/**
  * Create a new repository instance for a document class.
  *
  * @param DocumentManagerInterface  $dm             The DocumentManager instance.
  * @param string                    $documentName   The name of the document.
  *
  * @return \Doctrine\Common\Persistence\ObjectRepository
  */
 protected function createRepository(DocumentManagerInterface $dm, $documentName)
 {
     $metadata = $dm->getClassMetadata($documentName);
     $repositoryClassName = $metadata->customRepositoryClassName;
     if ($repositoryClassName === null) {
         $configuration = $dm->getConfiguration();
         $repositoryClassName = $configuration->getDefaultRepositoryClassName();
     }
     return new $repositoryClassName($dm, $metadata);
 }
 /**
  * @param NodeInterface[] $nodes
  */
 public function prefetch(DocumentManagerInterface $dm, $nodes, $locale = null)
 {
     if (!count($nodes)) {
         return;
     }
     $uuids = array();
     $paths = array();
     $documentClassMapper = $dm->getConfiguration()->getDocumentClassMapper();
     foreach ($nodes as $node) {
         $className = $documentClassMapper->getClassName($dm, $node);
         $class = $dm->getClassMetadata($className);
         if (!$locale && $class->translator) {
             $locale = $dm->getLocaleChooserStrategy()->getLocale();
         }
         $uuids = array_merge($uuids, $this->collectPrefetchReferences($class, $node));
         $paths = array_merge($paths, $this->collectPrefetchHierarchy($class, $node, $locale));
     }
     if (count($uuids)) {
         $node->getSession()->getNodesByIdentifier($uuids);
     }
     if (count($paths)) {
         $node->getSession()->getNodes($paths);
     }
 }
Exemple #3
0
 /**
  * @param DocumentManagerInterface $dm
  */
 public function __construct(DocumentManagerInterface $dm)
 {
     $this->dm = $dm;
     $this->session = $dm->getPhpcrSession();
     $this->eventListenersInvoker = new ListenersInvoker($dm);
     $this->eventManager = $dm->getEventManager();
     $config = $dm->getConfiguration();
     $this->documentClassMapper = $config->getDocumentClassMapper();
     $this->validateDocumentName = $config->getValidateDoctrineMetadata();
     $this->writeMetadata = $config->getWriteDoctrineMetadata();
     $this->uuidGenerator = $config->getUuidGenerator();
     if ($this->session instanceof JackalopeSession) {
         $this->useFetchDepth = 'jackalope.fetch_depth';
     }
 }
 /**
  * {@inheritDoc}
  */
 public function getConfiguration()
 {
     return $this->wrapped->getConfiguration();
 }
 /**
  * {@inheritdoc}
  */
 protected function getFqcnFromAlias($namespaceAlias, $simpleClassName)
 {
     return $this->dm->getConfiguration()->getDocumentNamespace($namespaceAlias) . '\\' . $simpleClassName;
 }