Exemplo n.º 1
0
 protected function readSiteRevision(File $revisionFile)
 {
     $nodes = array();
     $json = $revisionFile->read();
     $nodesArray = $this->jsonParser->parseToPhp($json);
     foreach ($nodesArray as $nodeId => $nodeArray) {
         $nodes[$nodeId] = $this->getNodeFromArray($nodeArray);
     }
     return $nodes;
 }
Exemplo n.º 2
0
 /**
  * Handles the expired routes
  * @param \ride\library\system\file\File $nodeFile
  * @param \ride\library\cms\node\Node $node
  * @return null
  */
 protected function handleExpiredRoutes(File $nodeFile, Node $node)
 {
     $ini = $nodeFile->read();
     $oldNode = $this->getNodeFromIni($ini);
     $oldRoutes = $oldNode->getRoutes();
     $routes = $node->getRoutes();
     $locales = array_keys($oldRoutes + $routes);
     foreach ($locales as $locale) {
         $routeSet = isset($routes[$locale]);
         $oldRouteSet = isset($oldRoutes[$locale]);
         if ($routeSet && $oldRouteSet) {
             if ($routes[$locale] == $oldRoutes[$locale]) {
                 continue;
             }
             $this->expiredRouteModel->removeExpiredRoutesByPath($routes[$locale]);
             $this->expiredRouteModel->addExpiredRoute($node->getId(), $locale, $oldRoutes[$locale], $node->getRootNode()->getBaseUrl($locale));
         } elseif (!$routeSet && $oldRouteSet) {
             $this->expiredRouteModel->addExpiredRoute($node->getId(), $locale, $oldRoutes[$locale], $node->getRootNode()->getBaseUrl($locale));
         }
     }
 }
 /**
  * Reads the site revisions from the provided site directory
  * @param \ride\library\system\file\File $siteDirectory Directory of the site
  * @param string $defaultRevision Default revision for the site
  * @param string $revision Revision to load
  * @return array Array with the name of the revision as key and value
  * @throws \ride\library\cms\exception\CmsException when the site directory
  * could not be read
  */
 protected function readSiteRevisions(File $siteDirectory, $defaultRevision, &$revision = null)
 {
     $revisions = array();
     $files = $siteDirectory->read();
     foreach ($files as $file) {
         $revision = $file->getName(true);
         if ($revision === $this->archiveName || $revision === $this->trashName || !$file->isDirectory()) {
             continue;
         }
         $revisions[$revision] = $revision;
     }
     if (!$revisions) {
         throw new CmsException('No valid site in ' . $siteDirectory->getAbsolutePath());
     }
     if (isset($revisions[$defaultRevision])) {
         $revision = $defaultRevision;
     } else {
         $revision = reset($revisions);
     }
     return $revisions;
 }