/** * Call non-static component method. * * @param array $listener listener definition */ private static function callNonStaticListener($listener, $parameters) { if (isset($listener['component'])) { $component = Components::getInstance($listener['component']); } else { if (isset($listener['class'])) { $className = $listener['class']; $component = new $className(); } } $callable = [$component, $listener['method']]; call_user_func_array($callable, $parameters); }
private function in($component, $property, $annotations, $afterCall) { $inAnnotation = $this->annotationManager->getAnnotation($annotations, self::IN_ANNOTATION, $this->getTargetReflection($component, $property)); if (null !== $inAnnotation) { if ($afterCall) { $this->setToNull($component, $property); return; } $injectKey = $inAnnotation->value === null ? $property : $inAnnotation->value; $injectValue = Components::getInstance($injectKey); if ($inAnnotation->required && $injectValue === null) { $class = get_class($component); throw new InjectionException("{$class}::{$property} injection value is required."); } $class = get_class($component); $component->{$property} = $injectValue; } }
/** * Scope cannot set, juset get from Scopes in the given order. * Precedence of Scopes : * - event * - request * - page * - conversation // TODO * - session * - application // TODO * // TODO more comment about Scopes */ public function get($key, $default = null, $autoCreate = true) { $value = $this->eventScope->get($key); if (is_null($value)) { $value = $this->requestScope->get($key); } if (is_null($value)) { $value = $this->pageScope->get($key); } if (is_null($value)) { $value = $this->sessionScope->get($key); } if (is_null($value) && $autoCreate) { $value = Components::getInstance($key); } if (!is_null($value)) { //.... return $value; } return $default; }