From 397b54a207c38250946f5d7b25b30a9140c914c6 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Tue, 15 Feb 2022 20:01:27 +0000 Subject: [PATCH] [PLUGIN][Bundles] Refactor BlogCollections to Bundles --- .../BlogCollections.php => Bundles/Bundles.php} | 16 ++++++++-------- .../Controller/BundleCollections.php} | 12 ++++++------ .../Entity/BundleCollection.php} | 4 ++-- .../Entity/BundleCollectionEntry.php} | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) rename plugins/{BlogCollections/BlogCollections.php => Bundles/Bundles.php} (89%) rename plugins/{BlogCollections/Controller/BlogCollections.php => Bundles/Controller/BundleCollections.php} (86%) rename plugins/{BlogCollections/Entity/BlogCollection.php => Bundles/Entity/BundleCollection.php} (97%) rename plugins/{BlogCollections/Entity/BlogCollectionEntry.php => Bundles/Entity/BundleCollectionEntry.php} (97%) diff --git a/plugins/BlogCollections/BlogCollections.php b/plugins/Bundles/Bundles.php similarity index 89% rename from plugins/BlogCollections/BlogCollections.php rename to plugins/Bundles/Bundles.php index ec36030e78..c411e1f02f 100644 --- a/plugins/BlogCollections/BlogCollections.php +++ b/plugins/Bundles/Bundles.php @@ -20,28 +20,28 @@ declare(strict_types = 1); // }}} -namespace Plugin\BlogCollections; +namespace Plugin\Bundles; use App\Core\DB\DB; use App\Core\Modules\Plugin; use App\Entity\Actor; use Component\Collection\Util\MetaCollectionTrait; -use Plugin\BlogCollections\Entity\BlogCollection; -use Plugin\BlogCollections\Entity\BlogCollectionEntry; +use Plugin\Bundles\Entity\BundleCollection; +use Plugin\Bundles\Entity\BundleCollectionEntry; use Symfony\Component\HttpFoundation\Request; -class BlogCollections extends Plugin +class Bundles extends Plugin { use MetaCollectionTrait; protected function createCollection(Actor $owner, array $vars, string $name) { - $column = BlogCollection::create([ + $column = BundleCollection::create([ 'name' => $name, 'actor_id' => $owner->getId(), ]); DB::persist($column); - DB::persist(BlogCollectionEntry::create(args: [ + DB::persist(BundleCollectionEntry::create(args: [ 'note_id' => $vars['vars']['note_id'], 'blog_collection_id' => $column->getId(), ])); @@ -69,7 +69,7 @@ class BlogCollections extends Plugin foreach ($items as $id) { // prevent user from putting something in a collection (s)he doesn't own: if (\in_array($id, $collections)) { - DB::persist(BlogCollectionEntry::create(args: [ + DB::persist(BundleCollectionEntry::create(args: [ 'note_id' => $vars['vars']['note_id'], 'blog_collection_id' => $id, ])); @@ -86,7 +86,7 @@ class BlogCollections extends Plugin protected function getCollectionsBy(Actor $owner, ?array $vars = null, bool $ids_only = false): array { if (\is_null($vars)) { - $res = DB::findBy(BlogCollection::class, ['actor_id' => $owner->getId()]); + $res = DB::findBy(BundleCollection::class, ['actor_id' => $owner->getId()]); } else { $res = DB::dql( <<<'EOF' diff --git a/plugins/BlogCollections/Controller/BlogCollections.php b/plugins/Bundles/Controller/BundleCollections.php similarity index 86% rename from plugins/BlogCollections/Controller/BlogCollections.php rename to plugins/Bundles/Controller/BundleCollections.php index 8999676a6a..75934586fc 100644 --- a/plugins/BlogCollections/Controller/BlogCollections.php +++ b/plugins/Bundles/Controller/BundleCollections.php @@ -21,14 +21,14 @@ declare(strict_types = 1); // }}} -namespace Plugin\BlogCollections\Controller; +namespace Plugin\Bundles\Controller; use App\Core\DB\DB; use App\Core\Router\Router; use Component\Collection\Util\Controller\MetaCollectionController; -use Plugin\BlogCollections\Entity\BlogCollection; +use Plugin\Bundles\Entity\BundleCollection; -class BlogCollections extends MetaCollectionController +class BundleCollections extends MetaCollectionController { public function getCollectionUrl(int $owner_id, string $owner_nickname, int $collection_id): string { @@ -65,17 +65,17 @@ class BlogCollections extends MetaCollectionController public function getCollectionsByActorId(int $owner_id): array { - return DB::findBy(BlogCollection::class, ['actor_id' => $owner_id], order_by: ['id' => 'desc']); + 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(BlogCollection::class, ['id' => $collection_id]); + return DB::findOneBy(BundleCollection::class, ['id' => $collection_id]); } public function createCollection(int $owner_id, string $name) { - DB::persist(BlogCollection::create([ + DB::persist(BundleCollection::create([ 'name' => $name, 'actor_id' => $owner_id, ])); diff --git a/plugins/BlogCollections/Entity/BlogCollection.php b/plugins/Bundles/Entity/BundleCollection.php similarity index 97% rename from plugins/BlogCollections/Entity/BlogCollection.php rename to plugins/Bundles/Entity/BundleCollection.php index c5b494a8fa..4f4672d3f0 100644 --- a/plugins/BlogCollections/Entity/BlogCollection.php +++ b/plugins/Bundles/Entity/BundleCollection.php @@ -21,7 +21,7 @@ declare(strict_types = 1); // }}} -namespace Plugin\BlogCollections\Entity; +namespace Plugin\Bundles\Entity; use App\Core\Entity; @@ -35,7 +35,7 @@ use App\Core\Entity; * @copyright 2022 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -class BlogCollection extends Entity +class BundleCollection extends Entity { // {{{ Autocode // @codeCoverageIgnoreStart diff --git a/plugins/BlogCollections/Entity/BlogCollectionEntry.php b/plugins/Bundles/Entity/BundleCollectionEntry.php similarity index 97% rename from plugins/BlogCollections/Entity/BlogCollectionEntry.php rename to plugins/Bundles/Entity/BundleCollectionEntry.php index f50afa5926..a667a40a4c 100644 --- a/plugins/BlogCollections/Entity/BlogCollectionEntry.php +++ b/plugins/Bundles/Entity/BundleCollectionEntry.php @@ -21,7 +21,7 @@ declare(strict_types = 1); // }}} -namespace Plugin\BlogCollections\Entity; +namespace Plugin\Bundles\Entity; use App\Core\Entity; @@ -35,7 +35,7 @@ use App\Core\Entity; * @copyright 2022 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -class BlogCollectionEntry extends Entity +class BundleCollectionEntry extends Entity { // {{{ Autocode // @codeCoverageIgnoreStart