/** * Resolves all of the arguments. If you do not send an array of arguments * it will use the Definition Arguments. * * @param array $args * @return array */ protected function resolveArguments($args = []) { $args = empty($args) ? $this->arguments : $args; $resolvedArguments = []; foreach ($args as $arg) { if (is_string($arg) && ($this->container->isRegistered($arg) || $this->container->isSingleton($arg) || class_exists($arg))) { $resolvedArguments[] = $this->container->get($arg); continue; } $resolvedArguments[] = $arg; } return $resolvedArguments; }
/** * Handles response to Method Argument Strategy * * @param string|array|\Closure $controller * @param array $vars * @return \Orno\Http\ResponseInterface */ protected function handleMethodArgumentStrategy($controller, array $vars) { if (is_array($controller)) { $controller = [$this->container->get($controller[0]), $controller[1]]; } $response = $this->container->call($controller); return $this->determineResponse($response); }
/** * {@inheritdoc} */ public function publish($event, array $args = []) { if (is_null($this->listener)) { throw new NoListenerException('You must provide an Event Publisher with a set of Listeners'); } foreach ($this->listener->getListeners($event) as $index => $callback) { if ($this->container instanceof ContainerInterface && is_string($callback) && false !== strpos($callback, '::')) { list($class, $method) = explode('::', $callback); $class = $this->container->get($class); call_user_func_array([$class, $method], $args); continue; } if (is_callable($callback)) { call_user_func_array($callback, $args); continue; } throw new InvalidCallbackException(sprintf('Could not invoke callback for event [%s] at index [%d]', $event, $index)); } }