ImageAccessTestHiddenHooks.php

Namespace

Drupal\image_access_test_hidden\Hook

File

core/modules/image/tests/modules/image_access_test_hidden/src/Hook/ImageAccessTestHiddenHooks.php

View source
<?php

declare (strict_types=1);
namespace Drupal\image_access_test_hidden\Hook;

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Hook\Attribute\Hook;

/**
 * Hook implementations for image_access_test_hidden.
 */
class ImageAccessTestHiddenHooks {
    
    /**
     * Implements hook_entity_field_access().
     */
    public function entityFieldAccess($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, ?FieldItemListInterface $items = NULL) {
        if ($field_definition->getName() == 'field_image' && $operation == 'edit') {
            return AccessResult::forbidden();
        }
        return AccessResult::neutral();
    }

}

Classes

Title Deprecated Summary
ImageAccessTestHiddenHooks Hook implementations for image_access_test_hidden.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.