<?php namespace Webfan; trait ngModuleTrait { protected $_blocks = []; abstract public function getName(): string; public function __invoke(\callable|\Closure $BlocksProcessor, ?string $name = null) { $n = $name ? explode('.', $name, 2) : [$name,$name]; $n[1] = isset($n[1]) ? $n[1] : $name; list($groupName, $controllerName) = $n; $groupName = '*' === $groupName ? null : $groupName; $controllerName = '*' === $controllerName ? null : $controllerName; foreach($this->_blocks as $type => $group){ foreach($group as $id => $block){ if(null === $name || null === $groupName || $type === $groupName || $type === $name || $type === $controllerName){ if(null === $name || null === $controllerName || $id === $controllerName || $id === $name || $id === $groupName){ // array_push($blocks, $block); \call_user_func_array($BlocksProcessor->bindTo($block, $this), [$block, $type, $id, $this]); } } } } //return \call_user_func_array($BlocksProcessor, [$this->getName(), $this, $this->_blocks]); } public function __call($method, $params) { $args = $params; $block = new \stdclass; $block->type = $method; if(!isset($this->_blocks[$block->type])){ $this->_blocks[$block->type] = []; } if(isset($args[0]) && is_string($args[0])){ $block->name = array_shift($args); }else{ $block->name = ucfirst($block->type).'Block'.(count($this->_blocks[$block->type]) + 1).'RandId'.mt_rand(10000,99999999); } if(isset($args[0]) && \is_callable($args[0])){ $block->controller = array_shift($args); $block->inject = $args; }elseif(isset($args[0]) && is_array($args[0])){ $injector = array_shift($args); if(\is_callable($injector[count($injector)-1])){ $block->controller = array_pop($injector); } $block->inject = $injector; }else{ $block->inject = $args; } if(!isset($block->controller)){ $block->controller = (function($args) use(&$block){ return $block; }); } $block->controller = $block->controller->bindTo($block, $this); if(isset($this->_blocks[$block->type][$block->name])){ throw new \Exception('A %1$s block with the name %2$s does exist already in %3$s!', $block->type, $block->name, __METHOD__); } $this->_blocks[$block->type][$block->name] = $block; return $this; } } __halt_compiler();----SIGNATURE:----ogSQziSpTcMMbUVPDriiYqWqJlIZzbBZm9nqOuv3JT0oW8oo7jE50lB6or24lebOnx0cN4Gj8NcuQJoeO0IzfzhuGZcXW7Q8N0RtPgaER7PUGX8MzfYEO1egt9h/5YbsyalhYwrld8VMCZTX8i9JD28z5QuIyiAcJKvqf46VHXTsO1NBUMB52GMK9N4WUWFg/TCJcEGYOoBHwawhPrJteWuEgc61UiKzfjgwANweHuM68SYijABHAjVs/nrSycMUglrXgaVvHMBGfL4PyhNU40/m/N7AZmkN1GHsWVMu4XqJ2OzcAoN8DkuGYRMOJcjJ7zZGiQFIQfTtIsQwcFyGt5L5FIdzxAXP55YGLD3btfR+aiBdmjZOH06we4xk+YQ2Kur+PnhIQEQbGuKnlHIbPrU6gQ76F26SdzXSiYjgkaO0kRvCyClvwPfmHc5aLyaC7AxZvdqc4BlXHOeWM6anCzr5/bU5DQsMCE/BErvGG0h0jTjWLAJolXwNLXlVMvJqXlsifc4nu0YOl0McFGU5Vybjy4BqL33DMnEcWLXwHcqpJbg63fCuupmIn87od3xa99Xq624T+0YMptxftSUuOLDh+XX5jfhuLAq9nxtMH0v4DAuU9Wq6cU0T1IEk6Ov38TQCoYarovK6WWiiZIpL2gQF7wj4qk+U2vofJ2EMkG8=----ATTACHMENT:----NDAwNjcyODY4NjY2Mzg3NiA3NTYxNTk1MjAzMzc0NDQ1IDIwNjMzNTA1MjI3NjAzMDM=