[TOOLS] Continue raising PHPStan to level 6
This commit is contained in:
parent
e6bb418fe6
commit
c31f3d4997
@ -51,6 +51,8 @@ class Avatar extends Component
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SettingsTabsType $tabs
|
||||
*
|
||||
* @throws \App\Util\Exception\ClientException
|
||||
*/
|
||||
public function onPopulateSettingsTabs(Request $request, string $section, &$tabs): EventResult
|
||||
@ -129,6 +131,8 @@ class Avatar extends Component
|
||||
*
|
||||
* Returns the avatar file's hash, mimetype, title and path.
|
||||
* Ensures exactly one cached value exists
|
||||
*
|
||||
* @return array{id: null|int, filename: null|string, title: string, mimetype: string, filepath?: string}
|
||||
*/
|
||||
public static function getAvatarFileInfo(int $actor_id, string $size = 'medium'): array
|
||||
{
|
||||
|
@ -54,6 +54,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
*/
|
||||
class Circle extends Component
|
||||
{
|
||||
/** @phpstan-use MetaCollectionTrait<Circle> */
|
||||
use MetaCollectionTrait;
|
||||
public const TAG_CIRCLE_REGEX = '/' . Nickname::BEFORE_MENTIONS . '@#([\pL\pN_\-\.]{1,64})/';
|
||||
protected const SLUG = 'circle';
|
||||
@ -107,6 +108,9 @@ class Circle extends Component
|
||||
return Event::next;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Actor[] $targets
|
||||
*/
|
||||
public function onPostingFillTargetChoices(Request $request, Actor $actor, array &$targets): EventResult
|
||||
{
|
||||
$circles = $actor->getCircles();
|
||||
@ -119,6 +123,9 @@ class Circle extends Component
|
||||
|
||||
// Meta Collection -------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $vars
|
||||
*/
|
||||
private function getActorIdFromVars(array $vars): int
|
||||
{
|
||||
$id = $vars['request']->get('id', null);
|
||||
@ -130,7 +137,7 @@ class Circle extends Component
|
||||
return $user->getId();
|
||||
}
|
||||
|
||||
public static function createCircle(Actor|int $tagger_id, string $tag): int
|
||||
public static function createCircle(Actor|int $tagger_id, string $tag): int|null
|
||||
{
|
||||
$tagger_id = \is_int($tagger_id) ? $tagger_id : $tagger_id->getId();
|
||||
$circle = ActorCircle::create([
|
||||
@ -146,7 +153,10 @@ class Circle extends Component
|
||||
return $circle->getId();
|
||||
}
|
||||
|
||||
protected function createCollection(Actor $owner, array $vars, string $name)
|
||||
/**
|
||||
* @param array<string, mixed> $vars
|
||||
*/
|
||||
protected function createCollection(Actor $owner, array $vars, string $name): void
|
||||
{
|
||||
$this->createCircle($owner, $name);
|
||||
DB::persist(ActorTag::create([
|
||||
@ -156,7 +166,12 @@ class Circle extends Component
|
||||
]));
|
||||
}
|
||||
|
||||
protected function removeItem(Actor $owner, array $vars, $items, array $collections)
|
||||
/**
|
||||
* @param array<string, mixed> $vars
|
||||
* @param array<int> $items
|
||||
* @param array<mixed> $collections
|
||||
*/
|
||||
protected function removeItem(Actor $owner, array $vars, array $items, array $collections): bool
|
||||
{
|
||||
$tagger_id = $owner->getId();
|
||||
$tagged_id = $this->getActorIdFromVars($vars);
|
||||
@ -169,9 +184,15 @@ class Circle extends Component
|
||||
DB::removeBy(ActorTag::class, ['tagger' => $tagger_id, 'tagged' => $tagged_id, 'tag' => $tag]);
|
||||
}
|
||||
Cache::delete(Actor::cacheKeys($tagger_id)['circles']);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function addItem(Actor $owner, array $vars, $items, array $collections)
|
||||
/**
|
||||
* @param array<string, mixed> $vars
|
||||
* @param array<int> $items
|
||||
* @param array<mixed> $collections
|
||||
*/
|
||||
protected function addItem(Actor $owner, array $vars, array $items, array $collections): void
|
||||
{
|
||||
$tagger_id = $owner->getId();
|
||||
$tagged_id = $this->getActorIdFromVars($vars);
|
||||
@ -188,8 +209,10 @@ class Circle extends Component
|
||||
|
||||
/**
|
||||
* @see MetaCollectionPlugin->shouldAddToRightPanel
|
||||
*
|
||||
* @param array<string, mixed> $vars
|
||||
*/
|
||||
protected function shouldAddToRightPanel(Actor $user, $vars, Request $request): bool
|
||||
protected function shouldAddToRightPanel(Actor $user, array $vars, Request $request): bool
|
||||
{
|
||||
return \in_array($vars['path'], ['actor_view_nickname', 'actor_view_id']);
|
||||
}
|
||||
@ -201,9 +224,11 @@ class Circle extends Component
|
||||
* Differs from the overwritten method in MetaCollectionsTrait, since retrieved Collections come from the $owner
|
||||
* itself, and from every Actor that is a part of its ActorCircle.
|
||||
*
|
||||
* @param Actor $owner the Actor, and by extension its own circle of Actors
|
||||
* @param null|array $vars Page vars sent by AppendRightPanelBlock event
|
||||
* @param bool $ids_only true if only the Collections ids are to be returned
|
||||
* @param Actor $owner the Actor, and by extension its own circle of Actors
|
||||
* @param null|array<string, mixed> $vars Page vars sent by AppendRightPanelBlock event
|
||||
* @param bool $ids_only true if only the Collections ids are to be returned
|
||||
*
|
||||
* @return Circle[]|int[]
|
||||
*/
|
||||
protected function getCollectionsBy(Actor $owner, ?array $vars = null, bool $ids_only = false): array
|
||||
{
|
||||
|
@ -38,6 +38,8 @@ class Circle extends CircleController
|
||||
*
|
||||
* @throws \App\Util\Exception\ServerException
|
||||
* @throws ClientException
|
||||
*
|
||||
* @return ControllerResultType
|
||||
*/
|
||||
public function circleById(int|ActorCircle $circle_id): array
|
||||
{
|
||||
@ -57,11 +59,17 @@ class Circle extends CircleController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ControllerResultType
|
||||
*/
|
||||
public function circleByTaggerIdAndTag(int $tagger_id, string $tag): array
|
||||
{
|
||||
return $this->circleById(ActorCircle::getByPK(['tagger' => $tagger_id, 'tag' => $tag]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ControllerResultType
|
||||
*/
|
||||
public function circleByTaggerNicknameAndTag(string $tagger_nickname, string $tag): array
|
||||
{
|
||||
return $this->circleById(ActorCircle::getByPK(['tagger' => LocalUser::getByNickname($tagger_nickname)->getId(), 'tag' => $tag]));
|
||||
|
@ -31,16 +31,20 @@ use App\Entity\LocalUser;
|
||||
use Component\Circle\Entity\ActorCircle;
|
||||
use Component\Collection\Util\Controller\MetaCollectionController;
|
||||
|
||||
/**
|
||||
* @extends MetaCollectionController<Circles>
|
||||
*/
|
||||
class Circles extends MetaCollectionController
|
||||
{
|
||||
protected const SLUG = 'circle';
|
||||
protected const PLURAL_SLUG = 'circles';
|
||||
protected string $page_title = 'Actor circles';
|
||||
|
||||
public function createCollection(int $owner_id, string $name)
|
||||
public function createCollection(int $owner_id, string $name): bool
|
||||
{
|
||||
return \Component\Circle\Circle::createCircle($owner_id, $name);
|
||||
return !\is_null(\Component\Circle\Circle::createCircle($owner_id, $name));
|
||||
}
|
||||
|
||||
public function getCollectionUrl(int $owner_id, ?string $owner_nickname, int $collection_id): string
|
||||
{
|
||||
return Router::url(
|
||||
@ -49,21 +53,26 @@ class Circles extends MetaCollectionController
|
||||
);
|
||||
}
|
||||
|
||||
public function getCollectionItems(int $owner_id, $collection_id): array
|
||||
/**
|
||||
* @return Circles[]
|
||||
*/
|
||||
public function getCollectionItems(int $owner_id, int $collection_id): array
|
||||
{
|
||||
$notes = []; // TODO: Use Feed::query
|
||||
return [
|
||||
'_template' => 'collection/notes.html.twig',
|
||||
'notes' => $notes,
|
||||
];
|
||||
return []; // TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Circles[]
|
||||
*/
|
||||
public function feedByCircleId(int $circle_id)
|
||||
{
|
||||
// Owner id isn't used
|
||||
return $this->getCollectionItems(0, $circle_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Circles[]
|
||||
*/
|
||||
public function feedByTaggerIdAndTag(int $tagger_id, string $tag)
|
||||
{
|
||||
// Owner id isn't used
|
||||
@ -71,6 +80,9 @@ class Circles extends MetaCollectionController
|
||||
return $this->getCollectionItems($tagger_id, $circle_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Circles[]
|
||||
*/
|
||||
public function feedByTaggerNicknameAndTag(string $tagger_nickname, string $tag)
|
||||
{
|
||||
$tagger_id = LocalUser::getByNickname($tagger_nickname)->getId();
|
||||
@ -78,6 +90,9 @@ class Circles extends MetaCollectionController
|
||||
return $this->getCollectionItems($tagger_id, $circle_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ActorCircle[]
|
||||
*/
|
||||
public function getCollectionsByActorId(int $owner_id): array
|
||||
{
|
||||
return DB::findBy(ActorCircle::class, ['tagger' => $owner_id], order_by: ['id' => 'desc']);
|
||||
@ -87,7 +102,7 @@ class Circles extends MetaCollectionController
|
||||
return DB::findOneBy(ActorCircle::class, ['id' => $collection_id, 'actor_id' => $owner_id]);
|
||||
}
|
||||
|
||||
public function setCollectionName(int $actor_id, string $actor_nickname, ActorCircle $collection, string $name)
|
||||
public function setCollectionName(int $actor_id, string $actor_nickname, ActorCircle $collection, string $name): void
|
||||
{
|
||||
foreach ($collection->getActorTags(db_reference: true) as $at) {
|
||||
$at->setTag($name);
|
||||
@ -96,7 +111,7 @@ class Circles extends MetaCollectionController
|
||||
Cache::delete(Actor::cacheKeys($actor_id)['circles']);
|
||||
}
|
||||
|
||||
public function removeCollection(int $actor_id, string $actor_nickname, ActorCircle $collection)
|
||||
public function removeCollection(int $actor_id, string $actor_nickname, ActorCircle $collection): void
|
||||
{
|
||||
foreach ($collection->getActorTags(db_reference: true) as $at) {
|
||||
DB::remove($at);
|
||||
|
@ -25,6 +25,7 @@ use App\Core\Cache;
|
||||
use App\Core\DB;
|
||||
use App\Core\Entity;
|
||||
use App\Core\Router;
|
||||
use App\Entity\Actor;
|
||||
use DateTimeInterface;
|
||||
|
||||
/**
|
||||
@ -144,6 +145,9 @@ class ActorCircle extends Entity
|
||||
return $this->tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ActorTag[]
|
||||
*/
|
||||
public function getActorTags(bool $db_reference = false): array
|
||||
{
|
||||
$handle = fn () => DB::findBy('actor_tag', ['tagger' => $this->getTagger(), 'tag' => $this->getTag()]);
|
||||
@ -156,7 +160,10 @@ class ActorCircle extends Entity
|
||||
);
|
||||
}
|
||||
|
||||
public function getTaggedActors()
|
||||
/**
|
||||
* @return Actor[]
|
||||
*/
|
||||
public function getTaggedActors(): array
|
||||
{
|
||||
return Cache::get(
|
||||
"circle-{$this->getId()}-tagged-actors",
|
||||
@ -170,6 +177,9 @@ class ActorCircle extends Entity
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Actor[]
|
||||
*/
|
||||
public function getSubscribedActors(?int $offset = null, ?int $limit = null): array
|
||||
{
|
||||
return Cache::get(
|
||||
|
@ -7,14 +7,18 @@ namespace Component\Circle\Form;
|
||||
use App\Core\Form;
|
||||
use function App\Core\I18n\_m;
|
||||
use App\Util\Form\ArrayTransformer;
|
||||
use Component\Circle\Entity\ActorTag;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
abstract class SelfTagsForm
|
||||
{
|
||||
/**
|
||||
* @return array [Form (add), ?Form (existing)]
|
||||
* @param ActorTag[] $actor_self_tags
|
||||
*
|
||||
* @return array{FormInterface, ?FormInterface} [Form (add), ?Form (existing)]
|
||||
*/
|
||||
public static function handleTags(
|
||||
Request $request,
|
||||
|
@ -23,6 +23,10 @@ class Collection extends Component
|
||||
*
|
||||
* Supports a variety of query terms and is used both in feeds and
|
||||
* in search. Uses query builders to allow for extension
|
||||
*
|
||||
* @param array<string, OrderByType> $note_order_by
|
||||
* @param array<string, OrderByType> $actor_order_by
|
||||
* @return array{notes: Note[], actors: Actor[]}
|
||||
*/
|
||||
public static function query(string $query, int $page, ?string $locale = null, ?Actor $actor = null, array $note_order_by = [], array $actor_order_by = []): array
|
||||
{
|
||||
|
@ -7,14 +7,22 @@ namespace Component\Collection\Util\Controller;
|
||||
use App\Core\Controller;
|
||||
use App\Entity\Actor;
|
||||
use App\Util\Common;
|
||||
use Component\Collection\Collection as CollectionModule;
|
||||
use Component\Collection\Collection as CollectionComponent;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
class Collection extends Controller
|
||||
{
|
||||
/**
|
||||
* @param array<string, OrderByType> $note_order_by
|
||||
* @param array<string, OrderByType> $actor_order_by
|
||||
* @return array<T>
|
||||
*/
|
||||
public function query(string $query, ?string $locale = null, ?Actor $actor = null, array $note_order_by = [], array $actor_order_by = []): array
|
||||
{
|
||||
$actor ??= Common::actor();
|
||||
$locale ??= Common::currentLanguage()->getLocale();
|
||||
return CollectionModule::query($query, $this->int('page') ?? 1, $locale, $actor, $note_order_by, $actor_order_by);
|
||||
return CollectionComponent::query($query, $this->int('page') ?? 1, $locale, $actor, $note_order_by, $actor_order_by);
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,10 @@ abstract class FeedController extends OrderedCollection
|
||||
* Post-processing of the result of a feed controller, to remove any
|
||||
* notes or actors the user specified, as well as format the raw
|
||||
* list of notes into a usable format
|
||||
*
|
||||
* @template T of Note|Actor
|
||||
* @param T[] $result
|
||||
* @return T[]
|
||||
*/
|
||||
protected function postProcess(array $result): array
|
||||
{
|
||||
@ -58,6 +62,9 @@ abstract class FeedController extends OrderedCollection
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Note[] $notes
|
||||
*/
|
||||
private static function enforceScope(array &$notes, ?Actor $actor, ?Actor $in = null): void
|
||||
{
|
||||
$notes = F\select($notes, fn (Note $n) => $n->isVisibleTo($actor, $in));
|
||||
|
@ -41,6 +41,9 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
abstract class MetaCollectionController extends FeedController
|
||||
{
|
||||
protected const SLUG = 'collectionsEntry';
|
||||
@ -48,17 +51,36 @@ abstract class MetaCollectionController extends FeedController
|
||||
protected string $page_title = 'Collections';
|
||||
|
||||
abstract public function getCollectionUrl(int $owner_id, string $owner_nickname, int $collection_id): string;
|
||||
abstract public function getCollectionItems(int $owner_id, $collection_id): array;
|
||||
abstract public function getCollectionsByActorId(int $owner_id): array;
|
||||
abstract public function getCollectionBy(int $owner_id, int $collection_id);
|
||||
abstract public function createCollection(int $owner_id, string $name);
|
||||
|
||||
/**
|
||||
* @return T[]
|
||||
*/
|
||||
abstract public function getCollectionItems(int $owner_id, int $collection_id): array;
|
||||
|
||||
/**
|
||||
* @return T[]
|
||||
*/
|
||||
abstract public function getCollectionsByActorId(int $owner_id): array;
|
||||
|
||||
/**
|
||||
* @return T A collection
|
||||
*/
|
||||
abstract public function getCollectionBy(int $owner_id, int $collection_id): object;
|
||||
|
||||
abstract public function createCollection(int $owner_id, string $name): bool;
|
||||
|
||||
/**
|
||||
* @return T[]
|
||||
*/
|
||||
public function collectionsViewByActorNickname(Request $request, string $nickname): array
|
||||
{
|
||||
$user = DB::findOneBy(LocalUser::class, ['nickname' => $nickname]);
|
||||
return self::collectionsView($request, $user->getId(), $nickname);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return T[]
|
||||
*/
|
||||
public function collectionsViewByActorId(Request $request, int $id): array
|
||||
{
|
||||
return self::collectionsView($request, $id, null);
|
||||
@ -70,7 +92,7 @@ abstract class MetaCollectionController extends FeedController
|
||||
* @param int $id actor id
|
||||
* @param ?string $nickname actor nickname
|
||||
*
|
||||
* @return array twig template options
|
||||
* @return ControllerResultType twig template options
|
||||
*/
|
||||
public function collectionsView(Request $request, int $id, ?string $nickname): array
|
||||
{
|
||||
|
@ -45,6 +45,9 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* */
|
||||
trait MetaCollectionTrait
|
||||
{
|
||||
//protected const SLUG = 'collection';
|
||||
@ -53,40 +56,42 @@ trait MetaCollectionTrait
|
||||
/**
|
||||
* create a collection owned by Actor $owner.
|
||||
*
|
||||
* @param Actor $owner The collection's owner
|
||||
* @param array $vars Page vars sent by AppendRightPanelBlock event
|
||||
* @param string $name Collection's name
|
||||
* @param Actor $owner The collection's owner
|
||||
* @param array<string, mixed> $vars Page vars sent by AppendRightPanelBlock event
|
||||
* @param string $name Collection's name
|
||||
*/
|
||||
abstract protected function createCollection(Actor $owner, array $vars, string $name);
|
||||
abstract protected function createCollection(Actor $owner, array $vars, string $name): void;
|
||||
/**
|
||||
* remove item from collections.
|
||||
*
|
||||
* @param Actor $owner Current user
|
||||
* @param array $vars Page vars sent by AppendRightPanelBlock event
|
||||
* @param array $items Array of collections's ids to remove the current item from
|
||||
* @param array $collections List of ids of collections owned by $owner
|
||||
* @param Actor $owner Current user
|
||||
* @param array<string, mixed> $vars Page vars sent by AppendRightPanelBlock event
|
||||
* @param int[] $items Array of collections's ids to remove the current item from
|
||||
* @param int[] $collections List of ids of collections owned by $owner
|
||||
*/
|
||||
abstract protected function removeItem(Actor $owner, array $vars, array $items, array $collections);
|
||||
abstract protected function removeItem(Actor $owner, array $vars, array $items, array $collections): bool;
|
||||
/**
|
||||
* add item to collections.
|
||||
*
|
||||
* @param Actor $owner Current user
|
||||
* @param array $vars Page vars sent by AppendRightPanelBlock event
|
||||
* @param array $items Array of collections's ids to add the current item to
|
||||
* @param array $collections List of ids of collections owned by $owner
|
||||
* @param Actor $owner Current user
|
||||
* @param array<string, mixed> $vars Page vars sent by AppendRightPanelBlock event
|
||||
* @param int[] $items Array of collections's ids to add the current item to
|
||||
* @param int[] $collections List of ids of collections owned by $owner
|
||||
*/
|
||||
abstract protected function addItem(Actor $owner, array $vars, array $items, array $collections);
|
||||
abstract protected function addItem(Actor $owner, array $vars, array $items, array $collections): void;
|
||||
|
||||
/**
|
||||
* Check the route to determine whether the widget should be added
|
||||
* @param array<string, mixed> $vars
|
||||
*/
|
||||
abstract protected function shouldAddToRightPanel(Actor $user, $vars, Request $request): bool;
|
||||
abstract protected function shouldAddToRightPanel(Actor $user, array $vars, Request $request): bool;
|
||||
/**
|
||||
* Get array of collections's owned by $actor
|
||||
*
|
||||
* @param Actor $owner Collection's owner
|
||||
* @param ?array $vars Page vars sent by AppendRightPanelBlock event
|
||||
* @param bool $ids_only if true, the function must return only the primary key or each collections
|
||||
* @param Actor $owner Collection's owner
|
||||
* @param null|array<string, mixed> $vars Page vars sent by AppendRightPanelBlock event
|
||||
* @param bool $ids_only if true, the function must return only the primary key or each collections
|
||||
* @return T[]|int[]
|
||||
*/
|
||||
abstract protected function getCollectionsBy(Actor $owner, ?array $vars = null, bool $ids_only = false): array;
|
||||
|
||||
@ -94,8 +99,11 @@ trait MetaCollectionTrait
|
||||
* Append Collections widget to the right panel.
|
||||
* It's compose of two forms: one to select collections to add
|
||||
* the current item to, and another to create a new collection.
|
||||
*
|
||||
* @param array<string, mixed> $vars
|
||||
* @param string[] $res
|
||||
*/
|
||||
public function onAppendRightPanelBlock(Request $request, $vars, &$res): EventResult
|
||||
public function onAppendRightPanelBlock(Request $request, array $vars, array &$res): EventResult
|
||||
{
|
||||
$user = Common::actor();
|
||||
if (\is_null($user)) {
|
||||
@ -187,6 +195,9 @@ trait MetaCollectionTrait
|
||||
return Event::next;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[]
|
||||
*/
|
||||
public function onEndShowStyles(array &$styles, string $route): EventResult
|
||||
{
|
||||
$styles[] = 'components/Collection/assets/css/widget.css';
|
||||
|
@ -15,6 +15,12 @@ parameters:
|
||||
earlyTerminatingMethodCalls:
|
||||
App\Core\Log:
|
||||
- unexpected_exception
|
||||
typeAliases:
|
||||
ControllerResultType: 'array{_template: string} & array<string, mixed>'
|
||||
CacheKeysType: 'array<string, string>'
|
||||
SettingsTabsType: 'array<array{title: string, desc: string, id: string, controller: ControllerResultType}>'
|
||||
OrderByType: "'ASC' | 'DESC' | 'asc' | 'desc'"
|
||||
|
||||
ignoreErrors:
|
||||
-
|
||||
message: '/Access to an undefined property App\\Util\\Bitmap::\$\w+/'
|
||||
|
@ -52,7 +52,7 @@ class AttachmentCollections extends Plugin
|
||||
use MetaCollectionTrait;
|
||||
protected const SLUG = 'collection';
|
||||
protected const PLURAL_SLUG = 'collections';
|
||||
protected function createCollection(Actor $owner, array $vars, string $name)
|
||||
protected function createCollection(Actor $owner, array $vars, string $name): void
|
||||
{
|
||||
$col = AttachmentCollection::create([
|
||||
'name' => $name,
|
||||
@ -65,7 +65,7 @@ class AttachmentCollections extends Plugin
|
||||
'attachment_collection_id' => $col->getId(),
|
||||
]));
|
||||
}
|
||||
protected function removeItem(Actor $owner, array $vars, array $items, array $collections)
|
||||
protected function removeItem(Actor $owner, array $vars, array $items, array $collections): bool
|
||||
{
|
||||
return DB::dql(<<<'EOF'
|
||||
DELETE FROM \Plugin\AttachmentCollections\Entity\AttachmentCollectionEntry AS entry
|
||||
@ -83,7 +83,7 @@ class AttachmentCollections extends Plugin
|
||||
]);
|
||||
}
|
||||
|
||||
protected function addItem(Actor $owner, array $vars, array $items, array $collections)
|
||||
protected function addItem(Actor $owner, array $vars, array $items, array $collections): void
|
||||
{
|
||||
foreach ($items as $id) {
|
||||
// prevent user from putting something in a collection (s)he doesn't own:
|
||||
@ -102,6 +102,10 @@ class AttachmentCollections extends Plugin
|
||||
return $vars['path'] === 'note_attachment_show';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $vars
|
||||
* @return int[]
|
||||
*/
|
||||
protected function getCollectionsBy(Actor $owner, ?array $vars = null, bool $ids_only = false): array
|
||||
{
|
||||
if (\is_null($vars)) {
|
||||
|
@ -30,13 +30,14 @@ use Plugin\AttachmentCollections\Entity\AttachmentCollection;
|
||||
|
||||
class AttachmentCollections extends MetaCollectionController
|
||||
{
|
||||
public function createCollection(int $owner_id, string $name)
|
||||
public function createCollection(int $owner_id, string $name): bool
|
||||
{
|
||||
DB::persist(AttachmentCollection::create([
|
||||
'name' => $name,
|
||||
'actor_id' => $owner_id,
|
||||
]));
|
||||
}
|
||||
|
||||
public function getCollectionUrl(int $owner_id, ?string $owner_nickname, int $collection_id): string
|
||||
{
|
||||
if (\is_null($owner_nickname)) {
|
||||
|
@ -33,7 +33,11 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class AttachmentShowRelated extends Plugin
|
||||
{
|
||||
public function onAppendRightPanelBlock(Request $request, $vars, &$res): EventResult
|
||||
/**
|
||||
* @param array<string, mixed> $vars
|
||||
* @param string[] $res
|
||||
*/
|
||||
public function onAppendRightPanelBlock(Request $request, array $vars, array &$res): EventResult
|
||||
{
|
||||
if ($vars['path'] === 'note_attachment_show') {
|
||||
$related_notes = DB::dql('select n from attachment_to_note an '
|
||||
|
@ -36,7 +36,10 @@ class Bundles extends Plugin
|
||||
protected const SLUG = 'bundle';
|
||||
protected const PLURAL_SLUG = 'bundles';
|
||||
|
||||
protected function createCollection(Actor $owner, array $vars, string $name)
|
||||
/**
|
||||
* @param array<string, mixed> $vars
|
||||
*/
|
||||
protected function createCollection(Actor $owner, array $vars, string $name): void
|
||||
{
|
||||
$column = BundleCollection::create([
|
||||
'name' => $name,
|
||||
@ -49,7 +52,11 @@ class Bundles extends Plugin
|
||||
]));
|
||||
}
|
||||
|
||||
protected function removeItem(Actor $owner, array $vars, array $items, array $collections)
|
||||
/**
|
||||
* @param array<string, mixed> $vars
|
||||
* @param array<int> $items
|
||||
*/
|
||||
protected function removeItem(Actor $owner, array $vars, array $items, array $collections): bool
|
||||
{
|
||||
return DB::dql(<<<'EOF'
|
||||
DELETE FROM \Plugin\BlogCollections\Entity\BlogCollectionEntry AS entry
|
||||
@ -66,7 +73,12 @@ class Bundles extends Plugin
|
||||
]);
|
||||
}
|
||||
|
||||
protected function addItem(Actor $owner, array $vars, array $items, array $collections)
|
||||
/**
|
||||
* @param array<string, mixed> $vars
|
||||
* @param array<int> $items
|
||||
* @param array<int> $collections
|
||||
*/
|
||||
protected function addItem(Actor $owner, array $vars, array $items, array $collections): void
|
||||
{
|
||||
foreach ($items as $id) {
|
||||
// prevent user from putting something in a collection (s)he doesn't own:
|
||||
@ -79,12 +91,19 @@ class Bundles extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
protected function shouldAddToRightPanel(Actor $user, $vars, Request $request): bool
|
||||
/**
|
||||
* @param array<string, mixed> $vars
|
||||
*/
|
||||
protected function shouldAddToRightPanel(Actor $user, array $vars, Request $request): bool
|
||||
{
|
||||
// TODO: Implement shouldAddToRightPanel() method.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $vars
|
||||
* @retrun int[]
|
||||
*/
|
||||
protected function getCollectionsBy(Actor $owner, ?array $vars = null, bool $ids_only = false): array
|
||||
{
|
||||
if (\is_null($vars)) {
|
||||
|
@ -68,16 +68,18 @@ class BundleCollections extends MetaCollectionController
|
||||
return DB::findBy(BundleCollection::class, ['actor_id' => $owner_id], order_by: ['id' => 'desc']);
|
||||
}
|
||||
|
||||
public function getCollectionBy(int $owner_id, int $collection_id)
|
||||
public function getCollectionBy(int $owner_id, int $collection_id): BundleCollection
|
||||
{
|
||||
return DB::findOneBy(BundleCollection::class, ['id' => $collection_id]);
|
||||
}
|
||||
|
||||
public function createCollection(int $owner_id, string $name)
|
||||
public function createCollection(int $owner_id, string $name): bool
|
||||
{
|
||||
DB::persist(BundleCollection::create([
|
||||
'name' => $name,
|
||||
'actor_id' => $owner_id,
|
||||
]));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,9 @@ class Cover extends Plugin
|
||||
return Event::next;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SettingsTabsType $tabs
|
||||
*/
|
||||
public function onPopulateSettingsTabs(Request $request, string $section, &$tabs): EventResult
|
||||
{
|
||||
if ($section === 'profile') {
|
||||
|
@ -62,6 +62,7 @@ class Oomox extends Plugin
|
||||
* Populates an additional profile user panel section
|
||||
* Used in 'person/settings.html.twig'
|
||||
*
|
||||
* @param SettingsTabsType $tabs
|
||||
* @throws \App\Util\Exception\NoLoggedInUser
|
||||
* @throws RedirectException
|
||||
* @throws ServerException
|
||||
|
@ -69,6 +69,9 @@ class Pinboard extends Plugin
|
||||
return Event::next;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SettingsTabsType $tabs
|
||||
*/
|
||||
public function onPopulateSettingsTabs(Request $request, string $section, array &$tabs): EventResult
|
||||
{
|
||||
if ($section === 'api') {
|
||||
|
@ -57,6 +57,7 @@ class ProfileColor extends Plugin
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SettingsTabsType $tabs
|
||||
* @throws RedirectException
|
||||
* @throws ServerException
|
||||
*/
|
||||
|
@ -104,6 +104,9 @@ class TagBasedFiltering extends Plugin
|
||||
return Event::next;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SettingsTabsType $tabs
|
||||
*/
|
||||
public function onPopulateSettingsTabs(Request $request, string $section, array &$tabs): EventResult
|
||||
{
|
||||
if ($section === 'muting') {
|
||||
|
@ -50,6 +50,9 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
*/
|
||||
class UnboundGroup extends Plugin
|
||||
{
|
||||
/**
|
||||
* @param SettingsTabsType $tabs
|
||||
*/
|
||||
public function onPopulateSettingsTabs(Request $request, string $section, array &$tabs): EventResult
|
||||
{
|
||||
if ($section === 'profile' && $request->get('_route') === 'group_actor_settings') {
|
||||
|
@ -54,6 +54,9 @@ class WebHooks extends Plugin
|
||||
return EventResult::next;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SettingsTabsType $tabs
|
||||
*/
|
||||
public function onPopulateSettingsTabs(Request $request, string $section, array &$tabs): EventResult
|
||||
{
|
||||
if ($section === 'api') {
|
||||
|
@ -53,7 +53,11 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class WebMonetization extends Plugin
|
||||
{
|
||||
public function onAppendRightPanelBlock(Request $request, $vars, &$res): EventResult
|
||||
/**
|
||||
* @param array<string, mixed> $vars
|
||||
* @param string[] $res
|
||||
*/
|
||||
public function onAppendRightPanelBlock(Request $request, array $vars, array &$res): EventResult
|
||||
{
|
||||
$user = Common::actor();
|
||||
if (\is_null($user)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user