public function getFunctions($ann, &$isCached = null) { $ann = strtolower(str_replace("@", "", $ann)); $dirs = array_merge(array($ann), $this->dirs); $isCached = true; $loader = Remember::wrap('function-discovery', function ($args) use(&$isCached) { $functions = array(); $isCached = false; $query = array_shift($args); $fs = new Filesystem($args); foreach ($fs->get($query, 'Callable') as $annotation) { $function = $annotation->getObject(); $static = false; if ($function->isMethod()) { $callback = [$function->getClass()->getName(), $function->getName()]; $static = $function->isStatic(); } else { $callback = $function->getName(); } try { $name = strtolower($annotation->getArg()); } catch (Exception $e) { $name = null; } $annotations = []; foreach ($annotation->getParent() as $annotation) { $annotations[] = [strtolower($annotation->getName()), $annotation->getArgs()]; } $wrapper = new TFunction($function->getFile(), $callback, $static); $wrapper->setAnnotations($annotations); if ($name) { $functions[$name] = $wrapper; } else { $functions[] = $wrapper; } } return $functions; }); return $loader($dirs); }
/** * Run custom initRequest when they have targeted a function name. * * @param string $processName processr name the initRequest is listening to * @param mixed &$argument Arguments * @param TFunction $event Event function object * @param TFunction $processr API call processr */ protected function runInitRequest($processName, &$argument, TFunction $event, TFunction $processr = null) { $arguments = array(); foreach ($argument['requests'] as $id => $request) { if ($request[0] === $processName) { $arguments[] =& $argument['requests'][$id][1]; } } if (!empty($arguments)) { $event->call(array(&$arguments, $this)); } }