summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/file/src/FileAccessFormatterControlHandlerInterface.php
blob: ad94323676ec736046583e979453cd75f66ab802 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php

namespace Drupal\file;

use Drupal\Core\Entity\EntityAccessControlHandlerInterface;

/**
 * Defines an interface for file access handlers which runs on file formatters.
 *
 * \Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase,
 * which file and image formatters extend, checks 'view' access on the
 * referenced files before displaying them. That check would be useless and
 * costly with Core's default access control implementation for files
 * (\Drupal\file\FileAccessControlHandler grants access based on whether
 * there are existing entities with granted access that reference the file). But
 * it might be needed if a different access control handler with different logic
 * is swapped in.
 *
 * \Drupal\file\Plugin\Field\FieldFormatter\FileFormatterBase thus adjusts that
 * behavior, and only checks access if the access control handler in use for
 * files opts in by implementing this interface.
 *
 * @see \Drupal\file\Plugin\Field\FieldFormatter\FileFormatterBase::needsAccessCheck()
 */
interface FileAccessFormatterControlHandlerInterface extends EntityAccessControlHandlerInterface {}