public function update(DocumentManagerInterface $documentManager, $document)
 {
     $metadataFactory = $documentManager->getMetadataFactory();
     $classFqn = ClassUtils::getRealClass(get_class($document));
     // PHPCR-ODM will throw an exception if the document is not mapped.
     $odmMetadata = $metadataFactory->getMetadataFor($classFqn);
     if (null === ($ctMetadata = $this->metadataFactory->getMetadataForClass($classFqn))) {
         return;
     }
     $this->doUpdate($metadataFactory, $odmMetadata, $ctMetadata, $document);
 }
 /**
  * Check each mapped PHPCR-ODM document for the given document manager,
  * throwing an exception if any document is set to use a unique node
  * type but the node type is re-used. Returns an array of debug information.
  *
  * @param DocumentManagerInterface $documentManager The document manager to check mappings for.
  *
  * @return array
  *
  * @throws MappingException
  */
 public function checkNodeTypeMappings(DocumentManagerInterface $documentManager)
 {
     $knownNodeTypes = array();
     $debugInformation = array();
     $allMetadata = $documentManager->getMetadataFactory()->getAllMetadata();
     foreach ($allMetadata as $classMetadata) {
         if ($classMetadata->hasUniqueNodeType() && isset($knownNodeTypes[$classMetadata->getNodeType()])) {
             throw new MappingException(sprintf('The class "%s" is mapped with uniqueNodeType set to true, but the node type "%s" is used by "%s" as well.', $classMetadata->name, $classMetadata->getNodeType(), $knownNodeTypes[$classMetadata->getNodeType()]));
         }
         $knownNodeTypes[$classMetadata->getNodeType()] = $classMetadata->name;
         $debugInformation[$classMetadata->name] = array('unique_node_type' => $classMetadata->hasUniqueNodeType(), 'node_type' => $classMetadata->getNodeType());
     }
     return $debugInformation;
 }
 /**
  * {@inheritDoc}
  */
 public function getMetadataFactory()
 {
     return $this->wrapped->getMetadataFactory();
 }
Esempio n. 4
0
 public function __construct(DocumentManagerInterface $dm, QueryObjectModelFactoryInterface $qomf)
 {
     $this->qomf = $qomf;
     $this->mdf = $dm->getMetadataFactory();
     $this->dm = $dm;
 }
Esempio n. 5
0
 /**
  * Initializes a new instance of the <tt>ProxyFactory</tt> class that is
  * connected to the given <tt>DocumentManager</tt>.
  *
  * @param DocumentManagerInterface $documentManager The DocumentManager the new factory works for.
  * @param string                   $proxyDir        The directory to use for the proxy classes. It must exist.
  * @param string                   $proxyNamespace  The namespace to use for the proxy classes.
  * @param boolean                  $autoGenerate    Whether to automatically generate proxy classes.
  */
 public function __construct(DocumentManagerInterface $documentManager, $proxyDir, $proxyNamespace, $autoGenerate = false)
 {
     parent::__construct(new ProxyGenerator($proxyDir, $proxyNamespace), $documentManager->getMetadataFactory(), $autoGenerate);
     $this->documentManager = $documentManager;
     $this->proxyNamespace = $proxyNamespace;
 }