// Define registers a PHP class for the name passed, using function fn as
// constructor for individual object instances as needed by the PHP context.
//
// The class name registered is assumed to be unique for the active engine.
//
// The constructor function accepts a slice of arguments, as passed by the PHP
// context, and should return a method receiver instance, or nil on error (in
// which case, an exception is thrown on the PHP object constructor).
Define registers a PHP class for the name passed, using function fn as
constructor for individual object instances as needed by the PHP context.

The class name registered is assumed to be unique for the active engine.

The constructor function accepts a slice of arguments, as passed by the PHP
context, and should return a method receiver instance, or nil on error (in
which case, an exception is thrown on the PHP object constructor).
// Define registers a PHP class for the name passed using function fn as // constructor for individual object instances as needed by the PHP context . // // The class name registered is assumed to be unique for the active engine . // // The constructor function accepts a slice of arguments as passed by the PHP // context and should return a method receiver instance or nil on error ( in // which case an exception is thrown on the PHP object constructor ) .
func (e *Engine) Define(name string, fn func(args []interface{}) interface{}) error {
	if _, exists := e.receivers[name]; exists {
		return fmt.Errorf("Failed to define duplicate receiver '%s'", name)
	}
	rcvr := &Receiver{
		name:    name,
		create:  fn,
		objects: make(map[*C.struct__zend_object]*ReceiverObject),
	}
	n := C.CString(name)
	defer C.free(unsafe.Pointer(n))
	C.receiver_define(n)
	e.receivers[name] = rcvr
	return nil
}
func ( e * Engine ) Define ( name string , fn func ( args [ ] interface { } ) interface { } ) error { if _ , exists := e . receivers [ name ] ; exists { return fmt . Errorf ( " " , name ) } rcvr := & Receiver { name : name , create : fn , objects : make ( map [ * C . struct__zend_object ] * ReceiverObject ) , } n := C . CString ( name ) defer C . free ( unsafe . Pointer ( n ) ) C . receiver_define ( n ) e . receivers [ name ] = rcvr return nil }
Define registers a PHP class for the name passed, using function fn as
constructor for individual object instances as needed by the PHP context.
Define registers a PHP class for the name passed using function fn as constructor for individual object instances as needed by the PHP context .