class FormEntityContext in Flexiform 8
Class for form entity contexts.
Hierarchy
- class \Drupal\Component\Plugin\Context\Context implements ContextInterface
- class \Drupal\Core\Plugin\Context\Context implements ContextInterface uses DependencySerializationTrait, TypedDataTrait
- class \Drupal\flexiform\FormEntity\FormEntityContext implements FormEntityContextInterface uses DependencySerializationTrait
- class \Drupal\Core\Plugin\Context\Context implements ContextInterface uses DependencySerializationTrait, TypedDataTrait
Expanded class hierarchy of FormEntityContext
File
- src/
FormEntity/ FormEntityContext.php, line 13
Namespace
Drupal\flexiform\FormEntityView source
class FormEntityContext extends Context implements FormEntityContextInterface {
use DependencySerializationTrait;
/**
* The entity namespace.
*
* @var string
*/
protected $entityNamespace;
/**
* The form entity plugin.
*
* @var \Drupal\flexiform\FormEntity\FlexiformFormEntityInterface
*/
protected $formEntity;
/**
* {@inheritdoc}
*/
public function setEntityNamespace($namespace) {
$this->entityNamespace = $namespace;
}
/**
* {@inheritdoc}
*/
public function getEntityNamespace() {
return $this->entityNamespace;
}
/**
* {@inheritdoc}
*/
public function getFormEntity() {
return $this->formEntity;
}
/**
* {@inheritdoc}
*/
public function setFormEntity(FlexiformFormEntityInterface $form_entity) {
$this->formEntity = $form_entity;
}
/**
* {@inheritdoc}
*/
public function hasContextValue() {
if (!$this->contextData) {
$this
->getContextValue();
}
return parent::hasContextValue();
}
/**
* {@inheritdoc}
*/
public function getContextValue() {
if (!$this->contextData) {
$this
->setContextValue($this
->getFormEntity()
->getEntity());
}
return parent::getContextValue();
}
/**
* Create from a form entity plugin.
*
* @param \Drupal\flexiform\FormEntity\FlexiformFormEntityInterface $form_entity
* The form entity plugin.
* @param \Drupal\Core\Entity\FieldableEntityInterface $entity
* The form entity to create from.
*
* @return static
* The generated context.
*/
public static function createFromFlexiformFormEntity(FlexiformFormEntityInterface $form_entity, FieldableEntityInterface $entity = NULL) {
$context_definition = new ContextDefinition('entity:' . $form_entity
->getEntityType(), $form_entity
->getLabel());
$context_definition
->addConstraint('Bundle', [
$form_entity
->getBundle(),
]);
$context = new static($context_definition, $entity);
$context
->setFormEntity($form_entity);
return $context;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Context:: |
protected | property | The cacheability metadata. | |
Context:: |
protected | property | The data associated with the context. | |
Context:: |
protected | property |
The definition to which a context must conform. Overrides Context:: |
|
Context:: |
protected | property | The value of the context. | |
Context:: |
public | function |
Adds a dependency on an object: merges its cacheability metadata. Overrides ContextInterface:: |
|
Context:: |
public static | function |
Creates a new context with a different value. Overrides ContextInterface:: |
|
Context:: |
public | function |
The cache contexts associated with this object. Overrides CacheableDependencyInterface:: |
|
Context:: |
public | function |
The maximum age for which this object may be cached. Overrides CacheableDependencyInterface:: |
|
Context:: |
public | function |
The cache tags associated with this object. Overrides CacheableDependencyInterface:: |
|
Context:: |
public | function |
Gets a list of validation constraints. Overrides Context:: |
|
Context:: |
public | function |
Gets the context value as typed data object. Overrides ContextInterface:: |
|
Context:: |
public | function |
Gets the provided definition that the context must conform to. Overrides Context:: |
|
Context:: |
protected | function | Sets the context value. | |
Context:: |
public | function |
Validates the set context value. Overrides Context:: |
|
Context:: |
public | function |
Create a context object. Overrides Context:: |
|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormEntityContext:: |
protected | property | The entity namespace. | |
FormEntityContext:: |
protected | property | The form entity plugin. | |
FormEntityContext:: |
public static | function | Create from a form entity plugin. | |
FormEntityContext:: |
public | function |
Gets the context value. Overrides Context:: |
|
FormEntityContext:: |
public | function |
Get the entity namespace. Overrides FormEntityContextInterface:: |
|
FormEntityContext:: |
public | function |
Get the form entity plugin. Overrides FormEntityContextInterface:: |
|
FormEntityContext:: |
public | function |
Returns whether the context has a value. Overrides Context:: |
|
FormEntityContext:: |
public | function |
Set the entity namespace. Overrides FormEntityContextInterface:: |
|
FormEntityContext:: |
public | function | ||
TypedDataTrait:: |
protected | property | The typed data manager used for creating the data types. | |
TypedDataTrait:: |
public | function | Gets the typed data manager. | 2 |
TypedDataTrait:: |
public | function | Sets the typed data manager. | 2 |