You are here

trait TestActionTrait in Search API 8

Reusable code for test actions.

Hierarchy

File

tests/search_api_test_bulk_form/src/Plugin/Action/TestActionTrait.php, line 12

Namespace

Drupal\search_api_test_bulk_form\Plugin\Action
View source
trait TestActionTrait {

  /**
   * {@inheritdoc}
   */
  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
    return $return_as_object ? AccessResult::allowed() : TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function execute(EntityInterface $entity = NULL) {
    $result = \Drupal::state()
      ->get('search_api_test_bulk_form', []);
    $result[] = [
      $this
        ->getPluginId(),
      $entity
        ->getEntityTypeId(),
      $entity
        ->id(),
    ];
    \Drupal::state()
      ->set('search_api_test_bulk_form', $result);
  }

}

Members