/** * Track a list of blocks for a collection * @param \Concrete\Core\Page\Collection\Collection $collection * @param Block[]|BlockController[] $blocks */ private function trackBlocks(Collection $collection, array $blocks) { $version = $collection->getVersionID(); $buffer = 0; foreach ($blocks as $block) { if ($block instanceof Controller) { $controller = $block; $block = $controller->getBlockObject(); } if ($block->getBlockTypeHandle() == BLOCK_HANDLE_STACK_PROXY) { if (!$controller) { $controller = $block->getController(); } $this->persist($controller->getStackID(), $collection->getCollectionID(), $version, $block->getBlockID()); $buffer++; } if ($buffer > 2) { $this->manager->flush(); $buffer = 0; } } if ($buffer) { // Sometimes you just need an extra flush... $this->manager->flush(); } }
/** * Forget about a collection object * @param \Concrete\Core\Page\Collection\Collection $collection */ private function forgetCollection(Collection $collection) { $query_builder = $this->manager->createQueryBuilder(); $query_builder->delete(FileUsageRecord::class, 'r')->where('r.collection_id = :collection_id')->setParameter('collection_id', $collection->getCollectionID())->getQuery()->execute(); }
public function getCollectionID() { return parent::getCollectionID(); }
private function countVersions(Collection $c) { /** @var Connection $database */ $database = $this->app['database']->connection(); $count = $database->fetchColumn('select count(cvID) from CollectionVersions where cID = :cID', [':cID' => $c->getCollectionID()]); return $count; }