mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 08:44:07 -04:00
Merge pull request #29436 from nextcloud/fix/profile-link-action-registration
This commit is contained in:
commit
bb39a21079
1 changed files with 20 additions and 11 deletions
|
|
@ -74,6 +74,9 @@ class ProfileManager {
|
|||
/** @var ILinkAction[] */
|
||||
private $actions = [];
|
||||
|
||||
/** @var null|ILinkAction[] */
|
||||
private $sortedActions = null;
|
||||
|
||||
/**
|
||||
* Array of account property actions
|
||||
*/
|
||||
|
|
@ -157,21 +160,25 @@ class ProfileManager {
|
|||
* @return ILinkAction[]
|
||||
*/
|
||||
private function getActions(IUser $targetUser, ?IUser $visitingUser): array {
|
||||
$context = $this->coordinator->getRegistrationContext();
|
||||
if ($context === null) {
|
||||
return [];
|
||||
// If actions are already registered and sorted, return them
|
||||
if ($this->sortedActions !== null) {
|
||||
return $this->sortedActions;
|
||||
}
|
||||
|
||||
foreach (self::ACCOUNT_PROPERTY_ACTIONS as $actionClass) {
|
||||
/** @var ILinkAction $provider */
|
||||
$provider = $this->container->get($actionClass);
|
||||
$this->registerAction($targetUser, $visitingUser, $provider);
|
||||
/** @var ILinkAction $action */
|
||||
$action = $this->container->get($actionClass);
|
||||
$this->registerAction($targetUser, $visitingUser, $action);
|
||||
}
|
||||
|
||||
foreach ($context->getProfileLinkActions() as $registration) {
|
||||
/** @var ILinkAction $provider */
|
||||
$provider = $this->container->get($registration->getService());
|
||||
$this->registerAction($targetUser, $visitingUser, $provider);
|
||||
$context = $this->coordinator->getRegistrationContext();
|
||||
|
||||
if ($context !== null) {
|
||||
foreach ($context->getProfileLinkActions() as $registration) {
|
||||
/** @var ILinkAction $action */
|
||||
$action = $this->container->get($registration->getService());
|
||||
$this->registerAction($targetUser, $visitingUser, $action);
|
||||
}
|
||||
}
|
||||
|
||||
$actionsClone = $this->actions;
|
||||
|
|
@ -179,7 +186,9 @@ class ProfileManager {
|
|||
usort($actionsClone, function (ILinkAction $a, ILinkAction $b) {
|
||||
return $a->getPriority() === $b->getPriority() ? 0 : ($a->getPriority() < $b->getPriority() ? -1 : 1);
|
||||
});
|
||||
return $actionsClone;
|
||||
|
||||
$this->sortedActions = $actionsClone;
|
||||
return $this->sortedActions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue