You are here

class NodeSchema in Schemata 8

Specialized schema for Node Entities.

Leverages NodeType configuration for additional metadata.

Hierarchy

Expanded class hierarchy of NodeSchema

2 files declare their use of NodeSchema
SchemaFactory.php in src/SchemaFactory.php
SchemaFactoryTest.php in tests/src/Kernel/SchemaFactoryTest.php

File

src/Schema/NodeSchema.php, line 13

Namespace

Drupal\schemata\Schema
View source
class NodeSchema extends Schema {

  /**
   * NodeType associated with the current bundle.
   *
   * @var \Drupal\node\Entity\NodeType
   */
  protected $nodeType;

  /**
   * {@inheritdoc}
   */
  public function __construct(EntityDataDefinitionInterface $entity_type, $bundle = NULL, $properties = []) {
    $this->nodeType = NodeType::load($bundle);
    parent::__construct($entity_type, $bundle, $properties);
  }

  /**
   * {@inheritdoc}
   */
  protected function createDescription($entityType, $bundle = '') {
    $description = $this->nodeType
      ->getDescription();
    if (empty($description)) {
      return parent::createDescription($entityType, $bundle);
    }
    return addslashes(strip_tags($description));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::getCacheContexts public function 3
CacheableDependencyTrait::getCacheMaxAge public function 3
CacheableDependencyTrait::getCacheTags public function 3
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
NodeSchema::$nodeType protected property NodeType associated with the current bundle.
NodeSchema::createDescription protected function Generates a description for the schema based on the types. Overrides Schema::createDescription
NodeSchema::__construct public function Creates a Schema object. Overrides Schema::__construct
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function
Schema::$bundle protected property The Entity Type bundle this schema describes, if one exists.
Schema::$entityType protected property The Entity Type this schema describes.
Schema::$metadata protected property Metadata values that describe the schema.
Schema::$properties protected property Typed Data objects for all properties on the entity type/bundle.
Schema::addProperties public function Add additional data properties to the Schema. Overrides SchemaInterface::addProperties
Schema::createTitle protected function Generates a title for the schema based on a simple trio of parameters.
Schema::getBundleId public function Retrieve the Bundle ID. Overrides SchemaInterface::getBundleId
Schema::getEntityTypeId public function Retrieve the Entity Type ID. Overrides SchemaInterface::getEntityTypeId
Schema::getMetadata public function Retrieve the Schema metadata. Overrides SchemaInterface::getMetadata
Schema::getProperties public function Retrieve the Schema properties. Overrides SchemaInterface::getProperties
Schema::__get public function Magic method: Gets a property value.
Schema::__isset public function Magic method: Determines whether a property is set.
Schema::__set public function Magic method: Sets a property value.
Schema::__unset public function Magic method: Unsets a property.