Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $test = new \ILLI\Core\Data\Object; // empty object (no methods, no fields)
- $test ->defineMethod('hello', function($name){ var_dump('-- hello: '.$name); return 'hello'; })
- ->defineMethod('world', function($name){ var_dump('-- world: '.$name); return 'world'; })
- ->defineMethod('foooo', function($name){ var_dump('-- foooo: '.$name); return 'foooo'; })
- ->defineMethod('baaar', function($name){ var_dump('-- baaar: '.$name); return 'baaar'; })
- ->defineSignal('hello', \ILLI\Core\Pattern\iSignal::POST_CALL, 'world')
- ->defineSignal('hello', \ILLI\Core\Pattern\iSignal::POST_CALL, 'foooo')
- ->defineSignal('hello', \ILLI\Core\Pattern\iSignal::POST_CALL, 'baaar')
- ->defineField('myProp', ['string'], [
- //\ILLI\Core\iField::PROP_FLAG => \ILLI\Core\iField::FLAG_IS_PRIVATE_SET | \ILLI\Core\iField::FLAG_IS_LOCKED,
- \ILLI\Core\iField::PROP_INIT => 'foobar',
- \ILLI\Core\iField::PROP_ON_SET => function($data) use ($test)
- {
- $test->hello($data[\ILLI\Core\iField::CALLBACK_PROP_NEW]);
- return $data;
- }]);
- $test ->myProp = 'foobaz';
- /**
- string(16) "-- hello: foobaz"
- string(16) "-- world: foobaz"
- string(16) "-- foooo: foobaz"
- string(16) "-- baaar: foobaz"
- object(ILLI\Core\Data\Object)#19 (6) {
- ["__tField_MemberProperties":"ILLI\Core\aObject":private]=>
- array(1) {
- ["myProp"]=>
- array(14) {
- ["init"]=>
- string(6) "foobar"
- ["contains"]=>
- string(6) "foobaz"
- ...
- */
- public function ILLI\Core\aObject::__call($__name, array $__args = [])
- {
- $name = strtolower($__name);
- if(FALSE === $this->tMethod_isDefined($name))
- return $this->tObject_template__call($__name, $__args);
- $this->tSignal_send($name, iSignal::PRE_CALL, $__args);
- $result = $this->tMethod_template__call($__name, $__args);
- $this->tSignal_send($name, iSignal::POST_CALL, $__args);
- return $result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement