You are here

public function CourseHandler::getOptions in Course 3.x

Same name and namespace in other branches
  1. 8.3 src/Helper/CourseHandler.php \Drupal\course\Helper\CourseHandler::getOptions()
  2. 8.2 src/Helper/CourseHandler.php \Drupal\course\Helper\CourseHandler::getOptions()

Get an object's configuration.

This can be overridden. For example, values stored in CourseObject sessions need to have priority over those in the database.

Return value

array

3 calls to CourseHandler::getOptions()
CourseHandler::addOptions in src/Helper/CourseHandler.php
Merge an array of options onto the existing options.
CourseHandler::getOption in src/Helper/CourseHandler.php
Get an handler option's value.
CourseObject::getOptions in src/Entity/CourseObject.php
Get options, with session options, except weight, having precedence.
1 method overrides CourseHandler::getOptions()
CourseObject::getOptions in src/Entity/CourseObject.php
Get options, with session options, except weight, having precedence.

File

src/Helper/CourseHandler.php, line 43

Class

CourseHandler
Master class for a course related content entity.

Namespace

Drupal\course\Helper

Code

public function getOptions() {
  $defaults = $this
    ->optionsDefinition();
  foreach ($this
    ->getFields() as $key => $var) {
    if ($var
      ->isEmpty() && array_key_exists($key, $defaults)) {
      $out[$key] = $defaults[$key];
    }
    else {
      $out[$key] = $var
        ->getString();
    }
    if (is_a($var, MapFieldItemList::class) && !$var
      ->isEmpty()) {

      // This is a serialized data field.

      /* @var $data MapFieldItemList */
      $data = $var;
      foreach ($data
        ->first()
        ->getValue() as $skey => $sval) {
        if (!isset($this
          ->getFields()[$skey])) {
          $out[$skey] = $sval;
        }
      }
    }
  }
  return $out + $defaults;
}