getServiceManager()->get(EventManager::SERVICE_ID); $eventManager->attach( AfterAssessmentTestSessionClosedEvent::class, [QtiTestListenerService::class, 'archiveState'] ); $this->getServiceManager()->register(EventManager::SERVICE_ID, $eventManager); // add config $extension = $this->getExtension(); /** @var QtiTestListenerService $config */ $config = $extension->getConfig('QtiTestListenerService'); $config->setOption(QtiTestListenerService::OPTION_ARCHIVE_ENABLED, true); $extension->setConfig('QtiTestListenerService', $config); } public function down(Schema $schema): void { /** @var EventManager $eventManager */ $eventManager = $this->getServiceManager()->get(EventManager::SERVICE_ID); $eventManager->detach( AfterAssessmentTestSessionClosedEvent::class, [QtiTestListenerService::class, 'archiveState'] ); $this->getServiceManager()->register(EventManager::SERVICE_ID, $eventManager); // remove config $extension = $this->getExtension(); /** @var QtiTestListenerService $config */ $config = $extension->getConfig('QtiTestListenerService'); $options = $config->getOptions(); if (array_key_exists(QtiTestListenerService::OPTION_ARCHIVE_ENABLED, $options)) { unset($options[QtiTestListenerService::OPTION_ARCHIVE_ENABLED]); $config->setOptions($options); } $extension->setConfig('QtiTestListenerService', $config); } /** * @throws ExtensionException * * @return Extension */ private function getExtension(): Extension { /** @var ExtensionsManager $extensionManager */ $extensionManager = $this->getServiceLocator()->get(ExtensionsManager::SERVICE_ID); return $extensionManager->getExtensionById('taoQtiTest'); } }