You are here

scheduled_updates_tests.module in Scheduled Updates 8

File

tests/modules/scheduled_updates_tests/scheduled_updates_tests.module
View source
<?php

use Drupal\Core\Entity\EntityTypeInterface;

/**
 * Implements hook_entity_base_field_info_alter().
 */
function scheduled_updates_tests_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
  if ($entity_type
    ->id() == 'node' && !empty($fields['title'])) {

    // Add constraint to allow triggering a field violation that confirms the
    // who is running the updates.

    /* @var \Drupal\Core\Field\BaseFieldDefinition[] $fields  */
    $fields['title']
      ->addConstraint('UserId');
  }
}