core/modules/file/src/FileFieldUploader.php | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/core/modules/file/src/FileFieldUploader.php b/core/modules/file/src/FileFieldUploader.php index fa3d85b98d..cf45884166 100644 --- a/core/modules/file/src/FileFieldUploader.php +++ b/core/modules/file/src/FileFieldUploader.php @@ -263,33 +263,6 @@ public static function getUploadStream() { return fopen('php://input', 'rb'); } - /** - * Checks if the current user has access to upload the file. - * - * @param \Drupal\Core\Session\AccountInterface $account - * The account for which file upload access should be checked. - * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition - * The field definition for which to get validators. - * @param \Drupal\Core\Entity\EntityInterface $entity - * (optional) The entity to which the file is to be uploaded, if it exists. - * If the entity does not exist and it is not given, create access to the - * file will be checked. - * - * @return \Drupal\Core\Access\AccessResultInterface - * The file upload access result. - */ - public static function checkFileUploadAccess(AccountInterface $account, FieldDefinitionInterface $field_definition, EntityInterface $entity = NULL) { - assert(is_null($entity) || $field_definition->getTargetEntityTypeId() === $entity->getEntityTypeId() && $field_definition->getTargetBundle() === $entity->bundle()); - $entity_type_manager = \Drupal::entityTypeManager(); - $entity_access_control_handler = $entity_type_manager->getAccessControlHandler($field_definition->getTargetEntityTypeId()); - $bundle = $entity_type_manager->getDefinition($field_definition->getTargetEntityTypeId())->hasKey('bundle') ? $field_definition->getTargetBundle() : NULL; - $entity_access_result = $entity - ? $entity_access_control_handler->access($entity, 'update', $account, TRUE) - : $entity_access_control_handler->createAccess($bundle, $account, [], TRUE); - $field_access_result = $entity_access_control_handler->fieldAccess('edit', $field_definition, NULL, NULL, TRUE); - return $entity_access_result->andIf($field_access_result); - } - /** * Reads file upload data to temporary file and moves to file destination. *