本文整理汇总了PHP中core_kernel_classes_Class::getInstances方法的典型用法代码示例。如果您正苦于以下问题:PHP core_kernel_classes_Class::getInstances方法的具体用法?PHP core_kernel_classes_Class::getInstances怎么用?PHP core_kernel_classes_Class::getInstances使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_kernel_classes_Class
的用法示例。
在下文中一共展示了core_kernel_classes_Class::getInstances方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* render the main layout
*/
public function index()
{
$uri = tao_helpers_Uri::decode($this->getRequestParameter('uri'));
$links = array();
$class = new core_kernel_classes_Class(CLASS_LTI_CONSUMER);
foreach ($class->getInstances() as $consumer) {
$links[] = array('key' => $consumer->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_OAUTH_KEY)), 'secret' => $consumer->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_OAUTH_SECRET)), 'url' => $this->service->getLaunchUrl(array('delivery' => $uri)));
}
$this->setData('links', $links);
$this->setData('launchUrl', $this->service->getLaunchUrl(array('delivery' => $uri)));
$this->setData('consumers', $class->getInstances());
$this->setData('delivery', $uri);
$this->setView('linkManagement.tpl', 'taoLti');
}
示例2: migrateCompiledDeliveryToAssembly
/**
*
* @author Lionel Lecaque, lionel@taotesting.com
*/
private function migrateCompiledDeliveryToAssembly()
{
$compiledDeliveryClass = new core_kernel_classes_Class(self::OLD_COMPILED_DELIVERY);
$props = array(self::OLD_PROPERTY_COMPILEDDELIVERY_DELIVERY => PROPERTY_COMPILEDDELIVERY_DELIVERY, self::OLD_PROPERTY_COMPILEDDELIVERY_TIME => PROPERTY_COMPILEDDELIVERY_TIME, self::OLD_PROPERTY_COMPILEDDELIVERY_RUNTIME => PROPERTY_COMPILEDDELIVERY_RUNTIME, self::OLD_PROPERTY_COMPILEDDELIVERY_DIRECTORY => PROPERTY_COMPILEDDELIVERY_DIRECTORY);
foreach ($compiledDeliveryClass->getInstances(true) as $compiledDelivery) {
taoUpdate_scripts_update_UpdateDeliveryModel::switchType($compiledDelivery, TAO_DELIVERY_CLASS);
$values = $compiledDelivery->getPropertiesValues(array_keys($props));
foreach ($values as $prop => $val) {
//compiled time was not always set in 2.5 so I set a 0 will appear as 1970 in UI
if ($prop == self::OLD_PROPERTY_COMPILEDDELIVERY_TIME && empty($val)) {
if (isset($props[$prop])) {
$compiledDelivery->setPropertyValue(new core_kernel_classes_Property($props[$prop]), '0');
}
}
if (!empty($val) && $prop != self::OLD_PROPERTY_COMPILEDDELIVERY_DIRECTORY) {
if (isset($props[$prop])) {
$compiledDelivery->removePropertyValues(new core_kernel_classes_Property($prop));
$compiledDelivery->setPropertiesValues(array($props[$prop] => $val));
} else {
$this->info('could not found property ' . $prop);
}
//copy property value from templace to assembly
if ($prop == self::OLD_PROPERTY_COMPILEDDELIVERY_DELIVERY) {
if (isset($val[0]) && $val[0] instanceof core_kernel_classes_Resource) {
$this->copyPropertyValuesFromTemplateToAssembly($val[0], $compiledDelivery);
}
}
}
}
}
}
示例3: __invoke
/**
* @param $params
* @return Report
*/
public function __invoke($params)
{
$deliveryMonitoringService = $this->getServiceLocator()->get(DeliveryMonitoringService::CONFIG_ID);
$deliveryClass = new \core_kernel_classes_Class('http://www.tao.lu/Ontologies/TAODelivery.rdf#AssembledDelivery');
$deliveries = $deliveryClass->getInstances(true);
$deliveryExecutionService = \taoDelivery_models_classes_execution_ServiceProxy::singleton();
$this->report = new Report(Report::TYPE_INFO, 'Updating of delivery monitoring cache...');
foreach ($deliveries as $delivery) {
if ($delivery->exists()) {
$deliveryExecutions = $deliveryExecutionService->getExecutionsByDelivery($delivery);
foreach ($deliveryExecutions as $deliveryExecution) {
$data = $deliveryMonitoringService->getData($deliveryExecution, true);
if ($deliveryMonitoringService->save($data)) {
$this->report->add(new Report(Report::TYPE_SUCCESS, "Delivery execution {$deliveryExecution->getUri()} successfully updated."));
} else {
$errors = $data->getErrors();
$errorsStr = " " . PHP_EOL;
array_walk($errors, function ($val, $key) use(&$errorsStr) {
$errorsStr .= " {$key} - {$val}" . PHP_EOL;
});
$this->report->add(new Report(Report::TYPE_ERROR, "Delivery execution {$deliveryExecution->getUri()} was not updated. {$errorsStr}"));
}
}
}
}
return $this->report;
}
示例4: initElements
public function initElements()
{
$class = $this->data['class'];
if (!$class instanceof \core_kernel_classes_Class) {
throw new \common_Exception('missing class in simple delivery creation form');
}
$classUriElt = \tao_helpers_form_FormFactory::getElement('classUri', 'Hidden');
$classUriElt->setValue($class->getUri());
$this->form->addElement($classUriElt);
//create the element to select the import format
$formatElt = \tao_helpers_form_FormFactory::getElement('test', 'Combobox');
$formatElt->setDescription(__('Select the test you want to publish to the test-takers'));
$testClass = new \core_kernel_classes_Class(TAO_TEST_CLASS);
$options = array();
$testService = \taoTests_models_classes_TestsService::singleton();
foreach ($testClass->getInstances(true) as $test) {
try {
$testItems = $testService->getTestItems($test);
//Filter tests which has no items
if (!empty($testItems)) {
$options[$test->getUri()] = $test->getLabel();
}
} catch (\Exception $e) {
\common_Logger::w('Unable to load items for test ' . $test->getUri());
}
}
if (empty($options)) {
throw new NoTestsException();
}
$formatElt->setOptions($options);
$formatElt->addValidator(\tao_helpers_form_FormFactory::getValidator('NotEmpty'));
$this->form->addElement($formatElt);
}
示例5: getFormalParameter
/**
* get a formal parameter
* @param string $key
* @param string $value
* @return core_kernel_classes_Resource
*/
private function getFormalParameter($key, $value)
{
foreach ($this->formalParamClass->getInstances(false) as $formalParam) {
$name = $formalParam->getOnePropertyValue($this->formalParamNameProp);
if (trim($key) == trim($name)) {
$foundProcessVar = $this->getProcessVar(str_replace('^', '', $value));
if (!is_null($foundProcessVar)) {
try {
$processVar = $formalParam->getUniquePropertyValue($this->formalParamDefProcessVarProp);
if ($foundProcessVar->getUri() == $processVar->getUri()) {
return $formalParam;
}
} catch (common_Exception $ce) {
}
}
try {
if ($value == $formalParam->getUniquePropertyValue($this->formalParamDefConstantProp)) {
return $formalParam;
}
} catch (common_Exception $ce) {
}
}
}
return null;
}
示例6: migrateDeliveryToTemplate
/**
*
* @author Lionel Lecaque, lionel@taotesting.com
*/
private function migrateDeliveryToTemplate()
{
$deliveryClass = new core_kernel_classes_Class(TAO_DELIVERY_CLASS);
foreach ($deliveryClass->getInstances(true) as $delivery) {
self::switchType($delivery, CLASS_DELIVERY_TEMPLATE);
}
}
示例7: testResourceIterator
public function testResourceIterator()
{
$expected1 = array();
foreach ($this->topClass->getInstances(true) as $resource) {
$expected1[] = $resource->getUri();
}
sort($expected1);
$iterator = new core_kernel_classes_ResourceIterator($this->topClass);
$found1 = array();
foreach ($iterator as $instance) {
$this->assertIsA($instance, 'core_kernel_classes_Resource');
$found1[] = $instance->getUri();
}
sort($found1);
$this->assertEquals($expected1, $found1);
$found2 = array();
foreach ($iterator as $instance) {
$found2[] = $instance->getUri();
}
sort($found2);
$this->assertEquals($expected1, $found2);
$iterator = new core_kernel_classes_ResourceIterator($this->emptyClass);
$this->assertFalse($iterator->valid());
$this->assertEquals('1#0', $iterator->key());
}
示例8: addPermissionToClass
/**
* recursivly add permissions to a class and all instances
*/
public static function addPermissionToClass(\core_kernel_classes_Class $class, $userUri, $rights)
{
$dbAccess = new DataBaseAccess();
$dbAccess->addPermissions($userUri, $class->getUri(), $rights);
foreach ($class->getInstances(false) as $instance) {
$dbAccess->addPermissions($userUri, $instance->getUri(), $rights);
}
foreach ($class->getSubClasses(false) as $subclass) {
self::addPermissionToClass($subclass, $userUri, $rights);
}
}
示例9: abandonDeliveryExecution
private function abandonDeliveryExecution()
{
$deliveryExecutionClass = new core_kernel_classes_Class(CLASS_DELVIERYEXECUTION);
$statusProp = new core_kernel_classes_Property(PROPERTY_DELVIERYEXECUTION_STATUS);
foreach ($deliveryExecutionClass->getInstances(true) as $execution) {
$status = $execution->getOnePropertyValue($statusProp);
if ($status == null || $status->getUri() == INSTANCE_DELIVERYEXEC_ACTIVE) {
$execution->editPropertyValues($statusProp, 'http://www.tao.lu/Ontologies/TAODelivery.rdf#DeliveryExecutionStatusAbandoned');
}
}
}
示例10: migrateAllResults
private static function migrateAllResults()
{
$variableClass = new core_kernel_classes_Class("http://www.tao.lu/Ontologies/TAOResult.rdf#Variable");
$variables = $variableClass->getInstances(true);
foreach ($variables as $variable) {
$value = $variable->getUniquePropertyValue(new core_kernel_classes_Property(RDF_VALUE));
if (@unserialize($value) !== false) {
$value = unserialize($value);
$variable->editPropertyValues(new core_kernel_classes_Property(RDF_VALUE), array(base64_encode($value)));
}
}
}
示例11: index
/**
* Show the list of roles
* @return void
*/
public function index()
{
$rolesc = new core_kernel_classes_Class(CLASS_ROLE);
$roles = array();
foreach ($rolesc->getInstances(true) as $id => $r) {
$roles[] = array('id' => $id, 'label' => $r->getLabel());
}
usort($roles, function ($a, $b) {
return strcmp($a['label'], $b['label']);
});
$this->setData('roles', $roles);
$this->setView('list.tpl');
}
示例12: getAvailableImportHandlers
protected function getAvailableImportHandlers()
{
$returnValue = parent::getAvailableImportHandlers();
$itemModelClass = new core_kernel_classes_Class(TAO_ITEM_MODEL_CLASS);
foreach ($itemModelClass->getInstances() as $model) {
$impl = taoItems_models_classes_ItemsService::singleton()->getItemModelImplementation($model);
if (in_array('tao_models_classes_import_ImportProvider', class_implements($impl))) {
foreach ($impl->getImportHandlers() as $handler) {
array_unshift($returnValue, $handler);
}
}
}
return $returnValue;
}
示例13: run
public function run()
{
$itemService = taoItems_models_classes_ItemsService::singleton();
$itemClass = new core_kernel_classes_Class(TAO_ITEM_CLASS);
$items = $itemClass->getInstances(true);
foreach ($items as $item) {
$itemModel = $itemService->getItemModel($item);
if (!is_null($itemModel) && $itemModel->getUri() == ItemModel::MODEL_URI) {
$this->out('qti item found: ' . $item->getLabel());
$this->convertQtiItem($item);
}
// break;
}
}
示例14: testMultiple
/**
* Test the service factory: dynamical instantiation and single instance serving
*/
public function testMultiple()
{
$propClass = new core_kernel_classes_Class(RDF_PROPERTY);
$q = "SELECT subject, count(object)\n FROM statements\n WHERE predicate = ?\n GROUP BY subject\n HAVING (count(object) > 1)";
foreach ($propClass->getInstances(true) as $property) {
$property = new core_kernel_classes_Property($property);
if (!$property->isMultiple() && !$property->isLgDependent()) {
// bypass generis
$result = core_kernel_classes_DbWrapper::singleton()->query($q, array($property->getUri()));
while ($statement = $result->fetch()) {
$this->fail($property->getUri() . ' has multiple values but is not multiple.');
}
}
}
}
示例15: testCreateProcessMonitoringGrid
public function testCreateProcessMonitoringGrid()
{
//wfEngine_helpers_Monitoring_ProcessMonitoringGrid
//wfEngine_helpers_Monitoring_TranslationProcessMonitoringGrid
$processInstancesClass = new core_kernel_classes_Class(CLASS_PROCESSINSTANCES);
$processExecutions = $processInstancesClass->getInstances();
$processMonitoringGrid = new wfAuthoring_helpers_Monitoring_TranslationProcessMonitoringGrid(array_keys($processExecutions));
/*var_dump($processMonitoringGrid->toArray());
var_dump($processMonitoringGrid->getGrid()->getColumnsModel());/*/
//wfEngine_helpers_Monitoring_ExecutionHistoryGrid
//wfEngine_helpers_Monitoring_TranslationExecutionHistoryGrid
if (!empty($processExecutions)) {
$executionHistoryGrid = new wfAuthoring_helpers_Monitoring_TranslationExecutionHistoryGrid(reset($processExecutions));
//var_dump($executionHistoryGrid->toArray());
}
}