Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Collection extends \ILLI\Core\Object
- {
- protected function prototypeMethod($data, $bar)
- {
- $data[] = 'Execute Proto-Method '.__METHOD__;
- return compact('data', 'bar');
- }
- public function method($data, $bar)
- {
- $data[] = 'Execute Method '.__METHOD__;
- return $this->prototype(__FUNCTION__, get_defined_vars());
- }
- }
- $test = new Collection([
- '__proto' =>
- [
- 'method' => function($data, $bar)
- {
- $data[] = 'Execute Proto-Method '.__METHOD__;
- return compact('data', 'bar');
- }
- ],
- '__method' =>
- [
- 'methodx' => function($data, $bar)
- {
- $data[] = 'Execute Method '.__METHOD__;
- return compact('data', 'bar');
- }
- ]
- ]);
- $test->applyMethodFilter('method', function(array $params = [], \ILLI\Core\Filter $chain)
- {
- $params['data'][] = 'Starting filter';
- $params = $chain->next($params, $chain);
- $params['data'][] = 'Ending filter';
- return $params;
- });
- $test->applyMethodFilter('method', function(array $params = [], \ILLI\Core\Filter $chain)
- {
- $params['data'][] = 'Starting inner filter';
- $params = $chain->next($params, $chain);
- $params['data'][] = 'Ending inner filter';
- return $params;
- });
- $result = $test->method(['Starting test'], 'Hello World');
- /*
- array(1) {
- ["result"]=>
- array(2) {
- ["data"]=>
- array(7) {
- [0]=>
- string(13) "Starting test"
- [1]=>
- string(38) "Execute Method root\Collection::method"
- [2]=>
- string(15) "Starting filter"
- [3]=>
- string(21) "Starting inner filter"
- [4]=>
- string(35) "Execute Proto-Method root\{closure}"
- [5]=>
- string(19) "Ending inner filter"
- [6]=>
- string(13) "Ending filter"
- }
- ["bar"]=>
- string(11) "Hello World"
- }
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement