/** * {@inheritdoc} */ public function createWidget($name, $params = []) { if (!$this->hasWidget($name)) { throw new OutOfBoundsException($this->translate('Cannot create "{name}" widget. Widget is not registered in component "{component}".', ['name' => $name, 'component' => $this->component->getPath()])); } $widget = $this->createWidgetByClass($this->widgetList[$name], $params); $widget->setName($name); return $widget; }
/** * Возвращает результат работы дочернего компонента. * @param IComponent $component * @param IRouteResult $routeResult * @param SplStack $callStack * @param string $matchedRoutePath * @throws HttpNotFound если дочерний компонент не существует * @throws ResourceAccessForbiddenException если доступ к дочернему компоненту не разрешен * @return Response */ private function processChildComponentRequest(IComponent $component, IRouteResult $routeResult, SplStack $callStack, $matchedRoutePath) { $routeMatches = $routeResult->getMatches(); if (!$component->hasChildComponent($routeMatches[IComponent::MATCH_COMPONENT])) { throw new HttpNotFound($this->translate('Child component "{name}" not found in component "{componentPath}".', ['name' => $routeMatches[IComponent::MATCH_COMPONENT], 'componentPath' => $component->getPath()])); } /** * @var IComponent|IACLResource $childComponent */ $childComponent = $component->getChildComponent($routeMatches[IComponent::MATCH_COMPONENT]); if ($childComponent instanceof IACLResource && !$this->checkPermissions($component, $childComponent)) { throw new ResourceAccessForbiddenException($childComponent, $this->translate('Cannot execute component "{path}". Access denied.', ['path' => $childComponent->getPath()])); } $matchedRoutePath .= $routeResult->getMatchedUrl(); return $this->processRequest($childComponent, $routeResult->getUnmatchedUrl(), $callStack, $matchedRoutePath); }