getPreloadContainer() public method

public getPreloadContainer ( ) : Nextras\Orm\Collection\IEntityPreloadContainer
return Nextras\Orm\Collection\IEntityPreloadContainer
Ejemplo n.º 1
0
 /**
  * @return ICollection
  */
 protected function getCachedCollection()
 {
     $key = spl_object_hash($this->parent->getPreloadContainer()) . '_' . $this->metadata->name;
     $cache = $this->parent->getRepository()->getMapper()->getCollectionCache();
     if (!isset($cache->{$key})) {
         $cache->{$key} = $this->createCollection();
     }
     $this->collection = $cache->{$key};
     return $cache->{$key};
 }
 protected function execute(DbalCollection $collection, IEntity $parent)
 {
     $builder = $collection->getQueryBuilder();
     $preloadIterator = $parent->getPreloadContainer();
     $cacheKey = $this->calculateCacheKey($builder, $preloadIterator, $parent);
     $data =& $this->cacheEntityContainers[$cacheKey];
     if ($data) {
         return $data;
     }
     $values = $preloadIterator ? $preloadIterator->getPreloadValues($this->metadata->name) : [$parent->getRawValue($this->metadata->name)];
     $data = $this->fetch(clone $builder, stripos($cacheKey, 'JOIN') !== FALSE, $values, $preloadIterator);
     return $data;
 }
Ejemplo n.º 3
0
 protected function execute(ICollection $collection, IEntity $parent)
 {
     $collectionMapper = $collection->getCollectionMapper();
     if (!$collectionMapper instanceof CollectionMapper) {
         throw new LogicException();
     }
     $builder = $collectionMapper->getSqlBuilder();
     $preloadIterator = $parent->getPreloadContainer();
     $values = $preloadIterator ? $preloadIterator->getPreloadValues($this->metadata->name) : [$parent->getRawValue($this->metadata->name)];
     $cacheKey = md5($builder->buildSelectQuery() . json_encode($values));
     $data =& $this->cacheEntityContainers[$cacheKey];
     if ($data) {
         return $data;
     }
     $data = $this->fetch(clone $builder, stripos($cacheKey, 'JOIN') !== FALSE, $values);
     return $data;
 }
Ejemplo n.º 4
0
 protected function executeCounts(DbalCollection $collection, IEntity $parent)
 {
     $builder = $collection->getQueryBuilder();
     $preloadIterator = $parent->getPreloadContainer();
     $values = $preloadIterator ? $preloadIterator->getPreloadValues('id') : [$parent->getValue('id')];
     $cacheKey = $this->calculateCacheKey($builder, $values);
     $data =& $this->cacheCounts[$cacheKey];
     if ($data !== NULL) {
         return $data;
     }
     $data = $this->fetchCounts($builder, $values);
     return $data;
 }
Ejemplo n.º 5
0
 protected function executeCounts(ICollection $collection, IEntity $parent)
 {
     $collectionMapper = $collection->getCollectionMapper();
     if (!$collectionMapper instanceof CollectionMapper) {
         throw new LogicException();
     }
     $builder = $collectionMapper->getSqlBuilder();
     $preloadIterator = $parent->getPreloadContainer();
     $values = $preloadIterator ? $preloadIterator->getPreloadValues('id') : [$parent->id];
     $cacheKey = $this->calculateCacheKey($builder, $values);
     $data =& $this->cacheCounts[$cacheKey];
     if ($data !== NULL) {
         return $data;
     }
     $data = $this->fetchCounts($builder, $values);
     return $data;
 }