You are here

HookCommentUnitTest.inc in Coder 8.3.x

Same filename and directory in other branches
  1. 8.3 tests/Drupal/Commenting/HookCommentUnitTest.inc

Example file with hook implementations.

File

tests/Drupal/Commenting/HookCommentUnitTest.inc
View source
<?php

/**
 * @file
 * Example file with hook implementations.
 */

/**
 * Implements example_page_build().
 */
function example_page_build(&$page) {
}

/**
 * Has a method doc comment that is not a hook implementation.
 */
class Test {

  /**
   * Implements a hook bridge for hook_entity_access().
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity to check access for.
   * @param string $operation
   *   The operation being performed.
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The user account making the to check access for.
   *
   * @return \Drupal\Core\Access\AccessResult
   *   The result of the access check.
   *
   * @see hook_entity_access()
   */
  public function entityOperationAccess(EntityInterface $entity, $operation, AccountInterface $account) {

    // Workspaces themselves are handled by their own access handler and we
    // should not try to do any access checks for entity types that can not
    // belong to a workspace.
    if ($entity
      ->getEntityTypeId() === 'workspace' || !$this->workspaceManager
      ->isEntityTypeSupported($entity
      ->getEntityType())) {
      return AccessResult::neutral();
    }
    return $this
      ->bypassAccessResult($account);
  }

  /**
   * Implements a hook bridge for hook_entity_access().
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity to check access for.
   * @param string $operation
   *   The operation being performed.
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The user account making the to check access for.
   *
   * @return \Drupal\Core\Access\AccessResult
   *   The result of the access check.
   *
   * @see hook_entity_access()
   */
  function entityOperationAccess2(EntityInterface $entity, $operation, AccountInterface $account) {

    // Workspaces themselves are handled by their own access handler and we
    // should not try to do any access checks for entity types that can not
    // belong to a workspace.
    if ($entity
      ->getEntityTypeId() === 'workspace' || !$this->workspaceManager
      ->isEntityTypeSupported($entity
      ->getEntityType())) {
      return AccessResult::neutral();
    }
    return $this
      ->bypassAccessResult($account);
  }

}

Functions

Namesort descending Description
example_page_build Implements example_page_build().

Classes

Namesort descending Description
Test Has a method doc comment that is not a hook implementation.