getOrCreateDocuments() public method

Supported hints are - refresh: reload the fields from the database if set - locale: use this locale instead of the one from the annotation or the default - fallback: whether to try other languages or throw a not found exception if the desired locale is not found. defaults to true if not set and locale is not given either. - prefetch: if set to false, do not attempt to prefetch related data. (This makes sense when the caller already did this beforehand.)
public getOrCreateDocuments ( null | string $className, Iterato\Iterator | array $nodes, array &$hints = [] ) : array
$className null | string
$nodes Iterato\Iterator | array
$hints array
return array
Beispiel #1
0
 /**
  * {@inheritDoc}
  */
 public function findMany($className, array $ids)
 {
     $uuids = array();
     foreach ($ids as $key => $id) {
         if (UUIDHelper::isUUID($id)) {
             $uuids[$id] = $key;
         } elseif (strpos($id, '/') !== 0) {
             $ids[$key] = '/' . $id;
         }
     }
     if (!empty($uuids)) {
         $nodes = $this->session->getNodesByIdentifier(array_keys($uuids));
         foreach ($nodes as $node) {
             /** @var $node \PHPCR\NodeInterface */
             $id = $node->getPath();
             $ids[$uuids[$node->getIdentifier()]] = $id;
             unset($uuids[$id]);
         }
         if (!empty($uuids)) {
             // skip not found ids
             $ids = array_diff($ids, array_keys($uuids));
         }
     }
     $nodes = $this->session->getNodes($ids);
     $hints = array('fallback' => true);
     $documents = $this->unitOfWork->getOrCreateDocuments($className, $nodes, $hints);
     return new ArrayCollection($documents);
 }