. // }}} namespace Plugin\Bundles\Controller; use App\Core\DB; use App\Core\Router; use Component\Collection\Util\Controller\MetaCollectionController; use Plugin\Bundles\Entity\BundleCollection; class BundleCollections extends MetaCollectionController { public function getCollectionUrl(int $owner_id, ?string $owner_nickname, int $collection_id): string { if (\is_null($owner_nickname)) { return Router::url( 'collection_notes_view_by_actor_id', ['id' => $owner_id, 'cid' => $collection_id], ); } return Router::url( 'collection_notes_view_by_nickname', ['nickname' => $owner_nickname, 'cid' => $collection_id], ); } public function getCollectionItems(int $owner_id, $collection_id): array { [$notes] = DB::dql( <<<'EOF' SELECT notice FROM \Plugin\BlogCollections\Entity\BlogCollectionEntry AS entry LEFT JOIN \App\Entity\Actor AS actor WITH entry.actor_id = :owner_id LEFT JOIN \App\Entity\Note AS notice WITH entry.note_id = notice.id WHERE entry.blog_collection_id = :collection_id EOF, ['collection_id' => $collection_id, 'owner_id' => $owner_id], ); return [ '_template' => 'BlogCollections/collection_entry_view.html.twig', 'bare_notes' => array_values($notes), ]; } public function getCollectionsByActorId(int $owner_id): array { return DB::findBy(BundleCollection::class, ['actor_id' => $owner_id], order_by: ['id' => 'desc']); } public function getCollectionBy(int $owner_id, int $collection_id) { return DB::findOneBy(BundleCollection::class, ['id' => $collection_id]); } public function createCollection(int $owner_id, string $name) { DB::persist(BundleCollection::create([ 'name' => $name, 'actor_id' => $owner_id, ])); } }