getServiceManager()->get(FileSystemService::SERVICE_ID); $fsService->createFileSystem('mediaManager'); $this->getServiceManager()->register(FileSystemService::SERVICE_ID, $fsService); $this->getServiceManager()->register( FileManagement::SERVICE_ID, new FlySystemManagement( [ FlySystemManagement::OPTION_FS => 'mediaManager' ] ) ); $this->getServiceManager() ->register(MediaRelationRepositoryInterface::SERVICE_ID, new RdfMediaRelationRepository()); /** @var EventManager $eventManager */ $eventManager = $this->getServiceManager()->get(EventManager::SERVICE_ID); $eventManager->attach(ItemUpdatedEvent::class, [MediaRelationListener::class, 'whenItemIsUpdated']); $eventManager->attach(ItemRemovedEvent::class, [MediaRelationListener::class, 'whenItemIsRemoved']); $eventManager->attach(MediaRemovedEvent::class, [MediaRelationListener::class, 'whenMediaIsRemoved']); $eventManager->attach(MediaSavedEvent::class, [MediaRelationListener::class, 'whenMediaIsSaved']); $this->getServiceManager()->register(EventManager::SERVICE_ID, $eventManager); /** @var MediaService $mediaService */ $mediaService = $this->getServiceManager()->get(MediaService::SERVICE_ID); $mediaService->addMediaSource(new MediaSource()); if ($fsService->hasDirectory('memory')) { $dirs = $fsService->getOption(FileSystemService::OPTION_DIRECTORIES); $dirs[CommandFactory::DEFAULT_DIRECTORY] = 'memory'; $fsService->setOption(FileSystemService::OPTION_DIRECTORIES, $dirs); } else { $fileSystem = $fsService->createFileSystem(CommandFactory::DEFAULT_DIRECTORY); } $this->getServiceManager()->register(FileSystemService::SERVICE_ID, $fsService); /** @var ResourceRelationServiceInterface $resourceRelationService */ $resourceRelationService = $this->getServiceManager()->get(ResourceRelationServiceProxy::SERVICE_ID); $resourceRelationService->addService('media', MediaRelationService::class); $this->getServiceManager()->register(ResourceRelationServiceProxy::SERVICE_ID, $resourceRelationService); return common_report_Report::createSuccess('MediaManager successfully installed'); } }