You are here

public function Extension::serialize in Service Container 7.2

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

Implements Serializable::serialize().

Serializes the Extension object in the most optimized way.

File

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() {
  $data = array(
    'root' => $this->root,
    '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);
}