You are here

public function MinisiteItemList::postSave in Mini site 8

Defines custom post-save behavior for field values.

This method is called during the process of saving an entity, just after item values are written into storage.

Parameters

bool $update: Specifies whether the entity is being updated or created.

Return value

bool Whether field items should be rewritten to the storage as a consequence of the logic implemented by the custom behavior.

Overrides FileFieldItemList::postSave

See also

\Drupal\Core\Field\FieldItemInterface::postSave()

File

src/Plugin/Field/FieldType/MinisiteItemList.php, line 20

Class

MinisiteItemList
Class MinisiteItemList.

Namespace

Drupal\minisite\Plugin\Field\FieldType

Code

public function postSave($update) {
  parent::postSave($update);
  $result = [];

  // Item update or creation.
  if (!$this
    ->isEmpty()) {
    $result = $this
      ->delegateMethodForItemList('postSave', $this, $update);
  }
  else {
    $original_item_list = $this
      ->getOriginalItemsList();
    if ($original_item_list) {
      $result = $this
        ->delegateMethodForItemList('delete', $original_item_list);
    }
  }
  return (bool) array_filter($result);
}