You are here

public function Extension::serialize in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Extension/Extension.php \Drupal\Core\Extension\Extension::serialize()

Implements Serializable::serialize().

Serializes the Extension object in the most optimized way.

File

core/lib/Drupal/Core/Extension/Extension.php, line 168
Contains \Drupal\Core\Extension\Extension.

Class

Extension
Defines an extension (file) object.

Namespace

Drupal\Core\Extension

Code

public function serialize() {

  // Don't serialize the app root, since this could change if the install is
  // moved.
  $data = array(
    'type' => $this->type,
    'pathname' => $this->pathname,
    'filename' => $this->filename,
  );

  // @todo ThemeHandler::listInfo(), ThemeHandler::rebuildThemeData(), and
  //   system_list() are adding custom properties to the Extension object.
  $info = new \ReflectionObject($this);
  foreach ($info
    ->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
    $data[$property
      ->getName()] = $property
      ->getValue($this);
  }
  return serialize($data);
}