本文整理汇总了PHP中oat\oatbox\service\ServiceManager类的典型用法代码示例。如果您正苦于以下问题:PHP ServiceManager类的具体用法?PHP ServiceManager怎么用?PHP ServiceManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ServiceManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __invoke
/**
* @param $params
*/
public function __invoke($params)
{
$serviceManager = ServiceManager::getServiceManager();
$assignmentService = new ProctoringAssignmentService();
$assignmentService->setServiceManager($serviceManager);
$serviceManager->register(ProctoringAssignmentService::CONFIG_ID, $assignmentService);
}
示例2: __construct
/**
* PciAssetHandler constructor.
* Set PortableElementItemParser
*/
public function __construct(Item $item, $sourceDir)
{
$this->portableItemParser = new PortableElementItemParser();
$this->portableItemParser->setServiceLocator(ServiceManager::getServiceManager());
$this->portableItemParser->setSource(rtrim($sourceDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR);
$this->portableItemParser->setQtiModel($item);
}
示例3: getServiceStorage
public static function getServiceStorage($serviceCallId)
{
$serviceService = ServiceManager::getServiceManager()->get('tao/stateStorage');
$state = $serviceService->get(common_session_SessionManager::getSession()->getUserUri(), $serviceCallId);
$submitUrl = _url('submitState', 'ServiceModule', 'tao', array('serviceCallId' => $serviceCallId));
return 'new StateStorage(' . tao_helpers_Javascript::buildObject($state) . ', ' . tao_helpers_Javascript::buildObject($submitUrl) . ')';
}
示例4: getTextConverterService
/**
* Get the TextConverterService
*
* @return ProctoringTextConverter
*/
protected function getTextConverterService()
{
if (!$this->textConverterService) {
$this->textConverterService = ServiceManager::getServiceManager()->get(ProctoringTextConverter::SERVICE_ID);
}
return $this->textConverterService;
}
示例5: __invoke
/**
* @param $params
*/
public function __invoke($params)
{
$serviceManager = ServiceManager::getServiceManager();
$deliveryContainerService = new DeliveryContainerService();
$deliveryContainerService->setServiceManager($serviceManager);
$serviceManager->register(DeliveryContainerService::CONFIG_ID, $deliveryContainerService);
}
示例6: getIrregularities
private function getIrregularities($delivery, $from = '', $to = '')
{
$export = array(array(__('date'), __('author'), __('test taker'), __('category'), __('subcategory'), __('comment')));
$deliveryLog = ServiceManager::getServiceManager()->get(DeliveryLog::SERVICE_ID);
$service = ResultsService::singleton();
$implementation = $service->getReadableImplementation($delivery);
$service->setImplementation($implementation);
$results = $service->getImplementation()->getResultByDelivery(array($delivery->getUri()));
foreach ($results as $res) {
$deliveryExecution = \taoDelivery_models_classes_execution_ServiceProxy::singleton()->getDeliveryExecution($res['deliveryResultIdentifier']);
$logs = $deliveryLog->get($deliveryExecution->getIdentifier(), 'TEST_IRREGULARITY');
foreach ($logs as $data) {
$exportable = array();
if ((empty($from) || $data['created_at'] > $from) && (empty($to) || $data['created_at'] < $to)) {
$testTaker = new \core_kernel_classes_Resource($res['testTakerIdentifier']);
$author = new \core_kernel_classes_Resource($data['created_by']);
$exportable[] = \tao_helpers_Date::displayeDate($data['created_at']);
$exportable[] = $author->getLabel();
$exportable[] = $testTaker->getLabel();
$exportable[] = $data['data']['reason']['reasons']['category'];
$exportable[] = isset($data['data']['reason']['reasons']['subCategory']) ? $data['data']['reason']['reasons']['subCategory'] : '';
$exportable[] = $data['data']['reason']['comment'];
$export[] = $exportable;
}
}
}
return $export;
}
示例7: __invoke
public function __invoke($params)
{
$service = new PortableElementService();
$service->setServiceLocator(ServiceManager::getServiceManager());
$sourceDirectory = $this->getSourceDirectory();
if (empty($sourceDirectory)) {
return $this->createFailure('the source directory is empty');
}
if (!is_readable($sourceDirectory)) {
return $this->createFailure('the source directory does not exists or is not readable ' . $sourceDirectory);
}
try {
$model = $service->getValidPortableElementFromDirectorySource($sourceDirectory);
if (!empty($params)) {
$minRequiredVersion = $params[0];
// if the minimal required version number string "x.y.z" is given in the parameter, the new target version should be equal or higher than it
if (version_compare($model->getVersion(), $minRequiredVersion) < 0) {
return $this->createFailure('the version in manifest "' . $model->getVersion() . '" cannot be lower than the given minimum required version "' . $minRequiredVersion . '"', $model);
}
}
$service->registerFromDirectorySource($sourceDirectory);
} catch (PortableElementVersionIncompatibilityException $e) {
return $this->createFailure('incompatible version: ' . $e->getMessage(), $model);
}
return Report::createSuccess('registered portable element "' . $model->getTypeIdentifier() . '" in version "' . $model->getVersion() . '""');
}
示例8: __invoke
public function __invoke($params)
{
$this->dryrun = in_array('dryrun', $params) || in_array('--dryrun', $params);
/** @var StorageInterface $storageService */
$storageService = ServiceManager::getServiceManager()->get(StorageInterface::SERVICE_ID);
$page = 1;
$rows = 500;
$this->report = new \common_report_Report(\common_report_Report::TYPE_INFO, 'Converting of dates for the event log');
while (true) {
$slice = $storageService->searchInstances(['page' => $page, 'rows' => $rows]);
if (!count($slice['data'])) {
break;
}
foreach ($slice['data'] as $row) {
if (empty($row['occurred']) || $row['occurred'] == '0000-00-00 00:00:00') {
$this->report->add(new \common_report_Report(\common_report_Report::TYPE_WARNING, 'Would not be converted date in id="' . $row['id'] . '" date is "' . $row['occurred'] . '"'));
continue;
}
if ($this->dryrun) {
$this->report->add(new \common_report_Report(\common_report_Report::TYPE_SUCCESS, 'Would be changed date "' . $row['occurred'] . '" to "' . $this->convertToUtcDate($row['occurred']) . '"'));
} else {
$this->setOccurred($storageService, $row['id'], $this->convertToUtcDate($row['occurred']));
}
}
if ($this->dryrun) {
$this->report->add(new \common_report_Report(\common_report_Report::TYPE_SUCCESS, 'In the same way would be changed "' . $slice['records'] . '" records'));
break;
}
$page++;
}
$this->report->add(new \common_report_Report(\common_report_Report::TYPE_SUCCESS, 'Done'));
return $this->report;
}
示例9: __invoke
/**
* @param $params
*/
public function __invoke($params)
{
$serviceManager = ServiceManager::getServiceManager();
$service = new CategoryService();
$service->setServiceManager($serviceManager);
$serviceManager->register(CategoryService::SERVICE_ID, $service);
}
示例10: setUp
public function setUp()
{
\common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery');
TaoPhpUnitTestRunner::initTest();
$this->service = ServiceManager::getServiceManager()->get(DeliveryMonitoringService::CONFIG_ID);
$this->persistence = \common_persistence_Manager::getPersistence('default');
}
示例11: __invoke
/**
* @param $params
*/
public function __invoke($params)
{
$serviceManager = ServiceManager::getServiceManager();
$testRunnerFeatureService = new TestRunnerFeatureService();
$testRunnerFeatureService->setServiceManager($serviceManager);
$serviceManager->register(TestRunnerFeatureService::SERVICE_ID, $testRunnerFeatureService);
}
示例12: install
/**
* install an extension
*
* @access public
* @author Jerome Bogaerts, <jerome@taotesting.com>
* @return void
*/
public function install()
{
common_Logger::i('Installing extension ' . $this->extension->getId(), 'INSTALL');
if ($this->extension->getId() == 'generis') {
throw new common_ext_ForbiddenActionException('Tried to install generis using the ExtensionInstaller', $this->extension->getId());
}
if (common_ext_ExtensionsManager::singleton()->isInstalled($this->extension->getId())) {
throw new common_ext_AlreadyInstalledException('Problem installing extension ' . $this->extension->getId() . ' : Already installed', $this->extension->getId());
}
// we purge the whole cache.
$cache = common_cache_FileCache::singleton();
$cache->purge();
// check reuired extensions, throws exception if failed
helpers_ExtensionHelper::checkRequiredExtensions($this->getExtension());
$this->installLoadDefaultConfig();
$this->installOntology();
$this->installRegisterExt();
common_Logger::d('Installing custom script for extension ' . $this->extension->getId());
$this->installCustomScript();
common_Logger::d('Done installing custom script for extension ' . $this->extension->getId());
if ($this->getLocalData() == true) {
common_Logger::d('Installing local data for extension ' . $this->extension->getId());
$this->installLocalData();
common_Logger::d('Done installing local data for extension ' . $this->extension->getId());
}
common_Logger::d('Extended install for extension ' . $this->extension->getId());
// Method to be overriden by subclasses
// to extend the installation mechanism.
$this->extendedInstall();
common_Logger::d('Done extended install for extension ' . $this->extension->getId());
$eventManager = ServiceManager::getServiceManager()->get(EventManager::CONFIG_ID);
$eventManager->trigger(new common_ext_event_ExtensionInstalled($this->extension));
}
示例13: inject
public function inject($target, array $values)
{
if (!$target instanceof core_kernel_classes_Resource) {
$msg = "The given target is not an instance of core_kernel_classes_Resource.";
throw new MetadataInjectionException($msg);
}
$injectionRules = $this->getInjectionRules();
foreach ($values as $metadataValues) {
foreach ($metadataValues as $metadataValue) {
$pathKey = implode('->', $metadataValue->getPath());
$lang = $metadataValue->getLanguage() ?: DEFAULT_LANG;
if (($rule = $this->getRuleByValue($metadataValue->getPath(), $metadataValue->getValue())) !== false) {
// Direct Mapping.
$target->setPropertyValueByLg(new core_kernel_classes_Property($rule[0]), $rule[2], $lang);
} elseif (($rule = $this->getRuleByPath($metadataValue->getPath())) !== false) {
// Direct Injection.
$target->setPropertyValueByLg(new core_kernel_classes_Property($rule[0]), $metadataValue->getValue(), $lang);
}
$eventManager = ServiceManager::getServiceManager()->get(EventManager::CONFIG_ID);
$metadata = $metadataValue->getPath();
$metadataUri = array_pop($metadata);
$eventManager->trigger(new MetadataModified($target, $metadataUri, $metadataValue->getValue()));
}
}
}
示例14: __invoke
/**
* @param $params
*/
public function __invoke($params)
{
$serviceManager = ServiceManager::getServiceManager();
$eventManager = $serviceManager->get(EventManager::CONFIG_ID);
$eventManager->attach('oat\\taoTests\\models\\event\\TestExecutionPausedEvent', ['oat\\taoProctoring\\model\\implementation\\DeliveryExecutionStateService', 'catchSessionPause']);
$serviceManager->register(EventManager::CONFIG_ID, $eventManager);
}
示例15: getPersistence
public function getPersistence()
{
if (is_null($this->persistence)) {
$this->persistence = ServiceManager::getServiceManager()->get(\common_persistence_Manager::SERVICE_KEY)->getPersistenceById($this->getOption('persistence'));
}
return $this->persistence;
}