public function CourseObject::getReadOnlyOptions in Course 3.x
Get read-only options. These options have been processed by plugins and may have changed from their definitions.
Only use this to get options when evaluating access or completion.
File
- src/
Entity/ CourseObject.php, line 473
Class
- CourseObject
- Parent abstract base class of all course objects.
Namespace
Drupal\course\EntityCode
public function getReadOnlyOptions() {
$account = \Drupal::currentUser();
if (!isset($this->readOnlyOptionsCache[$account
->id()])) {
$options = $this
->getOptions();
// Allow plugins to alter options on the fly if we are not editing the
// course.
$pluginManager = Drupal::service('plugin.manager.course.object.access');
$plugins = $pluginManager
->getDefinitions();
foreach ($plugins as $key => $plugin) {
// Initialize access class.
/* @var $accessPlugin CourseObjectAccessPluginBase */
$accessPlugin = $pluginManager
->createInstance($key);
$accessPlugin
->setCourseObject($this);
$accessPlugin
->setType($key);
$accessPlugin
->alterOptions($options, $account);
}
$this->readOnlyOptionsCache[$account
->id()] = $options;
}
return $this->readOnlyOptionsCache[$account
->id()];
}