[COMPONENT][Collection] Refactoring: Further work in abstracting collections
This commit is contained in:
@@ -33,20 +33,20 @@ namespace Plugin\AttachmentCollections;
|
||||
|
||||
use App\Core\DB\DB;
|
||||
use App\Core\Event;
|
||||
use App\Core\Modules\Collection;
|
||||
use function App\Core\I18n\_m;
|
||||
use App\Core\Router\RouteLoader;
|
||||
use App\Core\Router\Router;
|
||||
use App\Entity\Actor;
|
||||
use App\Entity\Feed;
|
||||
use App\Entity\LocalUser;
|
||||
use App\Util\Nickname;
|
||||
use Component\Collection\Util\MetaCollectionPlugin;
|
||||
use Plugin\AttachmentCollections\Controller\AttachmentCollections as AttachmentCollectionsController;
|
||||
use Plugin\AttachmentCollections\Entity\AttachmentCollection;
|
||||
use Plugin\AttachmentCollections\Entity\AttachmentCollectionEntry;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use function App\Core\I18n\_m;
|
||||
|
||||
class AttachmentCollections extends Collection
|
||||
class AttachmentCollections extends MetaCollectionPlugin
|
||||
{
|
||||
protected function createCollection(Actor $owner, array $vars, string $name)
|
||||
{
|
||||
@@ -128,12 +128,12 @@ class AttachmentCollections extends Collection
|
||||
$r->connect(
|
||||
id: 'collections_view_by_actor_id',
|
||||
uri_path: '/actor/{id<\d+>}/collections',
|
||||
target: [AttachmentCollectionsController::class, 'collectionsListViewByActorId'],
|
||||
target: [AttachmentCollectionsController::class, 'collectionsViewByActorId'],
|
||||
);
|
||||
$r->connect(
|
||||
id: 'collections_view_by_nickname',
|
||||
uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/collections',
|
||||
target: [AttachmentCollectionsController::class, 'collectionsListViewByActorNickname'],
|
||||
target: [AttachmentCollectionsController::class, 'collectionsViewByActorNickname'],
|
||||
);
|
||||
// View notes from a collection by actor id and nickname
|
||||
$r->connect(
|
||||
|
@@ -23,12 +23,12 @@ declare(strict_types = 1);
|
||||
|
||||
namespace Plugin\AttachmentCollections\Controller;
|
||||
|
||||
use App\Core\Controller\CollectionController;
|
||||
use App\Core\DB\DB;
|
||||
use App\Core\Router\Router;
|
||||
use Component\Collection\Util\Controller\MetaCollectionController;
|
||||
use Plugin\AttachmentCollections\Entity\AttachmentCollection;
|
||||
|
||||
class AttachmentCollections extends CollectionController
|
||||
class AttachmentCollections extends MetaCollectionController
|
||||
{
|
||||
public function createCollection(int $owner_id, string $name)
|
||||
{
|
||||
@@ -69,7 +69,7 @@ class AttachmentCollections extends CollectionController
|
||||
'bare_notes' => array_values($notes),
|
||||
];
|
||||
}
|
||||
public function getCollectionsBy(int $owner_id): array
|
||||
public function getCollectionsByActorId(int $owner_id): array
|
||||
{
|
||||
return DB::findBy(AttachmentCollection::class, ['actor_id' => $owner_id], order_by: ['id' => 'desc']);
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
{% extends 'collections/collection_entry_view.html.twig' %}
|
||||
{% extends 'collection/collection_entry_view.html.twig' %}
|
||||
|
||||
{% block collection_items %}
|
||||
{% for key, attachment in attachments %}
|
||||
|
Reference in New Issue
Block a user