public function run(ApplicationInterface $app) { $connector = Connector::getInstance(); $connector->setSourcesBasePath(getcwd()); $matcher = new Matcher(); // redirect errors to PhpConsole \PhpConsole\Handler::getInstance()->start(); $app->getEventsHandler()->bind('*', function (EventInterface $event) use($app, $connector, $matcher) { /** * @var $connector \PhpConsole\Connector */ if ($connector->isActiveClient()) { $console = \PhpConsole\Handler::getInstance(); $context = $event->getContext(); $origin = $event->getOrigin(); switch (true) { case $event->getName() == 'application.workflow.step.run': $console->debug(sprintf('Starting running step %s', $origin->getName()), 'workflow.step'); break; case $event->getName() == 'application.workflow.hook.run': $middleware = $origin->getMiddleware(); $console->debug(sprintf('Running Middleware %s (%s)', $middleware->getReference(), $middleware->getDescription()), 'workflow.hook'); $this->dumpNotifications($console, $middleware->getNotifications()); break; case $matcher->match(ServicesFactory::EVENT_INSTANCE_BUILT . '.*', $event->getName()): $console->debug(sprintf('Built service %s (%s)', $context['serviceSpecs']->getId(), is_object($context['instance']) ? get_class($context['instance']) : get_type($context['instance'])), 'services'); break; case $matcher->match($event->getName(), '*.notify.*'): $this->dumpNotifications($console, $event->getContext('notifications')); break; } } }); }
public function testAlternateSeparator() { $matcher = new Matcher(); $matcher->separator('\\'); $this->assertEquals('\\', $matcher->separator()); $this->assertTrue($matcher->match('*\\event\\test', 'namespace\\event\\test')); }
/** * @param $service * * @return ServiceSpecsInterface */ public function getServiceSpecs($service) { if ($service instanceof ServiceReference) { $service = $service->getId(); } $specs = $this->services[$service] ?? null; if (is_null($specs)) { $matcher = new Matcher(); foreach ($this->services as $id => $specs) { if ($matcher->match($service, $id)) { return (clone $specs)->setId($service); break; } $specs = null; } } return $specs; }