Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function deleteByPath($path, $webspaceKey, $languageCode, $segmentKey = null)
 {
     if (!is_string($path) || trim($path, '/') == '') {
         throw new \InvalidArgumentException(sprintf('The path to delete must be a non-empty string, "%s" given.', $path));
     }
     $routeDocument = $this->documentManager->find($this->getPath($path, $webspaceKey, $languageCode, $segmentKey), $languageCode);
     $this->documentManager->remove($routeDocument);
 }
Exemplo n.º 2
0
 /**
  * Removes related route of given document.
  *
  * @param StructureBehavior $document
  */
 private function removeRoute(StructureBehavior $document)
 {
     foreach ($this->documentInspector->getReferrers($document) as $referrer) {
         if ($referrer instanceof RouteBehavior) {
             $this->documentManager->remove($referrer);
         }
     }
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function deleteRoute($webspaceKey, $uuid)
 {
     $routeDocument = $this->findRoute($uuid);
     if (!$routeDocument->isHistory()) {
         $route = PathHelper::relativizePath($routeDocument->getPath(), $this->getRoutesPath($webspaceKey));
         throw new RouteNotRemovableException($route, $routeDocument, $routeDocument->getTargetDocument());
     }
     $this->documentManager->remove($routeDocument);
     return $routeDocument;
 }
Exemplo n.º 4
0
 /**
  * Remove given Route and his history.
  *
  * @param $document
  */
 private function recursivelyRemoveRoutes(RouteBehavior $document)
 {
     $referrers = $this->documentInspector->getReferrers($document);
     foreach ($referrers as $referrer) {
         if (!$referrer instanceof RouteBehavior) {
             continue;
         }
         $this->recursivelyRemoveRoutes($referrer);
         $this->documentManager->remove($referrer);
     }
 }
Exemplo n.º 5
0
 /**
  * Removes the routes for the given document.
  *
  * @param RemoveEvent $event
  */
 public function handleRemove(RemoveEvent $event)
 {
     $document = $event->getDocument();
     if (!$document instanceof CustomUrlBehavior) {
         return;
     }
     foreach ($this->inspector->getReferrers($document) as $referrer) {
         if ($referrer instanceof RouteBehavior) {
             $this->documentManager->remove($referrer);
         }
     }
 }