FieldableEdgeEntityStorageBase.php in Apigee Edge 8
File
src/Entity/Storage/FieldableEdgeEntityStorageBase.php
View source
<?php
namespace Drupal\apigee_edge\Entity\Storage;
use Drupal\apigee_edge\Entity\FieldableEdgeEntityInterface;
use Drupal\apigee_edge\Exception\InvalidArgumentException;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
abstract class FieldableEdgeEntityStorageBase extends EdgeEntityStorageBase implements FieldableEdgeEntityStorageInterface {
public function requiresFieldStorageSchemaChanges(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original) {
return FALSE;
}
public function requiresFieldDataMigration(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original) {
return FALSE;
}
public function requiresEntityStorageSchemaChanges(EntityTypeInterface $entity_type, EntityTypeInterface $original) {
return FALSE;
}
public function requiresEntityDataMigration(EntityTypeInterface $entity_type, EntityTypeInterface $original) {
return FALSE;
}
public function onEntityTypeCreate(EntityTypeInterface $entity_type) {
}
public function onEntityTypeUpdate(EntityTypeInterface $entity_type, EntityTypeInterface $original) {
}
public function onFieldableEntityTypeCreate(EntityTypeInterface $entity_type, array $field_storage_definitions) {
}
public function onFieldableEntityTypeUpdate(EntityTypeInterface $entity_type, EntityTypeInterface $original, array $field_storage_definitions, array $original_field_storage_definitions, array &$sandbox = NULL) {
}
public function onEntityTypeDelete(EntityTypeInterface $entity_type) {
}
public function onFieldDefinitionCreate(FieldDefinitionInterface $field_definition) {
}
public function onFieldDefinitionUpdate(FieldDefinitionInterface $field_definition, FieldDefinitionInterface $original) {
}
public function onFieldDefinitionDelete(FieldDefinitionInterface $field_definition) {
}
public function onFieldStorageDefinitionCreate(FieldStorageDefinitionInterface $storage_definition) {
}
public function onFieldStorageDefinitionUpdate(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original) {
}
public function onFieldStorageDefinitionDelete(FieldStorageDefinitionInterface $storage_definition) {
}
public function countFieldData($storage_definition, $as_bool = FALSE) {
return $as_bool ? FALSE : 0;
}
public function purgeFieldData(FieldDefinitionInterface $field_definition, $batch_size) {
return 0;
}
public function finalizePurge(FieldStorageDefinitionInterface $storage_definition) {
}
protected function getPersistentCacheTags(EntityInterface $entity) {
$tags = parent::getPersistentCacheTags($entity);
$tags[] = 'entity_field_info';
return $tags;
}
protected function doCreate(array $values) {
$entity = parent::doCreate($values);
$this
->initFieldValues($entity, $values);
return $entity;
}
protected function initFieldValues(FieldableEdgeEntityInterface $entity, array $values = [], array $field_names = []) {
foreach ($entity as $name => $field) {
if (!$field_names || isset($field_names[$name])) {
if (isset($values[$name])) {
$entity
->set($name, $values[$name]);
}
elseif (!array_key_exists($name, $values)) {
$entity
->get($name)
->applyDefaultValue();
}
}
unset($values[$name]);
}
foreach ($values as $name => $value) {
try {
$entity
->setPropertyValue($name, $value);
} catch (InvalidArgumentException $exception) {
}
}
$this
->invokeHook('field_values_init', $entity);
}
}