[PLUGIN][Bundles] Refactor BlogCollections to Bundles
This commit is contained in:
parent
33e1d3eb20
commit
397b54a207
|
@ -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'
|
|
@ -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,
|
||||
]));
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue
Block a user