You are here

protected static function FieldableEdgeEntityBase::getProperties in Apigee Edge 8

Parses the properties and its types from the parent class.

Return value

array The key is the property name, the value is its type, declared in the docblocks.

1 call to FieldableEdgeEntityBase::getProperties()
FieldableEdgeEntityBase::baseFieldDefinitions in src/Entity/FieldableEdgeEntityBase.php
Provides base field definitions for an entity type.

File

src/Entity/FieldableEdgeEntityBase.php, line 116

Class

FieldableEdgeEntityBase
Base field support for Apigee Entities without making them content entities.

Namespace

Drupal\apigee_edge\Entity

Code

protected static function getProperties() : array {
  $props = [];
  try {
    $rc = new \ReflectionClass(static::decoratedClass());
    foreach ($rc
      ->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {

      // This is not a property getter rather a utility function.
      if ($method
        ->getNumberOfParameters() > 0) {
        continue;
      }

      // Find property getters on decorated PHP API Client entity classes.
      if (strpos($method
        ->getName(), 'get') === 0) {
        $property = lcfirst(substr($method
          ->getName(), 3));
      }
      elseif (strpos($method
        ->getName(), 'is') === 0) {
        $property = lcfirst(substr($method
          ->getName(), 2));
      }
      else {
        continue;
      }
      if (static::exposePropertyAsBaseField($property)) {
        continue;
      }
      $props[$property] = static::propertyFieldType($property);
    }
  } catch (\ReflectionException $e) {
  }
  return $props;
}