public function isComponentInstantiationAuthorised(Component $component)
 {
     if ($component instanceof WebPage && $component->getIdentifier()->of($this->pageAuthIdentifier)) {
         return $this->isAuthorised();
     }
     return true;
 }
Ejemplo n.º 2
0
 public function internalInitialize()
 {
     parent::internalInitialize();
     $callback = function (&$component) {
         $component->internalInitialize();
         return Component::VISITOR_CONTINUE_TRAVERSAL;
     };
     $this->visitChildren(Component::getIdentifier(), $callback);
 }
Ejemplo n.º 3
0
 protected function onComponentTagBody(ComponentTag $tag)
 {
     $this->getResponse()->write('<head>');
     parent::onComponentTagBody($tag);
     $page = $this->getPage();
     $headerResponse = new HeaderResponse($this->getResponse());
     PiconApplication::get()->getComponentRenderHeadListener()->onHeadRendering($this, $headerResponse);
     $page->renderHead($headerResponse);
     $self = $this;
     $callback = function (Component &$component) use($headerResponse, $self) {
         $component->renderHeadContainer($self, $headerResponse);
         return Component::VISITOR_CONTINUE_TRAVERSAL;
     };
     $page->visitChildren(Component::getIdentifier(), $callback);
     $this->getResponse()->write('</head>');
 }
 private function getSubmitForm()
 {
     $usingComponent = $this->form;
     $form = $this->form;
     if ($usingComponent == null) {
         $usingComponent = $this->getComponent();
     }
     $callback = function (&$component) use(&$form) {
         if ($component instanceof Form) {
             $form = $component;
         }
         if ($component instanceof ModalWindow) {
             return Component::VISITOR_STOP_TRAVERSAL;
         }
         return Component::VISITOR_CONTINUE_TRAVERSAL;
     };
     $usingComponent->visitParents(Component::getIdentifier(), $callback);
     return $form;
 }
Ejemplo n.º 5
0
 public function isPageStateless()
 {
     $stateless = $this->isStateless();
     if (!$stateless) {
         return $stateless;
     }
     $reflection = new \ReflectionClass(get_called_class());
     $constructor = $reflection->getConstructor();
     $params = $constructor->getParameters();
     //@todo also add page params to this when in place
     $stateless = count($params) == 0;
     if (!$stateless) {
         return $stateless;
     }
     $callback = function ($component) use(&$stateless) {
         if (!$component->isStateless()) {
             $stateless = false;
             return Component::VISITOR_STOP_TRAVERSAL;
         }
         return Component::VISITOR_CONTINUE_TRAVERSAL;
     };
     $this->visitChildren(Component::getIdentifier(), $callback);
     return $stateless;
 }
Ejemplo n.º 6
0
 private function renderComponentHeader(Component $component, Response $response, $headerResponse)
 {
     $header = new HeaderContainer(HeaderResolver::HEADER_ID);
     $page = $component->getPage();
     $page->addOrReplace($header);
     PiconApplication::get()->getComponentRenderHeadListener()->onHeadRendering($component, $headerResponse);
     $page->renderHead($headerResponse);
     $component->renderHeadContainer($header, $headerResponse);
     $callback = function (Component &$component) use($headerResponse, $header) {
         $component->renderHeadContainer($header, $headerResponse);
         return Component::VISITOR_CONTINUE_TRAVERSAL;
     };
     if ($component instanceof MarkupContainer) {
         $component->visitChildren(Component::getIdentifier(), $callback);
     }
 }
Ejemplo n.º 7
0
 public function getComponentPath()
 {
     $page = $this->getPage();
     if ($page == null) {
         throw new \IllegalStateException(sprintf("Unable to generate a path for component %s as it has an incomplete hierarchy.", $this->id));
     }
     $path = $this->getId();
     $callback = function ($component) use(&$path) {
         if (!$component instanceof WebPage) {
             $path = $component->getId() . Component::PATH_SEPERATOR . $path;
             return Component::VISITOR_CONTINUE_TRAVERSAL;
         }
         return Component::VISITOR_STOP_TRAVERSAL;
     };
     $this->visitParents(Component::getIdentifier(), $callback);
     return str_replace(self::PATH_SEPERATOR . self::PATH_SEPERATOR, '', $path . self::PATH_SEPERATOR);
 }