You are here

interface SerialStorageInterface in Serial Field 8

Defines an interface for serial storage classes.

Hierarchy

Expanded class hierarchy of SerialStorageInterface

All classes that implement SerialStorageInterface

1 file declares its use of SerialStorageInterface
serial.module in ./serial.module
The Serial module main file.

File

src/SerialStorageInterface.php, line 12

Namespace

Drupal\serial
View source
interface SerialStorageInterface {
  const SERIAL_FIELD_TYPE = 'serial';

  /**
   * Creates the assistant storage name for a specific field.
   *
   * @param \Drupal\Core\Field\FieldDefinitionInterface $fieldDefinition
   *   Field definition.
   * @param \Drupal\Core\Entity\FieldableEntityInterface $entity
   *   Entity.
   *
   * @return string
   *   Storage name.
   */
  public function createStorageNameFromField(FieldDefinitionInterface $fieldDefinition, FieldableEntityInterface $entity);

  /**
   * Creates the storage name.
   *
   * @param string $entityTypeId
   *   Entity type id.
   * @param string $entityBundle
   *   Entity bundle (entity type) name.
   * @param string $fieldName
   *   Field name.
   *
   * @return string
   *   Storage name.
   */
  public function createStorageName($entityTypeId, $entityBundle, $fieldName);

  /**
   * Generates a unique serial value (unique per entity bundle).
   *
   * @param string $storageName
   *   Storage name.
   * @param bool $delete
   *   Indicates if temporary records should be deleted.
   *
   * @return int
   *   Unique serial id.
   */
  public function generateValueFromName($storageName, $delete = TRUE);

  /**
   * Generates a unique serial value (unique per entity bundle).
   *
   * @param \Drupal\Core\Field\FieldDefinitionInterface $fieldDefinition
   *   Field definition.
   * @param \Drupal\Core\Entity\FieldableEntityInterface $entity
   *   Entity.
   * @param bool $delete
   *   Indicates if temporary records should be deleted.
   *
   * @return int
   *   Unique serial id.
   */
  public function generateValue(FieldDefinitionInterface $fieldDefinition, FieldableEntityInterface $entity, $delete = TRUE);

  /**
   * Gets the schema of the assistant storage for generating serial values.
   *
   * @return array
   *   Assistant storage schema.
   */
  public function getSchema();

  /**
   * Gets a lightweight map of fields across bundles filtered by field type.
   *
   * @return array
   *   An array keyed by entity type. Each value is an array which keys are
   *   field names and value is an array with two entries:
   *   - type: The field type.
   *   - bundles: An associative array of the bundles in which the field
   *     appears, where the keys and values are both the bundle's machine name.
   */
  public function getAllFields();

  /**
   * Creates an assistant serial storage for a new created field.
   *
   * @param \Drupal\Core\Field\FieldDefinitionInterface $fieldDefinition
   *   Field definition.
   * @param \Drupal\Core\Entity\FieldableEntityInterface $entity
   *   Entity.
   */
  public function createStorage(FieldDefinitionInterface $fieldDefinition, FieldableEntityInterface $entity);

  /**
   * Creates an assistant serial storage for a new created field.
   *
   * @param string $storageName
   *   Storage name.
   */
  public function createStorageFromName($storageName);

  /**
   * Drops an assistant serial storage for a deleted field.
   *
   * @param \Drupal\Core\Field\FieldDefinitionInterface $fieldDefinition
   *   Field definition.
   * @param \Drupal\Core\Entity\FieldableEntityInterface $entity
   *   Entity.
   */
  public function dropStorage(FieldDefinitionInterface $fieldDefinition, FieldableEntityInterface $entity);

  /**
   * Drops an assistant serial storage for a deleted field.
   *
   * @param string $storageName
   *   Storage name.
   */
  public function dropStorageFromName($storageName);

  /**
   * Initializes the value of a new serial field in existing entities.
   *
   * @param string $entityTypeId
   *   Entity type id.
   * @param string $entityBundle
   *   Entity bundle (entity type) name.
   * @param string $fieldName
   *   Field name.
   * @param int $startValue
   *   The value to start the serial increment with.
   *
   * @return int
   *   Amount of entries that were updated.
   */
  public function initOldEntries($entityTypeId, $entityBundle, $fieldName, $startValue);

}

Members

Namesort descending Modifiers Type Description Overrides
SerialStorageInterface::createStorage public function Creates an assistant serial storage for a new created field. 1
SerialStorageInterface::createStorageFromName public function Creates an assistant serial storage for a new created field. 1
SerialStorageInterface::createStorageName public function Creates the storage name. 1
SerialStorageInterface::createStorageNameFromField public function Creates the assistant storage name for a specific field. 1
SerialStorageInterface::dropStorage public function Drops an assistant serial storage for a deleted field. 1
SerialStorageInterface::dropStorageFromName public function Drops an assistant serial storage for a deleted field. 1
SerialStorageInterface::generateValue public function Generates a unique serial value (unique per entity bundle). 1
SerialStorageInterface::generateValueFromName public function Generates a unique serial value (unique per entity bundle). 1
SerialStorageInterface::getAllFields public function Gets a lightweight map of fields across bundles filtered by field type. 1
SerialStorageInterface::getSchema public function Gets the schema of the assistant storage for generating serial values. 1
SerialStorageInterface::initOldEntries public function Initializes the value of a new serial field in existing entities. 1
SerialStorageInterface::SERIAL_FIELD_TYPE constant