ChangedFieldItemList.php 925 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace Drupal\Core\Field;
  3. use Drupal\Core\Access\AccessResult;
  4. use Drupal\Core\Session\AccountInterface;
  5. /**
  6. * Defines a item list class for changed fields.
  7. */
  8. class ChangedFieldItemList extends FieldItemList {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function defaultAccess($operation = 'view', AccountInterface $account = NULL) {
  13. // It is not possible to edit the changed field.
  14. return AccessResult::allowedIf($operation !== 'edit');
  15. }
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public function hasAffectingChanges(FieldItemListInterface $original_items, $langcode) {
  20. // When saving entities in the user interface, the changed timestamp is
  21. // automatically incremented by ContentEntityForm::submitForm() even if
  22. // nothing was actually changed. Thus, the changed time needs to be
  23. // ignored when determining whether there are any actual changes in the
  24. // entity.
  25. return FALSE;
  26. }
  27. }