For write operations, the object manager acts as the Unit of Work handler: it keeps track which nodes are dirty and updates them with the transport interface.
Ejemplo n.º 1
0
 public function current()
 {
     $path = $this->key();
     if (!isset($path)) {
         return null;
     }
     return $this->objectmanager->getNodeByPath($path);
 }
Ejemplo n.º 2
0
 /**
  * {@inheritDoc}
  *
  * @api
  */
 public function restore($removeExisting, $version, $absPath = null)
 {
     if ($this->objectManager->hasPendingChanges()) {
         throw new InvalidItemStateException('You may not call restore when there pending unsaved changes');
     }
     if (is_string($version)) {
         if (!is_string($absPath)) {
             throw new InvalidArgumentException('To restore version by version name you need to specify the path to the node you want to restore to this name');
         }
         $vh = $this->getVersionHistory($absPath);
         $version = $vh->getVersion($version);
         $versionPath = $version->getPath();
         $nodePath = $absPath;
     } elseif (is_array($version)) {
         // @codeCoverageIgnoreStart
         throw new NotImplementedException('TODO: implement restoring a list of versions');
         // @codeCoverageIgnoreEnd
     } elseif ($version instanceof VersionInterface && is_string($absPath)) {
         // @codeCoverageIgnoreStart
         throw new NotImplementedException('TODO: implement restoring a version to a specified path');
         // @codeCoverageIgnoreEnd
     } elseif ($version instanceof VersionInterface) {
         $versionPath = $version->getPath();
         $nodePath = $this->objectManager->getNodeByIdentifier($version->getContainingHistory()->getVersionableIdentifier())->getPath();
     } else {
         throw new InvalidArgumentException();
     }
     $this->objectManager->restore($removeExisting, $versionPath, $nodePath);
     $version->setCachedPredecessorsDirty();
     if ($history = $this->objectManager->getCachedNode(PathHelper::getParentPath($version->getPath()), 'Version\\VersionHistory')) {
         $history->notifyHistoryChanged();
     }
 }
Ejemplo n.º 3
0
 /**
  * {@inheritDoc}
  *
  * TODO: Make sure RollbackException and AccessDeniedException are thrown
  * by the transport if corresponding problems occur
  *
  * @api
  */
 public function rollback()
 {
     if (!$this->inTransaction) {
         throw new LogicException("No transaction to rollback.");
     }
     $this->objectManager->rollbackTransaction();
     $this->inTransaction = false;
 }
Ejemplo n.º 4
0
 /**
  * {@inheritDoc}
  *
  * @api
  */
 public function getNode($selectorName = null)
 {
     $path = $this->getPath($selectorName);
     if (!$path) {
         // handle outer joins
         return null;
     }
     return $this->objectmanager->getNodeByPath($this->getPath($selectorName));
 }
Ejemplo n.º 5
0
 /**
  * {@inheritDoc}
  *
  * @api
  */
 public function execute()
 {
     if (is_null($this->objectManager)) {
         // if the ObjectManager was not injected in the header. this is only supposed to happen in the DBAL client.
         throw new RepositoryException('Jackalope implementation error: This query was built for parsing only. (There is no ObjectManager to run the query against.)');
     }
     $transport = $this->objectManager->getTransport();
     $rawData = $transport->query($this);
     $queryResult = $this->factory->get('Query\\QueryResult', array($rawData, $this->objectManager));
     return $queryResult;
 }
Ejemplo n.º 6
0
 /**
  * {@inheritDoc}
  *
  * @api
  */
 public function getNodes($prefetch = false)
 {
     if ($prefetch !== true) {
         return $this->factory->get('Query\\NodeIterator', array($this->objectmanager, $this->rows));
     }
     $paths = array();
     foreach ($this->getRows() as $row) {
         $paths[] = $row->getPath();
     }
     return $this->objectmanager->getNodesByPath($paths);
 }
Ejemplo n.º 7
0
 /**
  * {@inheritDoc}
  *
  * @api
  */
 public function registerNodeTypesCnd($cnd, $allowUpdate)
 {
     //set fetched from backend to false to allow to load the new types from backend
     $fetched = $this->fetchedAllFromBackend;
     $this->fetchedAllFromBackend = false;
     $this->objectManager->registerNodeTypesCnd($cnd, $allowUpdate);
     //parse out type names and fetch types to return definitions of the new nodes
     preg_match_all('/\\[([^\\]]*)\\]/', $cnd, $names);
     $types = array();
     foreach ($names[1] as $name) {
         $types[$name] = $this->getNodeType($name);
     }
     $this->fetchedAllFromBackend = $fetched;
     return $types;
 }
Ejemplo n.º 8
0
 /**
  * {@inheritDoc}
  *
  * @api
  */
 public function getNode($selectorName = null)
 {
     return $this->objectmanager->getNodeByPath($this->getPath($selectorName));
 }
Ejemplo n.º 9
0
 /**
  * {@inheritDoc}
  *
  * @api
  */
 public function getSupportedQueryLanguages()
 {
     // Workspace checks if transport implements QueryInterface
     return $this->objectManager->getTransport()->getSupportedQueryLanguages();
 }
Ejemplo n.º 10
0
 /**
  * Implementation specific: The transport implementation is also used by
  * other components, i.e. the NamespaceRegistry
  *
  * @return TransportInterface the transport implementation associated with
  *      this session.
  *
  * @private
  */
 public function getTransport()
 {
     return $this->objectManager->getTransport();
 }