Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions apps/admin_audit/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
*/
namespace OCA\AdminAudit\AppInfo;

use Closure;
use OC\Files\Filesystem;
use OC\Files\Node\File;
use OC\Group\Manager as GroupManager;
Expand Down Expand Up @@ -82,7 +81,7 @@ public function __construct() {
}

public function register(IRegistrationContext $context): void {
$context->registerService(IAuditLogger::class, function (ContainerInterface $c) {
$context->registerService(IAuditLogger::class, static function (ContainerInterface $c) {
return new AuditLogger($c->get(ILogFactory::class), $c->get(Iconfig::class));
});

Expand Down Expand Up @@ -170,23 +169,23 @@ private function authHooks(IAuditLogger $logger): void {

private function appHooks(IAuditLogger $logger,
EventDispatcherInterface $eventDispatcher): void {
$eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE, function (ManagerEvent $event) use ($logger) {
$eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE, static function (ManagerEvent $event) use ($logger) {
$appActions = new AppManagement($logger);
$appActions->enableApp($event->getAppID());
});
$eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, function (ManagerEvent $event) use ($logger) {
$eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, static function (ManagerEvent $event) use ($logger) {
$appActions = new AppManagement($logger);
$appActions->enableAppForGroups($event->getAppID(), $event->getGroups());
});
$eventDispatcher->addListener(ManagerEvent::EVENT_APP_DISABLE, function (ManagerEvent $event) use ($logger) {
$eventDispatcher->addListener(ManagerEvent::EVENT_APP_DISABLE, static function (ManagerEvent $event) use ($logger) {
$appActions = new AppManagement($logger);
$appActions->disableApp($event->getAppID());
});
}

private function consoleHooks(IAuditLogger $logger,
EventDispatcherInterface $eventDispatcher): void {
$eventDispatcher->addListener(ConsoleEvent::EVENT_RUN, function (ConsoleEvent $event) use ($logger) {
$eventDispatcher->addListener(ConsoleEvent::EVENT_RUN, static function (ConsoleEvent $event) use ($logger) {
$appActions = new Console($logger);
$appActions->runCommand($event->getArguments());
});
Expand All @@ -197,7 +196,7 @@ private function fileHooks(IAuditLogger $logger,
$fileActions = new Files($logger);
$eventDispatcher->addListener(
IPreview::EVENT,
function (GenericEvent $event) use ($fileActions) {
static function (GenericEvent $event) use ($fileActions) {
/** @var File $file */
$file = $event->getSubject();
$fileActions->preview([
Expand Down Expand Up @@ -268,11 +267,11 @@ private function trashbinHooks(IAuditLogger $logger): void {

private function securityHooks(IAuditLogger $logger,
EventDispatcherInterface $eventDispatcher): void {
$eventDispatcher->addListener(IProvider::EVENT_SUCCESS, function (GenericEvent $event) use ($logger) {
$eventDispatcher->addListener(IProvider::EVENT_SUCCESS, static function (GenericEvent $event) use ($logger) {
$security = new Security($logger);
$security->twofactorSuccess($event->getSubject(), $event->getArguments());
});
$eventDispatcher->addListener(IProvider::EVENT_FAILED, function (GenericEvent $event) use ($logger) {
$eventDispatcher->addListener(IProvider::EVENT_FAILED, static function (GenericEvent $event) use ($logger) {
$security = new Security($logger);
$security->twofactorFailed($event->getSubject(), $event->getArguments());
});
Expand Down
13 changes: 5 additions & 8 deletions apps/dav/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
use OCA\DAV\CalDAV\Reminder\Notifier;

use OCA\DAV\Capabilities;
use OCA\DAV\CardDAV\CardDavBackend;
use OCA\DAV\CardDAV\ContactsManager;
use OCA\DAV\CardDAV\PhotoCache;
use OCA\DAV\CardDAV\SyncService;
Expand Down Expand Up @@ -118,10 +117,9 @@ public function __construct() {

public function register(IRegistrationContext $context): void {
$context->registerServiceAlias('CardDAVSyncService', SyncService::class);
$context->registerService(PhotoCache::class, function (ContainerInterface $c) {
$context->registerService(PhotoCache::class, static function (ContainerInterface $c) {
/** @var IServerContainer $server */
$server = $c->get(IServerContainer::class);

return new PhotoCache(
$server->getAppDataDir('dav-photocache'),
$c->get(LoggerInterface::class)
Expand Down Expand Up @@ -217,21 +215,21 @@ public function registerHooks(HookManager $hm,
$hm->setup();

// first time login event setup
$dispatcher->addListener(IUser::class . '::firstLogin', function ($event) use ($hm) {
$dispatcher->addListener(IUser::class . '::firstLogin', static function ($event) use ($hm) {
if ($event instanceof GenericEvent) {
$hm->firstLogin($event->getSubject());
}
});

$dispatcher->addListener('OC\AccountManager::userUpdated', function (GenericEvent $event) use ($container) {
$dispatcher->addListener('OC\AccountManager::userUpdated', static function (GenericEvent $event) use ($container) {
$user = $event->getSubject();
/** @var SyncService $syncService */
$syncService = $container->query(SyncService::class);
$syncService->updateUser($user);
});


$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateShares', function (GenericEvent $event) use ($container) {
$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateShares', static function (GenericEvent $event) use ($container) {
/** @var Backend $backend */
$backend = $container->query(Backend::class);
$backend->onCalendarUpdateShares(
Expand All @@ -240,11 +238,10 @@ public function registerHooks(HookManager $hm,
$event->getArgument('add'),
$event->getArgument('remove')
);

// Here we should recalculate if reminders should be sent to new or old sharees
});

$eventHandler = function () use ($container, $serverContainer): void {
$eventHandler = static function () use ($container, $serverContainer) : void {
try {
/** @var UpdateCalendarResourcesRoomsBackgroundJob $job */
$job = $container->query(UpdateCalendarResourcesRoomsBackgroundJob::class);
Expand Down
20 changes: 10 additions & 10 deletions apps/encryption/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,17 @@ public function registerEncryptionModule(IManager $encryptionManager) {
$encryptionManager->registerEncryptionModule(
Encryption::ID,
Encryption::DISPLAY_NAME,
function () use ($container) {
static function () use ($container) {
return new Encryption(
$container->query(Crypt::class),
$container->query(KeyManager::class),
$container->query(Util::class),
$container->query(Session::class),
$container->query(EncryptAll::class),
$container->query(DecryptAll::class),
$container->getServer()->getLogger(),
$container->getServer()->getL10N($container->getAppName())
);
$container->query(Crypt::class),
$container->query(KeyManager::class),
$container->query(Util::class),
$container->query(Session::class),
$container->query(EncryptAll::class),
$container->query(DecryptAll::class),
$container->getServer()->getLogger(),
$container->getServer()->getL10N($container->getAppName())
);
});
}
}
2 changes: 1 addition & 1 deletion apps/federatedfilesharing/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private function registerCloudFederationProvider(ICloudFederationProviderManager
IAppContainer $appContainer): void {
$manager->addCloudFederationProvider('file',
'Federated Files Sharing',
function () use ($appContainer): CloudFederationProviderFiles {
static function () use ($appContainer) : CloudFederationProviderFiles {
return $appContainer->get(CloudFederationProviderFiles::class);
});
}
Expand Down
12 changes: 5 additions & 7 deletions apps/files/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ public function register(IRegistrationContext $context): void {
/**
* Controllers
*/
$context->registerService('APIController', function (ContainerInterface $c) {
$context->registerService('APIController', static function (ContainerInterface $c) {
/** @var IServerContainer $server */
$server = $c->get(IServerContainer::class);

return new ApiController(
$c->get('AppName'),
$c->get(IRequest::class),
Expand All @@ -97,10 +96,9 @@ public function register(IRegistrationContext $context): void {
/**
* Services
*/
$context->registerService(TagService::class, function (ContainerInterface $c) {
$context->registerService(TagService::class, static function (ContainerInterface $c) {
/** @var IServerContainer $server */
$server = $c->get(IServerContainer::class);

return new TagService(
$c->get(IUserSession::class),
$c->get(IActivityManager::class),
Expand Down Expand Up @@ -149,7 +147,7 @@ private function registerTemplates(): void {
}

private function registerNavigation(IL10N $l10n): void {
\OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
\OCA\Files\App::getNavigationManager()->add(static function () use ($l10n) {
return [
'id' => 'files',
'appname' => 'files',
Expand All @@ -158,7 +156,7 @@ private function registerNavigation(IL10N $l10n): void {
'name' => $l10n->t('All files')
];
});
\OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
\OCA\Files\App::getNavigationManager()->add(static function () use ($l10n) {
return [
'id' => 'recent',
'appname' => 'files',
Expand All @@ -167,7 +165,7 @@ private function registerNavigation(IL10N $l10n): void {
'name' => $l10n->t('Recent')
];
});
\OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
\OCA\Files\App::getNavigationManager()->add(static function () use ($l10n) {
return [
'id' => 'favorites',
'appname' => 'files',
Expand Down
6 changes: 3 additions & 3 deletions apps/files_external/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ public function register(IRegistrationContext $context): void {
}

public function boot(IBootContext $context): void {
$context->injectFn(function (IMountProviderCollection $mountProviderCollection, ConfigAdapter $configAdapter) {
$context->injectFn(static function (IMountProviderCollection $mountProviderCollection, ConfigAdapter $configAdapter) {
$mountProviderCollection->registerProvider($configAdapter);
});
\OCA\Files\App::getNavigationManager()->add(function () {
\OCA\Files\App::getNavigationManager()->add(static function () {
$l = \OC::$server->getL10N('files_external');
return [
'id' => 'extstoragemounts',
Expand All @@ -110,7 +110,7 @@ public function boot(IBootContext $context): void {
$context->injectFn(function (BackendService $backendService, UserPlaceholderHandler $userConfigHandler) {
$backendService->registerBackendProvider($this);
$backendService->registerAuthMechanismProvider($this);
$backendService->registerConfigHandler('user', function () use ($userConfigHandler) {
$backendService->registerConfigHandler('user', static function () use ($userConfigHandler) {
return $userConfigHandler;
});
});
Expand Down
24 changes: 6 additions & 18 deletions apps/files_sharing/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
use OCA\Files_Sharing\Notification\Notifier;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Files\Event\LoadSidebar;
use OCP\Files\Event\BeforeDirectGetEvent;
use OCA\Files_Sharing\ShareBackend\File;
use OCA\Files_Sharing\ShareBackend\Folder;
use OCA\Files_Sharing\ViewOnly;
Expand All @@ -61,7 +60,6 @@
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent as ResourcesLoadAdditionalScriptsEvent;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\EventDispatcher\GenericEvent;
use OCP\Federation\ICloudIdManager;
use OCP\Files\Config\IMountProviderCollection;
use OCP\Files\Events\BeforeDirectFileDownloadEvent;
Expand Down Expand Up @@ -89,10 +87,10 @@ public function __construct(array $urlParams = []) {
}

public function register(IRegistrationContext $context): void {
$context->registerService(ExternalMountProvider::class, function (ContainerInterface $c) {
$context->registerService(ExternalMountProvider::class, static function (ContainerInterface $c) {
return new ExternalMountProvider(
$c->get(IDBConnection::class),
function () use ($c) {
static function () use ($c) {
return $c->get(Manager::class);
},
$c->get(ICloudIdManager::class)
Expand Down Expand Up @@ -144,7 +142,7 @@ public function registerEventsScripts(IEventDispatcher $dispatcher, EventDispatc
$dispatcher->addServiceListener(ShareCreatedEvent::class, ShareInteractionListener::class);
$dispatcher->addServiceListener(ShareCreatedEvent::class, UserShareAcceptanceListener::class);
$dispatcher->addServiceListener(UserAddedEvent::class, UserAddedToGroupListener::class);
$dispatcher->addListener(ResourcesLoadAdditionalScriptsEvent::class, function () {
$dispatcher->addListener(ResourcesLoadAdditionalScriptsEvent::class, static function () {
\OCP\Util::addScript('files_sharing', 'collaboration');
});

Expand All @@ -166,10 +164,9 @@ public function registerDownloadEvents(
IUserSession $userSession,
IRootFolder $rootFolder
): void {

$dispatcher->addListener(
BeforeDirectFileDownloadEvent::class,
function (BeforeDirectFileDownloadEvent $event) use ($userSession, $rootFolder): void {
static function (BeforeDirectFileDownloadEvent $event) use ($userSession, $rootFolder) : void {
$pathsToCheck = [$event->getPath()];
// Check only for user/group shares. Don't restrict e.g. share links
$user = $userSession->getUser();
Expand All @@ -187,15 +184,13 @@ function (BeforeDirectFileDownloadEvent $event) use ($userSession, $rootFolder):

$dispatcher->addListener(
BeforeZipCreatedEvent::class,
function (BeforeZipCreatedEvent $event) use ($userSession, $rootFolder): void {
static function (BeforeZipCreatedEvent $event) use ($userSession, $rootFolder) : void {
$dir = $event->getDirectory();
$files = $event->getFiles();

$pathsToCheck = [];
foreach ($files as $file) {
$pathsToCheck[] = $dir . '/' . $file;
}

// Check only for user/group shares. Don't restrict e.g. share links
$user = $userSession->getUser();
if ($user) {
Expand All @@ -222,13 +217,11 @@ public function setupSharingMenus(IManager $shareManager, IFactory $l10nFactory,

$navigationManager = \OCA\Files\App::getNavigationManager();
// show_Quick_Access stored as string
$navigationManager->add(function () use ($shareManager, $l10nFactory, $userSession) {
$navigationManager->add(static function () use ($shareManager, $l10nFactory, $userSession) {
$l = $l10nFactory->get('files_sharing');
$user = $userSession->getUser();
$userId = $user ? $user->getUID() : null;

$sharingSublistArray = [];

if ($shareManager->sharingDisabledForUser($userId) === false) {
$sharingSublistArray[] = [
'id' => 'sharingout',
Expand All @@ -238,15 +231,13 @@ public function setupSharingMenus(IManager $shareManager, IFactory $l10nFactory,
'name' => $l->t('Shared with others'),
];
}

$sharingSublistArray[] = [
'id' => 'sharingin',
'appname' => 'files_sharing',
'script' => 'list.php',
'order' => 15,
'name' => $l->t('Shared with you'),
];

if ($shareManager->sharingDisabledForUser($userId) === false) {
// Check if sharing by link is enabled
if ($shareManager->shareApiAllowLinks()) {
Expand All @@ -259,23 +250,20 @@ public function setupSharingMenus(IManager $shareManager, IFactory $l10nFactory,
];
}
}

$sharingSublistArray[] = [
'id' => 'deletedshares',
'appname' => 'files_sharing',
'script' => 'list.php',
'order' => 19,
'name' => $l->t('Deleted shares'),
];

$sharingSublistArray[] = [
'id' => 'pendingshares',
'appname' => 'files_sharing',
'script' => 'list.php',
'order' => 19,
'name' => $l->t('Pending shares'),
];

return [
'id' => 'shareoverview',
'appname' => 'files_sharing',
Expand Down
2 changes: 1 addition & 1 deletion apps/files_trashbin/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function boot(IBootContext $context): void {
// pre and post-rename, disable trash logic for the copy+unlink case
\OCP\Util::connectHook('OC_Filesystem', 'delete', 'OCA\Files_Trashbin\Trashbin', 'ensureFileScannedHook');

\OCA\Files\App::getNavigationManager()->add(function () {
\OCA\Files\App::getNavigationManager()->add(static function () {
$l = \OC::$server->getL10N(self::APP_ID);
return [
'id' => 'trashbin',
Expand Down
4 changes: 2 additions & 2 deletions apps/files_versions/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function register(IRegistrationContext $context): void {
/**
* Register $principalBackend for the DAV collection
*/
$context->registerService('principalBackend', function (ContainerInterface $c) {
$context->registerService('principalBackend', static function (ContainerInterface $c) {
/** @var IServerContainer $server */
$server = $c->get(IServerContainer::class);
return new Principal(
Expand All @@ -87,7 +87,7 @@ public function register(IRegistrationContext $context): void {
);
});

$context->registerService(IVersionManager::class, function () {
$context->registerService(IVersionManager::class, static function () {
return new VersionManager();
});

Expand Down
3 changes: 1 addition & 2 deletions apps/lookup_server_connector/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ public function boot(IBootContext $context): void {
*/
private function registerEventListeners(EventDispatcher $dispatcher,
IAppContainer $appContainer): void {
$dispatcher->addListener('OC\AccountManager::userUpdated', function (GenericEvent $event) use ($appContainer) {
$dispatcher->addListener('OC\AccountManager::userUpdated', static function (GenericEvent $event) use ($appContainer) {
/** @var IUser $user */
$user = $event->getSubject();

/** @var UpdateLookupServer $updateLookupServer */
$updateLookupServer = $appContainer->get(UpdateLookupServer::class);
$updateLookupServer->userUpdated($user);
Expand Down
Loading