diff --git a/core/modules/jsonapi/src/Controller/TemporaryJsonapiFileFieldUploader.php b/core/modules/jsonapi/src/Controller/TemporaryJsonapiFileFieldUploader.php index a8ca4066f737afed93a808de99bda9237bb48e04..c5b1d6f80f9cd8d07241e458446709adeaa600ff 100644 --- a/core/modules/jsonapi/src/Controller/TemporaryJsonapiFileFieldUploader.php +++ b/core/modules/jsonapi/src/Controller/TemporaryJsonapiFileFieldUploader.php @@ -2,7 +2,6 @@ namespace Drupal\jsonapi\Controller; -use Drupal\Component\Render\PlainTextOutput; use Drupal\Component\Utility\Crypt; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityInterface; @@ -12,13 +11,11 @@ use Drupal\Core\File\FileExists; use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Lock\LockBackendInterface; -use Drupal\Core\Render\BubbleableMetadata; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Utility\Token; use Drupal\file\Entity\File; use Drupal\file\FileInterface; use Drupal\file\Plugin\Field\FieldType\FileFieldItemList; -use Drupal\file\Upload\ContentDispositionFilenameParser; use Drupal\file\Upload\FileUploadLocationTrait; use Drupal\file\Upload\InputStreamFileWriterInterface; use Drupal\file\Validation\FileValidatorInterface; @@ -27,9 +24,9 @@ use Symfony\Component\HttpFoundation\File\Exception\CannotWriteFileException; use Symfony\Component\HttpFoundation\File\Exception\NoFileException; use Symfony\Component\HttpFoundation\File\Exception\UploadException; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\Mime\MimeTypeGuesserInterface; /** * Reads data from an upload stream and creates a corresponding file entity. @@ -51,136 +48,7 @@ class TemporaryJsonapiFileFieldUploader { getUploadLocation as getUploadDestination; } - /** - * The regex used to extract the filename from the content disposition header. - * - * @var string - * - * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use - * \Drupal\file\Upload\ContentDispositionFilenameParser::REQUEST_HEADER_FILENAME_REGEX - * instead. - * - * @see https://www.drupal.org/node/3380380 - */ - const REQUEST_HEADER_FILENAME_REGEX = '@\bfilename(?<star>\*?)=\"(?<filename>.+)\"@'; - - /** - * The amount of bytes to read in each iteration when streaming file data. - * - * @var int - * - * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use - * \Drupal\file\Upload\InputStreamFileWriterInterface::DEFAULT_BYTES_TO_READ - * instead. - * - * @see https://www.drupal.org/node/3380607 - */ - const BYTES_TO_READ = 8192; - - /** - * A logger instance. - * - * @var \Psr\Log\LoggerInterface - */ - protected $logger; - - /** - * The file system service. - * - * @var \Drupal\Core\File\FileSystemInterface - */ - protected $fileSystem; - - /** - * The MIME type guesser. - * - * @var \Symfony\Component\Mime\MimeTypeGuesserInterface - */ - protected $mimeTypeGuesser; - - /** - * The token replacement instance. - * - * @var \Drupal\Core\Utility\Token - */ - protected $token; - - /** - * The lock service. - * - * @var \Drupal\Core\Lock\LockBackendInterface - */ - protected $lock; - - /** - * System file configuration. - * - * @var \Drupal\Core\Config\ImmutableConfig - */ - protected $systemFileConfig; - - /** - * The event dispatcher. - * - * @var \Symfony\Contracts\EventDispatcher\EventDispatcherInterface - */ - protected $eventDispatcher; - - /** - * The file validator. - * - * @var \Drupal\file\Validation\FileValidatorInterface - */ - protected FileValidatorInterface $fileValidator; - - /** - * The input stream file writer. - */ - protected InputStreamFileWriterInterface $inputStreamFileWriter; - - /** - * Constructs a FileUploadResource instance. - * - * @param \Psr\Log\LoggerInterface $logger - * A logger instance. - * @param \Drupal\Core\File\FileSystemInterface $file_system - * The file system service. - * @param \Symfony\Component\Mime\MimeTypeGuesserInterface $mime_type_guesser - * The MIME type guesser. - * @param \Drupal\Core\Utility\Token $token - * The token replacement instance. - * @param \Drupal\Core\Lock\LockBackendInterface $lock - * The lock service. - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The config factory. - * @param \Symfony\Contracts\EventDispatcher\EventDispatcherInterface|null $event_dispatcher - * (optional) The event dispatcher. - * @param \Drupal\file\Validation\FileValidatorInterface|null $file_validator - * The file validator. - * @param \Drupal\file\Upload\InputStreamFileWriterInterface|null $input_stream_file_writer - * The stream file uploader. - */ - public function __construct(LoggerInterface $logger, FileSystemInterface $file_system, $mime_type_guesser, Token $token, LockBackendInterface $lock, ConfigFactoryInterface $config_factory, EventDispatcherInterface $event_dispatcher = NULL, FileValidatorInterface $file_validator = NULL, InputStreamFileWriterInterface $input_stream_file_writer = NULL) { - $this->logger = $logger; - $this->fileSystem = $file_system; - $this->mimeTypeGuesser = $mime_type_guesser; - $this->token = $token; - $this->lock = $lock; - $this->systemFileConfig = $config_factory->get('system.file'); - if (!$event_dispatcher) { - $event_dispatcher = \Drupal::service('event_dispatcher'); - } - $this->eventDispatcher = $event_dispatcher; - if (!$file_validator) { - @trigger_error('Calling ' . __METHOD__ . '() without the $file_validator argument is deprecated in drupal:10.2.0 and is required in drupal:11.0.0. See https://www.drupal.org/node/3363700', E_USER_DEPRECATED); - $file_validator = \Drupal::service('file.validator'); - } - $this->fileValidator = $file_validator; - if (!$input_stream_file_writer) { - @trigger_error('Calling ' . __METHOD__ . '() without the $input_stream_file_writer argument is deprecated in drupal:10.3.0 and is required in drupal:11.0.0. See https://www.drupal.org/node/3380607', E_USER_DEPRECATED); - $input_stream_file_writer = \Drupal::service('file.input_stream_file_writer'); - } - $this->inputStreamFileWriter = $input_stream_file_writer; + public function __construct(protected LoggerInterface $logger, protected FileSystemInterface $fileSystem, protected MimeTypeGuesserInterface $mimeTypeGuesser, protected Token $token, protected LockBackendInterface $lock, protected ConfigFactoryInterface $configFactory, protected EventDispatcherInterface $eventDispatcher, protected FileValidatorInterface $fileValidator, protected InputStreamFileWriterInterface $inputStreamFileWriter) { } /** @@ -290,29 +158,6 @@ public function handleFileUploadForField(FieldDefinitionInterface $field_definit return $file; } - /** - * Validates and extracts the filename from the Content-Disposition header. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * The request object. - * - * @return string - * The filename extracted from the header. - * - * @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException - * Thrown when the 'Content-Disposition' request header is invalid. - * - * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use - * \Drupal\file\Upload\ContentDispositionFilenameParser::parseFilename() - * instead. - * - * @see https://www.drupal.org/node/3380380 - */ - public function validateAndParseContentDispositionHeader(Request $request) { - @trigger_error('Calling ' . __METHOD__ . '() is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use \Drupal\file\Upload\ContentDispositionFilenameParser::parseFilename() instead. See https://www.drupal.org/node/3380380', E_USER_DEPRECATED); - return ContentDispositionFilenameParser::parseFilename($request); - } - /** * Checks if the current user has access to upload the file. * @@ -423,31 +268,6 @@ protected function prepareFilename($filename, array &$validators) { return $event->getFilename(); } - /** - * Determines the URI for a file field. - * - * @param array $settings - * The array of field settings. - * - * @return string - * An un-sanitized file directory URI with tokens replaced. The result of - * the token replacement is then converted to plain text and returned. - * - * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use - * \Drupal\file\Upload\FileUploadLocationTrait::getUploadLocation() instead. - * - * @see https://www.drupal.org/node/3406099 - */ - protected function getUploadLocation(array $settings) { - @\trigger_error(__METHOD__ . ' is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use \Drupal\file\Upload\FileUploadLocationTrait::getUploadLocation() instead. See https://www.drupal.org/node/3406099', E_USER_DEPRECATED); - $destination = trim($settings['file_directory'], '/'); - - // Replace tokens. As the tokens might contain HTML we convert it to plain - // text. - $destination = PlainTextOutput::renderFromHtml($this->token->replace($destination, [], [], new BubbleableMetadata())); - return $settings['uri_scheme'] . '://' . $destination; - } - /** * Generates a lock ID based on the file URI. * diff --git a/core/modules/jsonapi/src/IncludeResolver.php b/core/modules/jsonapi/src/IncludeResolver.php index b7d47d557621c9842be1d5e0a30096f20bc3f210..9a77602d365932ef5e722af3b7ab69aec794cff6 100644 --- a/core/modules/jsonapi/src/IncludeResolver.php +++ b/core/modules/jsonapi/src/IncludeResolver.php @@ -6,7 +6,6 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Field\FieldItemListInterface; -use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItemInterface; use Drupal\Core\TypedData\DataReferenceDefinitionInterface; use Drupal\jsonapi\Access\EntityAccessChecker; use Drupal\jsonapi\Context\FieldResolver; @@ -138,32 +137,18 @@ protected function resolveIncludeTree(array $include_tree, Data $data, Data $inc $includes = IncludedData::merge($includes, new IncludedData([$exception])); continue; } - if (is_subclass_of($field_list->getItemDefinition()->getClass(), EntityReferenceItemInterface::class)) { - foreach ($field_list as $field_item) { - if (!($field_item->getDataDefinition()->getPropertyDefinition('entity') instanceof DataReferenceDefinitionInterface)) { - continue; - } - - if (!($field_item->entity instanceof EntityInterface)) { - continue; - } - - // Support entity reference fields that don't have the referenced - // target type stored in settings. - $references[$field_item->entity->getEntityTypeId()][] = $field_item->get($field_item::mainPropertyName())->getValue(); + foreach ($field_list as $field_item) { + if (!($field_item->getDataDefinition()->getPropertyDefinition('entity') instanceof DataReferenceDefinitionInterface)) { + continue; } - } - else { - @trigger_error( - sprintf('Entity reference field items not implementing %s is deprecated in drupal:10.2.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3279140', EntityReferenceItemInterface::class), - E_USER_DEPRECATED - ); - $target_type = $field_list->getFieldDefinition()->getFieldStorageDefinition()->getSetting('target_type'); - if (!empty($target_type)) { - foreach ($field_list as $field_item) { - $references[$target_type][] = $field_item->get($field_item::mainPropertyName())->getValue(); - } + + if (!($field_item->entity instanceof EntityInterface)) { + continue; } + + // Support entity reference fields that don't have the referenced + // target type stored in settings. + $references[$field_item->entity->getEntityTypeId()][] = $field_item->get($field_item::mainPropertyName())->getValue(); } } foreach ($references as $target_type => $ids) { diff --git a/core/modules/jsonapi/src/Normalizer/ConfigEntityDenormalizer.php b/core/modules/jsonapi/src/Normalizer/ConfigEntityDenormalizer.php index d803f6e3008bea2b495068387c0ab17ec2ab4e02..9bcda10ab70a80307eb98027215fc5c64d2d14dc 100644 --- a/core/modules/jsonapi/src/Normalizer/ConfigEntityDenormalizer.php +++ b/core/modules/jsonapi/src/Normalizer/ConfigEntityDenormalizer.php @@ -27,15 +27,6 @@ protected function prepareInput(array $data, ResourceType $resource_type, $forma return $prepared; } - /** - * {@inheritdoc} - */ - public function hasCacheableSupportsMethod(): bool { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED); - - return TRUE; - } - /** * {@inheritdoc} */ diff --git a/core/modules/jsonapi/src/Normalizer/ContentEntityDenormalizer.php b/core/modules/jsonapi/src/Normalizer/ContentEntityDenormalizer.php index 112c02212a412fd7a1b4089dc812711808636278..6748e1a30d207754b913f68e83d5b1dfb10251af 100644 --- a/core/modules/jsonapi/src/Normalizer/ContentEntityDenormalizer.php +++ b/core/modules/jsonapi/src/Normalizer/ContentEntityDenormalizer.php @@ -83,15 +83,6 @@ protected function prepareInput(array $data, ResourceType $resource_type, $forma return $data_internal; } - /** - * {@inheritdoc} - */ - public function hasCacheableSupportsMethod(): bool { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED); - - return TRUE; - } - /** * {@inheritdoc} */ diff --git a/core/modules/jsonapi/src/Normalizer/DataNormalizer.php b/core/modules/jsonapi/src/Normalizer/DataNormalizer.php index 7c3a039552e23af2c829db2330ab77e0d12521b4..c7e162e240dec7658d6a0563d7ff98029e34aaa7 100644 --- a/core/modules/jsonapi/src/Normalizer/DataNormalizer.php +++ b/core/modules/jsonapi/src/Normalizer/DataNormalizer.php @@ -25,15 +25,6 @@ public function normalize($object, $format = NULL, array $context = []): array|s : CacheableNormalization::aggregate($cacheable_normalizations); } - /** - * {@inheritdoc} - */ - public function hasCacheableSupportsMethod(): bool { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED); - - return TRUE; - } - /** * {@inheritdoc} */ diff --git a/core/modules/jsonapi/src/Normalizer/FieldItemNormalizer.php b/core/modules/jsonapi/src/Normalizer/FieldItemNormalizer.php index 82fbd0ecde28e83db6d7ff546e7b6dde2e67b023..b8089ccf6a9e6d681d6ce9e4bfa41304fe65c909 100644 --- a/core/modules/jsonapi/src/Normalizer/FieldItemNormalizer.php +++ b/core/modules/jsonapi/src/Normalizer/FieldItemNormalizer.php @@ -233,15 +233,6 @@ protected function getFieldItemInstance(ResourceType $resource_type, FieldItemDa return $field_item; } - /** - * {@inheritdoc} - */ - public function hasCacheableSupportsMethod(): bool { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED); - - return TRUE; - } - /** * {@inheritdoc} */ diff --git a/core/modules/jsonapi/src/Normalizer/FieldNormalizer.php b/core/modules/jsonapi/src/Normalizer/FieldNormalizer.php index fd1fd1bb60190af86c6c73d7d7e593d2b961c451..188f24c6bd44c1fbd5a73994ab231b514e21f129 100644 --- a/core/modules/jsonapi/src/Normalizer/FieldNormalizer.php +++ b/core/modules/jsonapi/src/Normalizer/FieldNormalizer.php @@ -89,15 +89,6 @@ protected function normalizeFieldItems(FieldItemListInterface $field, $format, a return $normalizer_items; } - /** - * {@inheritdoc} - */ - public function hasCacheableSupportsMethod(): bool { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED); - - return TRUE; - } - /** * {@inheritdoc} */ diff --git a/core/modules/jsonapi/src/Normalizer/HttpExceptionNormalizer.php b/core/modules/jsonapi/src/Normalizer/HttpExceptionNormalizer.php index 6ca47ae23340fa3b6b2bc49bb10d5d7653e17c48..b80eb46edc17a30e4bf09e3268fc270c32153ceb 100644 --- a/core/modules/jsonapi/src/Normalizer/HttpExceptionNormalizer.php +++ b/core/modules/jsonapi/src/Normalizer/HttpExceptionNormalizer.php @@ -166,15 +166,6 @@ public static function getInfoUrl($status_code) { return empty($sections[$status_code]) ? NULL : $url . $sections[$status_code]; } - /** - * {@inheritdoc} - */ - public function hasCacheableSupportsMethod(): bool { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED); - - return TRUE; - } - /** * {@inheritdoc} */ diff --git a/core/modules/jsonapi/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php b/core/modules/jsonapi/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php index 6954c5b73ab50481957fb3a8879cb59119e6022b..8e616b498d1ace1533d0f58400903480991d5918 100644 --- a/core/modules/jsonapi/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php +++ b/core/modules/jsonapi/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php @@ -327,15 +327,6 @@ protected static function getLinkHash($salt, $link_href) { return substr(str_replace(['-', '_'], '', Crypt::hashBase64($salt . $link_href)), 0, 7); } - /** - * {@inheritdoc} - */ - public function hasCacheableSupportsMethod(): bool { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED); - - return TRUE; - } - /** * {@inheritdoc} */ diff --git a/core/modules/jsonapi/src/Normalizer/LinkCollectionNormalizer.php b/core/modules/jsonapi/src/Normalizer/LinkCollectionNormalizer.php index 96a50bc3e446e4a283476a5eb9624a7c756adb6d..74487b20407ccb2e33490f9378dc9b1bd66f4b2e 100644 --- a/core/modules/jsonapi/src/Normalizer/LinkCollectionNormalizer.php +++ b/core/modules/jsonapi/src/Normalizer/LinkCollectionNormalizer.php @@ -145,15 +145,6 @@ protected function hashByHref(Link $link) { return substr(str_replace(['-', '_'], '', $b64_hash), 0, 7); } - /** - * {@inheritdoc} - */ - public function hasCacheableSupportsMethod(): bool { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED); - - return TRUE; - } - /** * {@inheritdoc} */ diff --git a/core/modules/jsonapi/src/Normalizer/RelationshipNormalizer.php b/core/modules/jsonapi/src/Normalizer/RelationshipNormalizer.php index 90e2d79cb689a62d607b57c9f645bb92943834fa..b406cd4d749ffa2ce20ddd476270fba12f486ff4 100644 --- a/core/modules/jsonapi/src/Normalizer/RelationshipNormalizer.php +++ b/core/modules/jsonapi/src/Normalizer/RelationshipNormalizer.php @@ -24,15 +24,6 @@ public function normalize($object, $format = NULL, array $context = []): array|s ]); } - /** - * {@inheritdoc} - */ - public function hasCacheableSupportsMethod(): bool { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED); - - return TRUE; - } - /** * {@inheritdoc} */ diff --git a/core/modules/jsonapi/src/Normalizer/ResourceIdentifierNormalizer.php b/core/modules/jsonapi/src/Normalizer/ResourceIdentifierNormalizer.php index 87454df8d750df22ad10c8b46632dfacf6ef6ba2..b450ea02e701b65a6518ac4c756d7d0131f22fc8 100644 --- a/core/modules/jsonapi/src/Normalizer/ResourceIdentifierNormalizer.php +++ b/core/modules/jsonapi/src/Normalizer/ResourceIdentifierNormalizer.php @@ -134,15 +134,6 @@ protected function massageRelationshipInput(array $data, $is_multiple) { return $data; } - /** - * {@inheritdoc} - */ - public function hasCacheableSupportsMethod(): bool { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED); - - return TRUE; - } - /** * {@inheritdoc} */ diff --git a/core/modules/jsonapi/src/Normalizer/ResourceObjectNormalizer.php b/core/modules/jsonapi/src/Normalizer/ResourceObjectNormalizer.php index dfcbc3ca9b2e346e2b3a28f5b86fe28a24d9263b..ca9c28cbecea1bfea9001bb333f2c09b162efc0d 100644 --- a/core/modules/jsonapi/src/Normalizer/ResourceObjectNormalizer.php +++ b/core/modules/jsonapi/src/Normalizer/ResourceObjectNormalizer.php @@ -197,15 +197,6 @@ protected function serializeField($field, array $context, $format) { } } - /** - * {@inheritdoc} - */ - public function hasCacheableSupportsMethod(): bool { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED); - - return TRUE; - } - /** * {@inheritdoc} */ diff --git a/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php b/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php index 25bc5f8de3f26735ab08bbf1ef044512630d2289..901ec2104b155e09ead54bb428140fdec142db44 100644 --- a/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php +++ b/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php @@ -15,7 +15,6 @@ use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Installer\InstallerKernel; -use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItemInterface; use Drupal\Core\Logger\LoggerChannelTrait; use Drupal\Core\TypedData\DataReferenceTargetDefinition; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; @@ -445,21 +444,7 @@ protected function getRelatableResourceTypesFromFieldDefinition(FieldDefinitionI $entity_type_id = $item_definition->getSetting('target_type'); $relatable_resource_types = []; $item_class = $item_definition->getClass(); - if (is_subclass_of($item_class, EntityReferenceItemInterface::class)) { - $target_type_bundles = $item_class::getReferenceableBundles($field_definition); - } - else { - @trigger_error( - sprintf('Entity reference field items not implementing %s is deprecated in drupal:10.2.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3279140', EntityReferenceItemInterface::class), - E_USER_DEPRECATED - ); - $handler_settings = $item_definition->getSetting('handler_settings'); - - $has_target_bundles = isset($handler_settings['target_bundles']) && !empty($handler_settings['target_bundles']); - $target_bundles = $has_target_bundles ? $handler_settings['target_bundles'] : $this->getAllBundlesForEntityType($entity_type_id); - $target_type_bundles = [$entity_type_id => $target_bundles]; - } - + $target_type_bundles = $item_class::getReferenceableBundles($field_definition); foreach ($target_type_bundles as $entity_type_id => $target_bundles) { foreach ($target_bundles as $target_bundle) { if ($resource_type = static::lookupResourceType($resource_types, $entity_type_id, $target_bundle)) { diff --git a/core/modules/jsonapi/tests/modules/jsonapi_test_reference_types/jsonapi_test_reference_types.info.yml b/core/modules/jsonapi/tests/modules/jsonapi_test_reference_types/jsonapi_test_reference_types.info.yml deleted file mode 100644 index c87903c1da50316c0b796da5308c18affc1f3397..0000000000000000000000000000000000000000 --- a/core/modules/jsonapi/tests/modules/jsonapi_test_reference_types/jsonapi_test_reference_types.info.yml +++ /dev/null @@ -1,3 +0,0 @@ -name: 'JSON API test deprecated reference field types' -type: module -package: Testing diff --git a/core/modules/jsonapi/tests/modules/jsonapi_test_reference_types/jsonapi_test_reference_types.module b/core/modules/jsonapi/tests/modules/jsonapi_test_reference_types/jsonapi_test_reference_types.module deleted file mode 100644 index df448396837b1954666339de1ffb9ca6f4aebb93..0000000000000000000000000000000000000000 --- a/core/modules/jsonapi/tests/modules/jsonapi_test_reference_types/jsonapi_test_reference_types.module +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -/** - * @file - * Contains hook implementations for the jsonapi_test_reference_types module. - */ - -use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Field\BaseFieldDefinition; - -/** - * Implements hook_entity_base_field_info(). - */ -function jsonapi_test_reference_types_entity_base_field_info(EntityTypeInterface $entity_type) { - // Add a field of the deprecated reference type to nodes. - if ($entity_type->id() === 'node') { - $fields = []; - $fields['deprecated_reference'] = BaseFieldDefinition::create('jsonapi_test_deprecated_reference') - ->setLabel(t('Reference')) - ->setDescription(t('Deprecated reference field.')); - - return $fields; - } -} diff --git a/core/modules/jsonapi/tests/modules/jsonapi_test_reference_types/src/Plugin/Field/FieldType/DeprecatedReferenceItem.php b/core/modules/jsonapi/tests/modules/jsonapi_test_reference_types/src/Plugin/Field/FieldType/DeprecatedReferenceItem.php deleted file mode 100644 index 7067bc5bd869d095f487c0316dcfa4ece1d06d7b..0000000000000000000000000000000000000000 --- a/core/modules/jsonapi/tests/modules/jsonapi_test_reference_types/src/Plugin/Field/FieldType/DeprecatedReferenceItem.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php - -namespace Drupal\jsonapi_test_reference_types\Plugin\Field\FieldType; - -use Drupal\Core\Field\FieldItemBase; -use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\Core\StringTranslation\TranslatableMarkup; -use Drupal\Core\TypedData\DataReferenceTargetDefinition; - -/** - * Entity reference field type which doesn't implement the standard interface. - * - * This is to test the handling of deprecated fields which do not implement - * \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItemInterface. - * - * @see https://www.drupal.org/node/3279140 - * @see \Drupal\Tests\jsonapi\Kernel\ResourceType\RelatedResourceTypesTest::testGetRelatableResourceTypesFromFieldDefinitionEntityReferenceFieldDeprecated() - * - * @todo Remove this in Drupal 11 https://www.drupal.org/project/drupal/issues/3353314. - * - * @FieldType( - * id = "jsonapi_test_deprecated_reference", - * ) - */ -class DeprecatedReferenceItem extends FieldItemBase { - - /** - * {@inheritdoc} - */ - public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { - $properties['target_id'] = DataReferenceTargetDefinition::create('integer') - ->setLabel(new TranslatableMarkup('Target ID')) - ->setSetting('unsigned', TRUE); - - return $properties; - } - - /** - * {@inheritdoc} - */ - public static function schema(FieldStorageDefinitionInterface $field_definition) { - $schema = [ - 'columns' => [ - 'target_id' => [ - 'description' => 'The ID of the target entity.', - 'type' => 'int', - 'unsigned' => TRUE, - ], - ], - 'indexes' => [ - 'target_id' => ['target_id'], - ], - ]; - - return $schema; - } - - /** - * {@inheritdoc} - */ - public static function mainPropertyName() { - return 'target_id'; - } - -} diff --git a/core/modules/jsonapi/tests/src/Functional/NodeTest.php b/core/modules/jsonapi/tests/src/Functional/NodeTest.php index 9330809ec7237197491827fe56807ab3cf251c89..7d5ec95239023e4e738610e55aa2234bd7b59a77 100644 --- a/core/modules/jsonapi/tests/src/Functional/NodeTest.php +++ b/core/modules/jsonapi/tests/src/Functional/NodeTest.php @@ -526,26 +526,4 @@ public function testCollectionFilterAccess() { $this->assertContains('user.node_grants:view', explode(' ', $response->getHeader('X-Drupal-Cache-Contexts')[0])); } - /** - * Tests deprecated entity reference items. - * - * @group legacy - */ - public function testDeprecatedEntityReferenceFieldItem(): void { - \Drupal::service('module_installer')->install(['jsonapi_test_reference_types']); - - $this->setUpAuthorization('GET'); - // @todo Remove line below in favor of commented line in https://www.drupal.org/project/drupal/issues/2878463. - $url = Url::fromRoute(sprintf('jsonapi.%s.individual', static::$resourceTypeName), ['entity' => $this->entity->uuid()]); - // $url = $this->entity->toUrl('jsonapi'); - $query = ['include' => 'deprecated_reference']; - $url->setOption('query', $query); - $request_options = []; - $request_options[RequestOptions::HEADERS]['Accept'] = 'application/vnd.api+json'; - $request_options = NestedArray::mergeDeep($request_options, $this->getAuthenticationRequestOptions()); - - $this->expectDeprecation('Entity reference field items not implementing Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItemInterface is deprecated in drupal:10.2.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3279140'); - $this->request('GET', $url, $request_options); - } - } diff --git a/core/modules/jsonapi/tests/src/Kernel/ResourceType/RelatedResourceTypesTest.php b/core/modules/jsonapi/tests/src/Kernel/ResourceType/RelatedResourceTypesTest.php index 9080ed0bd44146a76347eef03645d2e1831da301..2d4277426888ff61a4a7bb834b0c2f3e1eb9d627 100644 --- a/core/modules/jsonapi/tests/src/Kernel/ResourceType/RelatedResourceTypesTest.php +++ b/core/modules/jsonapi/tests/src/Kernel/ResourceType/RelatedResourceTypesTest.php @@ -222,15 +222,4 @@ public function testGetRelatableResourceTypesFromFieldDefinition() { $this->assertEquals(serialize($arguments), $logged); } - /** - * Test the deprecation error on entity reference fields. - * - * @group legacy - */ - public function testGetRelatableResourceTypesFromFieldDefinitionEntityReferenceFieldDeprecated(): void { - \Drupal::service('module_installer')->install(['jsonapi_test_reference_types']); - $this->expectDeprecation('Entity reference field items not implementing Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItemInterface is deprecated in drupal:10.2.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3279140'); - $this->resourceTypeRepository->all(); - } - } diff --git a/core/modules/serialization/src/Normalizer/ComplexDataNormalizer.php b/core/modules/serialization/src/Normalizer/ComplexDataNormalizer.php index eaa098d2c498a50ed1f8bff45fb632dc6ff58f65..48715335a7026970ae19e1c3f64044ee8cddebb5 100644 --- a/core/modules/serialization/src/Normalizer/ComplexDataNormalizer.php +++ b/core/modules/serialization/src/Normalizer/ComplexDataNormalizer.php @@ -39,15 +39,6 @@ public function normalize($object, $format = NULL, array $context = []): array|s return $attributes; } - /** - * {@inheritdoc} - */ - public function hasCacheableSupportsMethod(): bool { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED); - - return TRUE; - } - /** * {@inheritdoc} */ diff --git a/core/modules/serialization/src/Normalizer/DateTimeNormalizer.php b/core/modules/serialization/src/Normalizer/DateTimeNormalizer.php index 83ffe156fe6e6ebaa5ae5c09016dcc4c19697286..cfbef830bc0a3b8bd9b82ece397775bcd12707e9 100644 --- a/core/modules/serialization/src/Normalizer/DateTimeNormalizer.php +++ b/core/modules/serialization/src/Normalizer/DateTimeNormalizer.php @@ -110,15 +110,6 @@ public function denormalize($data, $class, $format = NULL, array $context = []): throw new UnexpectedValueException(sprintf('The specified date "%s" is not in an accepted format: %s.', $data, $formats)); } - /** - * {@inheritdoc} - */ - public function hasCacheableSupportsMethod(): bool { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED); - - return TRUE; - } - /** * {@inheritdoc} */ diff --git a/core/modules/serialization/src/Normalizer/MarkupNormalizer.php b/core/modules/serialization/src/Normalizer/MarkupNormalizer.php index f7ba6bb1e58d6c34dc3d395ebff2396deab453c5..e3df030735ea8a8eda9e3d4968726a0be7e8e0ed 100644 --- a/core/modules/serialization/src/Normalizer/MarkupNormalizer.php +++ b/core/modules/serialization/src/Normalizer/MarkupNormalizer.php @@ -16,15 +16,6 @@ public function normalize($object, $format = NULL, array $context = []): array|s return (string) $object; } - /** - * {@inheritdoc} - */ - public function hasCacheableSupportsMethod(): bool { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED); - - return TRUE; - } - /** * {@inheritdoc} */ diff --git a/core/modules/serialization/src/Normalizer/NormalizerBase.php b/core/modules/serialization/src/Normalizer/NormalizerBase.php index ff0a13fc1c79527e4ef0946856f7ceebc25aa3ca..f0a1e55691843689ea2924ff61c6ecd37d484e71 100644 --- a/core/modules/serialization/src/Normalizer/NormalizerBase.php +++ b/core/modules/serialization/src/Normalizer/NormalizerBase.php @@ -29,14 +29,7 @@ public function supportsNormalization($data, string $format = NULL, array $conte if (!is_object($data) || !$this->checkFormat($format)) { return FALSE; } - - if (property_exists($this, 'supportedInterfaceOrClass')) { - @trigger_error('Defining ' . static::class . '::supportedInterfaceOrClass property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED); - $supported = (array) $this->supportedInterfaceOrClass; - } - else { - $supported = array_keys($this->getSupportedTypes($format)); - } + $supported = array_keys($this->getSupportedTypes($format)); return (bool) array_filter($supported, function ($name) use ($data) { return $data instanceof $name; @@ -56,13 +49,7 @@ public function supportsDenormalization($data, string $type, string $format = NU return FALSE; } - if (property_exists($this, 'supportedInterfaceOrClass')) { - @trigger_error('Defining ' . static::class . '::supportedInterfaceOrClass property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED); - $supported = (array) $this->supportedInterfaceOrClass; - } - else { - $supported = array_keys($this->getSupportedTypes($format)); - } + $supported = array_keys($this->getSupportedTypes($format)); $subclass_check = function ($name) use ($type) { return (class_exists($name) || interface_exists($name)) && is_subclass_of($type, $name, TRUE); @@ -103,15 +90,6 @@ protected function addCacheableDependency(array $context, $data) { } } - /** - * {@inheritdoc} - */ - public function hasCacheableSupportsMethod(): bool { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED); - - return FALSE; - } - /** * {@inheritdoc} */ diff --git a/core/modules/serialization/src/Normalizer/PrimitiveDataNormalizer.php b/core/modules/serialization/src/Normalizer/PrimitiveDataNormalizer.php index 785104ef1404a928f8080398a72ac254a298b787..a34784953795c3295e220eac0e717efe50066fa4 100644 --- a/core/modules/serialization/src/Normalizer/PrimitiveDataNormalizer.php +++ b/core/modules/serialization/src/Normalizer/PrimitiveDataNormalizer.php @@ -36,15 +36,6 @@ public function normalize($object, $format = NULL, array $context = []): array|s return $object->getValue() === NULL ? NULL : $object->getCastedValue(); } - /** - * {@inheritdoc} - */ - public function hasCacheableSupportsMethod(): bool { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED); - - return TRUE; - } - /** * {@inheritdoc} */ diff --git a/core/modules/serialization/src/Normalizer/TypedDataNormalizer.php b/core/modules/serialization/src/Normalizer/TypedDataNormalizer.php index f0572bb1bf3642e03ccf813e874e6fa0926a5c87..96866b23685856d777bee00f42e662a6d3bcb6db 100644 --- a/core/modules/serialization/src/Normalizer/TypedDataNormalizer.php +++ b/core/modules/serialization/src/Normalizer/TypedDataNormalizer.php @@ -22,15 +22,6 @@ public function normalize($object, $format = NULL, array $context = []): array|s return $value; } - /** - * {@inheritdoc} - */ - public function hasCacheableSupportsMethod(): bool { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED); - - return TRUE; - } - /** * {@inheritdoc} */