本文整理汇总了PHP中core_kernel_classes_Resource::isInstanceOf方法的典型用法代码示例。如果您正苦于以下问题:PHP core_kernel_classes_Resource::isInstanceOf方法的具体用法?PHP core_kernel_classes_Resource::isInstanceOf怎么用?PHP core_kernel_classes_Resource::isInstanceOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_kernel_classes_Resource
的用法示例。
在下文中一共展示了core_kernel_classes_Resource::isInstanceOf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: adminPermissions
/**
* Manage permissions
* @requiresRight id GRANT
*/
public function adminPermissions()
{
$resource = new \core_kernel_classes_Resource($this->getRequestParameter('id'));
$accessRights = AdminService::getUsersPermissions($resource->getUri());
$this->setData('privileges', PermissionProvider::getRightLabels());
$users = array();
$roles = array();
foreach ($accessRights as $uri => $privileges) {
$identity = new \core_kernel_classes_Resource($uri);
if ($identity->isInstanceOf(\tao_models_classes_RoleService::singleton()->getRoleClass())) {
$roles[$uri] = array('label' => $identity->getLabel(), 'privileges' => $privileges);
} else {
$users[$uri] = array('label' => $identity->getLabel(), 'privileges' => $privileges);
}
}
$this->setData('users', $users);
$this->setData('roles', $roles);
$this->setData('isClass', $resource->isClass());
$this->setData('uri', $resource->getUri());
$this->setData('label', _dh($resource->getLabel()));
$this->setView('AdminAccessController/index.tpl');
}
示例2: getUrl
/**
* return a LTI link URI from a valid delivery id
* @author Christophe GARCIA <christopheg@taotesing.com>
*/
public function getUrl()
{
try {
if ($this->getRequestMethod() != \Request::HTTP_GET) {
throw new \common_exception_NotImplemented('Only GET method is accepted to request this service.');
}
if (!$this->hasRequestParameter('deliveryId')) {
$this->returnFailure(new \common_exception_MissingParameter('At least one mandatory parameter was required but found missing in your request'));
}
$selectedDelivery = new \core_kernel_classes_Resource($this->getRequestParameter('deliveryId'));
if (!$selectedDelivery->isInstanceOf(new \core_kernel_classes_Class(TAO_DELIVERY_CLASS))) {
$this->returnFailure(new \common_exception_NotFound('Delivery not found'));
}
try {
$selectedDelivery->getUniquePropertyValue(new \core_kernel_classes_Property(\TAO_DELIVERY_RESULTSERVER_PROP));
} catch (Exception $e) {
$this->returnFailure(new \common_exception_BadRequest('The delivery is not associated to a Result server storage policy'));
}
$this->returnSuccess(LTIDeliveryTool::singleton()->getLaunchUrl(array('delivery' => $selectedDelivery->getUri())));
} catch (Exception $ex) {
$this->returnFailure($ex);
}
}
示例3: replaceSharedStimulus
/**
* Validate an xml file, convert file linked inside and store it into media manager
* @param \core_kernel_classes_Resource $instance the instance to edit
* @param string $lang language of the shared stimulus
* @param string $xmlFile File to store
* @return \common_report_Report
*/
protected function replaceSharedStimulus($instance, $lang, $xmlFile)
{
//if the class does not belong to media classes create a new one with its name (for items)
$mediaClass = new core_kernel_classes_Class(MediaService::ROOT_CLASS_URI);
if (!$instance->isInstanceOf($mediaClass)) {
$report = \common_report_Report::createFailure('The instance ' . $instance->getUri() . ' is not a Media instance');
return $report;
}
SharedStimulusImporter::isValidSharedStimulus($xmlFile);
$name = basename($xmlFile, '.xml');
$name .= '.xhtml';
$filepath = dirname($xmlFile) . '/' . $name;
\tao_helpers_File::copy($xmlFile, $filepath);
$service = MediaService::singleton();
if (!$service->editMediaInstance($filepath, $instance->getUri(), $lang)) {
$report = \common_report_Report::createFailure(__('Fail to edit Shared Stimulus'));
} else {
$report = \common_report_Report::createSuccess(__('Shared Stimulus edited successfully'));
}
return $report;
}
示例4: compileAction
/**
* Recompile deliveries
*/
private function compileAction()
{
$deliveryIds = array_slice($this->params, 1);
$deliveryClass = new \core_kernel_classes_Class('http://www.tao.lu/Ontologies/TAODelivery.rdf#AssembledDelivery');
$this->report = new Report(Report::TYPE_INFO, 'Recompile deliveries:');
foreach ($deliveryIds as $deliveryId) {
$delivery = new \core_kernel_classes_Resource($deliveryId);
if (!$delivery->exists()) {
$this->report->add(new Report(Report::TYPE_ERROR, "Delivery {$deliveryId} does not exists"));
continue;
} else {
if (!$delivery->isInstanceOf($deliveryClass)) {
$this->report->add(new Report(Report::TYPE_ERROR, "{$deliveryId} is not delivery resource"));
continue;
}
}
try {
$newDelivery = $this->compileDelivery($delivery);
} catch (\common_Exception $e) {
$this->report->add(new Report(Report::TYPE_ERROR, $e->getMessage()));
}
$this->report->add(new Report(Report::TYPE_SUCCESS, "{$deliveryId} successfully compiled. New Id: {$newDelivery->getUri()}"));
}
}
示例5: isRepeated
/**
* Whether delivery is repetition of main delivery
* @param \core_kernel_classes_Resource $delivery
* @return bool
*/
public function isRepeated(\core_kernel_classes_Resource $delivery)
{
return $delivery->isInstanceOf(new \core_kernel_classes_Class(self::CLASS_URI));
}