W3cubDocs

/Drupal 8

public function Extension::serialize

public Extension::serialize()

Implements Serializable::serialize().

Serializes the Extension object in the most optimized way.

File

core/lib/Drupal/Core/Extension/Extension.php, line 163

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);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Extension!Extension.php/function/Extension::serialize/8.1.x