/**
  * @param string $uri
  * @param bool $includeHidden
  * @param FrontendPage $parentPage
  * @return stdClass
  */
 public static function findByUri($uri, $includeHidden = true, FrontendPage $parentPage = null)
 {
     $uri = trim($uri, '/');
     $urls = preg_split('/\\//', $uri, -1, PREG_SPLIT_NO_EMPTY);
     if ($parentPage === null) {
         $urls = array_merge([''], $urls);
     }
     $url = '';
     $pageObject = new \stdClass();
     $pageObject->id = 0;
     foreach ($urls as $pageSlug) {
         $url = ltrim($url . '/' . $pageSlug, '/');
         if ($pageObject = self::findBySlug($pageSlug, $parentPage, $includeHidden)) {
             if (!is_null($pageObject->getBehavior()) and $behavior = BehaviorManager::load($pageObject->getBehavior(), $pageObject)) {
                 $behavior->executeRoute($pageObject->getUri());
                 $pageObject->behaviorObject = $behavior;
                 return $pageObject;
             }
         } else {
             break;
         }
         $parentPage = $pageObject;
     }
     return $pageObject;
 }
 /**
  * @param PageRepository $pageRepository
  *
  * @throws \KodiCMS\Pages\Exceptions\BehaviorException
  */
 public function getSettings(PageRepository $pageRepository)
 {
     $pageId = $this->getParameter('pid');
     $behavior = $this->getRequiredParameter('behavior');
     if (!is_null($behavior = BehaviorManager::load($behavior))) {
         $page = $pageRepository->findOrFail($pageId);
         if ($page->hasBehavior()) {
             $behavior->setPage($page);
         }
     }
     return $this->setContent($behavior->getSettings()->render());
 }
Esempio n. 3
0
 /**
  * @return \KodiCMS\Pages\Contracts\Behavior\BehaviorInterface|void
  * @throws \KodiCMS\Pages\Exceptions\BehaviorException
  */
 public function getBehaviorObject()
 {
     if (!$this->hasBehavior()) {
         return;
     }
     return BehaviorManager::load($this->getBehavior());
 }
Esempio n. 4
0
 /**
  * @return null|\KodiCMS\Pages\Behavior\Decorator
  * @throws \KodiCMS\Pages\Exceptions\BehaviorException
  */
 public function getBehaviorObject()
 {
     if (is_null($this->behavior)) {
         return null;
     }
     return BehaviorManager::load($this->behavior);
 }