From 05ad6de2bc143911750050a1008eb15caa70b2a7 Mon Sep 17 00:00:00 2001 From: Alberto Paderno <22536-avpaderno@users.noreply.drupalcode.org> Date: Thu, 5 Dec 2024 20:30:47 +0000 Subject: [PATCH] Issue #3445394 by arunsahijpal, avpaderno, alexpott, kul.pratap, chandansha, cleavinjosh, marcoscano: Fix the PHP_CodeSniffer issues reported by GitLab CI --- .gitlab-ci.yml | 3 ++- entity_usage.install | 4 ++-- entity_usage.module | 16 +++++++------- entity_usage.post_update.php | 5 +++-- src/Commands/EntityUsageCommands.php | 2 +- src/Controller/ListUsageController.php | 9 +++++--- src/EntityUpdateManager.php | 8 +++---- src/EntityUpdateManagerInterface.php | 8 +++---- src/EntityUsage.php | 5 +++-- src/EntityUsageBatchManager.php | 21 +++++++++++-------- src/EntityUsageInterface.php | 11 +++++++--- src/EntityUsageTrackBase.php | 9 ++++---- src/Form/BatchUpdateForm.php | 2 +- src/Form/EntityUsageSettingsForm.php | 4 ++-- src/Plugin/EntityUsage/Track/BlockField.php | 4 ++-- .../EntityUsage/Track/CkeditorImage.php | 2 +- src/Plugin/EntityUsage/Track/EntityEmbed.php | 2 +- .../EntityUsage/Track/LayoutBuilder.php | 8 +++---- src/Plugin/EntityUsage/Track/LinkIt.php | 2 +- src/Plugin/EntityUsage/Track/MediaEmbed.php | 2 +- .../src/Plugin/Block/DependenciesBlock.php | 1 + .../EntityUsageLayoutBuilderTest.php | 4 ++-- .../ConfigEntityTrackingTest.php | 2 +- .../ConfigurationFormTest.php | 2 +- .../DynamicEntityReferenceTest.php | 2 +- .../EmbeddedContentTest.php | 4 ++-- ...ageLayoutBuilderEntityBrowserBlockTest.php | 8 +++---- .../FunctionalJavascript/IntegrationTest.php | 3 ++- .../ListControllerTest.php | 2 +- .../FunctionalJavascript/ParagraphsTest.php | 6 +++--- .../RevisionsTranslationsTest.php | 4 ++-- .../Kernel/EntityUsageLayoutBuilderTest.php | 2 +- tests/src/Kernel/EntityUsageTest.php | 6 ++++-- 33 files changed, 96 insertions(+), 77 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3504bef..b95e909 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,7 +11,8 @@ variables: OPT_IN_TEST_PREVIOUS_MINOR: 1 OPT_IN_TEST_PREVIOUS_MAJOR: 1 RUN_JOB_UPGRADE_STATUS: '1' - +phpcs: + allow_failure: false # By default, Gitlab CI runs on the default system mysql database, change # this as it won't work for the schema required by entity_usage. # Remove when https://www.drupal.org/project/gitlab_templates/issues/3463044 is diff --git a/entity_usage.install b/entity_usage.install index fb52e1a..80bf3c6 100644 --- a/entity_usage.install +++ b/entity_usage.install @@ -257,7 +257,7 @@ function entity_usage_update_8204(&$sandbox) { $schema->addIndex( 'entity_usage', 'source_entity', - ['source_type','source_id'], + ['source_type', 'source_id'], $spec ); } @@ -265,7 +265,7 @@ function entity_usage_update_8204(&$sandbox) { $schema->addIndex( 'entity_usage', 'source_entity_string', - ['source_type','source_id_string'], + ['source_type', 'source_id_string'], $spec ); } diff --git a/entity_usage.module b/entity_usage.module index 6556436..e4e9873 100644 --- a/entity_usage.module +++ b/entity_usage.module @@ -110,12 +110,14 @@ function entity_usage_form_alter(&$form, FormStateInterface $form_state, $form_i $form['entity_usage_edit_warning'] = [ '#theme' => 'status_messages', '#message_list' => [ - 'warning' => [t('Modifications on this form will affect all <a href="@usage_url" target="_blank">existing usages</a> of this entity.', [ - '@usage_url' => Url::fromRoute('entity_usage.usage_list', [ - 'entity_type' => $entity->getEntityTypeId(), - 'entity_id' => $entity->id(), - ])->toString(), - ])], + 'warning' => [ + t('Modifications on this form will affect all <a href="@usage_url" target="_blank">existing usages</a> of this entity.', [ + '@usage_url' => Url::fromRoute('entity_usage.usage_list', [ + 'entity_type' => $entity->getEntityTypeId(), + 'entity_id' => $entity->id(), + ])->toString(), + ]), + ], ], '#status_headings' => ['warning' => t('Warning message')], '#weight' => -201, @@ -143,7 +145,7 @@ function entity_usage_form_alter(&$form, FormStateInterface $form_state, $form_i 'entity_type' => $entity->getEntityTypeId(), 'entity_id' => $entity->id(), ])->toString(), - ]) + ]), ], ], '#status_headings' => ['warning' => t('Warning message')], diff --git a/entity_usage.post_update.php b/entity_usage.post_update.php index 2149b0b..2721712 100644 --- a/entity_usage.post_update.php +++ b/entity_usage.post_update.php @@ -2,15 +2,16 @@ /** * @file - * hook_post_update_NAME functions for entity_usage module. + * Post update functions for the Entity Usage module. */ use Drupal\Core\Entity\RevisionableStorageInterface; -use Drupal\Core\Url; use Drupal\Core\Site\Settings; +use Drupal\Core\Url; /** * Implements hook_post_update_NAME(). + * * Re-generate entity_usage statistics. */ function entity_usage_post_update_regenerate_2x(&$sandbox) { diff --git a/src/Commands/EntityUsageCommands.php b/src/Commands/EntityUsageCommands.php index f745a00..4fa9d42 100644 --- a/src/Commands/EntityUsageCommands.php +++ b/src/Commands/EntityUsageCommands.php @@ -4,9 +4,9 @@ namespace Drupal\entity_usage\Commands; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\entity_usage\EntityUsageBatchManager; use Drupal\entity_usage\EntityUsageQueueBatchManager; use Drush\Commands\DrushCommands; -use Drupal\entity_usage\EntityUsageBatchManager; /** * Entity Usage drush commands. diff --git a/src/Controller/ListUsageController.php b/src/Controller/ListUsageController.php index afc6439..4aeb3f5 100644 --- a/src/Controller/ListUsageController.php +++ b/src/Controller/ListUsageController.php @@ -2,7 +2,6 @@ namespace Drupal\entity_usage\Controller; -use Drupal\block_content\BlockContentInterface; use Drupal\Core\Access\AccessResult; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Controller\ControllerBase; @@ -13,6 +12,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\RevisionableInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Pager\PagerManagerInterface; +use Drupal\block_content\BlockContentInterface; use Drupal\entity_usage\EntityUsageInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -100,7 +100,7 @@ class ListUsageController extends ControllerBase { * @param \Drupal\entity_usage\EntityUsageInterface $entity_usage * The EntityUsage service. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The config factory service. + * The config factory service. * @param \Drupal\Core\Pager\PagerManagerInterface $pager_manager * The pager manager. */ @@ -143,7 +143,10 @@ class ListUsageController extends ControllerBase { $all_rows = $this->getRows($entity_type, $entity_id); if (empty($all_rows)) { return [ - '#markup' => $this->t('There are no recorded usages for entity of type: @type with id: @id', ['@type' => $entity_type, '@id' => $entity_id]), + '#markup' => $this->t( + 'There are no recorded usages for entity of type: @type with id: @id', + ['@type' => $entity_type, '@id' => $entity_id] + ), ]; } diff --git a/src/EntityUpdateManager.php b/src/EntityUpdateManager.php index ff0ee8f..f565b98 100644 --- a/src/EntityUpdateManager.php +++ b/src/EntityUpdateManager.php @@ -7,7 +7,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\TranslatableInterface; /** - * Class EntityUpdateManager. + * The entity update manager. * * @package Drupal\entity_usage */ @@ -35,7 +35,7 @@ class EntityUpdateManager implements EntityUpdateManagerInterface { protected $config; /** - * EntityUpdateManager constructor. + * Constructs a new \Drupal\entity_usage\EntityUpdateManager object. * * @param \Drupal\entity_usage\EntityUsageInterface $usage_service * The usage tracking service. @@ -140,7 +140,7 @@ class EntityUpdateManager implements EntityUpdateManagerInterface { } /** - * Check if an entity is allowed to be tracked as source. + * Checks if an entity is allowed to be tracked as source. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity object. @@ -163,7 +163,7 @@ class EntityUpdateManager implements EntityUpdateManagerInterface { } /** - * Get the enabled tracking plugins, all plugins are enabled by default. + * Gets the enabled tracking plugins, all plugins are enabled by default. * * @return array<string, \Drupal\entity_usage\EntityUsageTrackInterface> * The enabled plugin instances keyed by plugin ID. diff --git a/src/EntityUpdateManagerInterface.php b/src/EntityUpdateManagerInterface.php index da95849..1385378 100644 --- a/src/EntityUpdateManagerInterface.php +++ b/src/EntityUpdateManagerInterface.php @@ -5,14 +5,14 @@ namespace Drupal\entity_usage; use Drupal\Core\Entity\EntityInterface; /** - * Class EntityUpdateManagerInterface. + * The interface implemented by the entity update manager. * * @package Drupal\entity_usage */ interface EntityUpdateManagerInterface { /** - * Track updates on creation of potential source entities. + * Tracks updates on creation of potential source entities. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity we are dealing with. @@ -20,7 +20,7 @@ interface EntityUpdateManagerInterface { public function trackUpdateOnCreation(EntityInterface $entity); /** - * Track updates on edit / update of potential source entities. + * Tracks updates on edits/updates of potential source entities. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity we are dealing with. @@ -28,7 +28,7 @@ interface EntityUpdateManagerInterface { public function trackUpdateOnEdition(EntityInterface $entity); /** - * Track updates on deletion of entities. + * Tracks updates on deletion of entities. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity we are dealing with. diff --git a/src/EntityUsage.php b/src/EntityUsage.php index adfdf7a..fccbca5 100644 --- a/src/EntityUsage.php +++ b/src/EntityUsage.php @@ -280,8 +280,6 @@ class EntityUsage implements EntityUsageInterface { * Core doesn't support big integers (bigint) for entity reference fields. * Therefore we consider integers with more than 10 digits (big integer) to be * strings. - * @todo: Fix bigint support once fixed in core. More info on #2680571 and - * #2989033. * * @param int|string $value * The value to check. @@ -289,6 +287,9 @@ class EntityUsage implements EntityUsageInterface { * @return bool * TRUE if the value is a numeric integer or a string containing an integer, * FALSE otherwise. + * + * @todo Fix bigint support once fixed in core. More info on #2680571 and + * #2989033. */ protected function isInt($value) { return ((string) (int) $value === (string) $value) && strlen($value) < 11; diff --git a/src/EntityUsageBatchManager.php b/src/EntityUsageBatchManager.php index 0fbf34a..27f6419 100644 --- a/src/EntityUsageBatchManager.php +++ b/src/EntityUsageBatchManager.php @@ -39,15 +39,15 @@ class EntityUsageBatchManager implements LoggerAwareInterface { /** * Recreate the entity usage statistics. * - * @param bool $keep_existing_records - * (optional) If TRUE existing usage records won't be deleted. Defaults to - * FALSE. - * * Generate a batch to recreate the statistics for all entities. * Note that if we force all statistics to be created, there is no need to - * separate them between source / target cases. If all entities are - * going to be re-tracked, tracking all of them as source is enough, because - * there could never be a target without a source. + * separate them between source/target cases. If all entities are going to + * be re-tracked, tracking all of them as source is enough, because there + * could never be a target without a source. + * + * @param bool $keep_existing_records + * (optional) If TRUE, existing usage records won't be deleted. Defaults to + * FALSE. */ public function recreate($keep_existing_records = FALSE) { $batch = $this->generateBatch($keep_existing_records); @@ -83,7 +83,10 @@ class EntityUsageBatchManager implements LoggerAwareInterface { $track_this_entity_type = TRUE; } if ($track_this_entity_type) { - $operations[] = ['\Drupal\entity_usage\EntityUsageBatchManager::updateSourcesBatchWorker', [$entity_type_id, $keep_existing_records]]; + $operations[] = [ + '\Drupal\entity_usage\EntityUsageBatchManager::updateSourcesBatchWorker', + [$entity_type_id, $keep_existing_records], + ]; } } @@ -123,7 +126,7 @@ class EntityUsageBatchManager implements LoggerAwareInterface { $context['sandbox']['progress'] = 0; $context['sandbox']['current_id'] = ''; - if (($id_definition instanceof FieldStorageDefinitionInterface) && $id_definition->getType() === 'integer') { + if (($id_definition instanceof FieldStorageDefinitionInterface) && $id_definition->getType() === 'integer') { $context['sandbox']['current_id'] = -1; } $context['sandbox']['total'] = (int) $entity_storage->getQuery() diff --git a/src/EntityUsageInterface.php b/src/EntityUsageInterface.php index f74639f..ea52b74 100644 --- a/src/EntityUsageInterface.php +++ b/src/EntityUsageInterface.php @@ -160,7 +160,8 @@ interface EntityUsageInterface { * @param \Drupal\Core\Entity\EntityInterface $source_entity * The source entity to check for references. * @param int $vid - * (optional) The revision id to return the references for. Defaults to all revisions. + * (optional) The revision id to return the references for. + * Defaults to all revisions. * * @return array<string, array<int, array<array{method: string, field_name: string, count: string}>>> * A nested array with usage data. The first level is keyed by the type of @@ -194,8 +195,10 @@ interface EntityUsageInterface { * Note that if $include_method is TRUE, the first level is keyed by the * reference method, and the second level will continue as explained above. * - * @deprecated in branch 2.x. + * @deprecated in entity_usage:2.0.0 and is removed from entity_usage:3.0.0. * Use \Drupal\entity_usage\EntityUsageInterface::listSources() instead. + * + * @see https://www.drupal.org/project/entity_usage/issues/3445394 */ public function listUsage(EntityInterface $entity, $include_method = FALSE); @@ -216,8 +219,10 @@ interface EntityUsageInterface { * the second level contains the usage count, which will be summed for all * revisions and translations tracked. * - * @deprecated in branch 2.x. + * @deprecated in entity_usage:2.0.0 and is removed from entity_usage:3.0.0. * Use \Drupal\entity_usage\EntityUsageInterface::listTargets() instead. + * + * @see https://www.drupal.org/project/entity_usage/issues/3445394 */ public function listReferencedEntities(EntityInterface $entity); diff --git a/src/EntityUsageTrackBase.php b/src/EntityUsageTrackBase.php index 179d248..87414df 100644 --- a/src/EntityUsageTrackBase.php +++ b/src/EntityUsageTrackBase.php @@ -2,8 +2,6 @@ namespace Drupal\entity_usage; -use Drupal\Core\StreamWrapper\StreamWrapperInterface; -use Drupal\Core\Url; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityInterface; @@ -14,7 +12,8 @@ use Drupal\Core\Entity\RevisionableInterface; use Drupal\Core\Path\PathValidatorInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\PluginBase; -use Drupal\Core\StreamWrapper\PublicStream; +use Drupal\Core\StreamWrapper\StreamWrapperInterface; +use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -56,7 +55,7 @@ abstract class EntityUsageTrackBase extends PluginBase implements EntityUsageTra * @var \Drupal\Core\Entity\EntityRepositoryInterface */ protected $entityRepository; - + /** * The Drupal Path Validator service. * @@ -272,7 +271,7 @@ abstract class EntityUsageTrackBase extends PluginBase implements EntityUsageTra return $referencing_fields_on_bundle; } - + /** * Process the url to a Url object. * diff --git a/src/Form/BatchUpdateForm.php b/src/Form/BatchUpdateForm.php index d68d82d..81f44ea 100644 --- a/src/Form/BatchUpdateForm.php +++ b/src/Form/BatchUpdateForm.php @@ -2,9 +2,9 @@ namespace Drupal\entity_usage\Form; -use Drupal\entity_usage\EntityUsageBatchManager; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; +use Drupal\entity_usage\EntityUsageBatchManager; use Symfony\Component\DependencyInjection\ContainerInterface; /** diff --git a/src/Form/EntityUsageSettingsForm.php b/src/Form/EntityUsageSettingsForm.php index 712a950..420a70d 100644 --- a/src/Form/EntityUsageSettingsForm.php +++ b/src/Form/EntityUsageSettingsForm.php @@ -233,12 +233,12 @@ class EntityUsageSettingsForm extends ConfigFormBase { $form['edit_warning_message_entity_types']['entity_types'][$entity_type_id]['#states'] = [ 'enabled' => [ ':input[name="track_enabled_target_entity_types[entity_types][' . $entity_type_id . ']"]' => ['checked' => TRUE], - ] + ], ]; $form['delete_warning_message_entity_types']['entity_types'][$entity_type_id]['#states'] = [ 'enabled' => [ ':input[name="track_enabled_target_entity_types[entity_types][' . $entity_type_id . ']"]' => ['checked' => TRUE], - ] + ], ]; } diff --git a/src/Plugin/EntityUsage/Track/BlockField.php b/src/Plugin/EntityUsage/Track/BlockField.php index 0086b20..5170dd7 100644 --- a/src/Plugin/EntityUsage/Track/BlockField.php +++ b/src/Plugin/EntityUsage/Track/BlockField.php @@ -2,9 +2,9 @@ namespace Drupal\entity_usage\Plugin\EntityUsage\Track; -use Drupal\block_content\Plugin\Block\BlockContentBlock; use Drupal\Core\Block\BlockPluginInterface; use Drupal\Core\Field\FieldItemInterface; +use Drupal\block_content\Plugin\Block\BlockContentBlock; use Drupal\entity_usage\EntityUsageTrackBase; /** @@ -34,7 +34,7 @@ class BlockField extends EntityUsageTrackBase { // If there is a view inside this block, track the view entity instead. if ($block_instance->getBaseId() === 'views_block') { - list($view_name, $display_id) = explode('-', $block_instance->getDerivativeId(), 2); + [$view_name, $display_id] = explode('-', $block_instance->getDerivativeId(), 2); // @todo worth trying to track the display id as well? // At this point the view is supposed to exist. Only track it if so. if ($this->entityTypeManager->getStorage('view')->load($view_name)) { diff --git a/src/Plugin/EntityUsage/Track/CkeditorImage.php b/src/Plugin/EntityUsage/Track/CkeditorImage.php index 0c47397..4f39f6c 100644 --- a/src/Plugin/EntityUsage/Track/CkeditorImage.php +++ b/src/Plugin/EntityUsage/Track/CkeditorImage.php @@ -37,7 +37,7 @@ class CkeditorImage extends TextFieldEmbedBase { // when we should record 2. The alternative is to add a lot of complexity // to the update logic of our plugin, to deal with all possible // combinations in the update scenario. - // @TODO Re-evaluate if this is worth the effort and overhead. + // @todo Re-evaluate if this is worth the effort and overhead. $entities[$node->getAttribute('data-entity-uuid')] = $node->getAttribute('data-entity-type'); } return $entities; diff --git a/src/Plugin/EntityUsage/Track/EntityEmbed.php b/src/Plugin/EntityUsage/Track/EntityEmbed.php index a3f0bc5..ad5adce 100644 --- a/src/Plugin/EntityUsage/Track/EntityEmbed.php +++ b/src/Plugin/EntityUsage/Track/EntityEmbed.php @@ -36,7 +36,7 @@ class EntityEmbed extends TextFieldEmbedBase { // when we should record 2. The alternative is to add a lot of complexity // to the update logic of our plugin, to deal with all possible // combinations in the update scenario. - // @TODO Re-evaluate if this is worth the effort and overhead. + // @todo Re-evaluate if this is worth the effort and overhead. $entities[$node->getAttribute('data-entity-uuid')] = $node->getAttribute('data-entity-type'); } return $entities; diff --git a/src/Plugin/EntityUsage/Track/LayoutBuilder.php b/src/Plugin/EntityUsage/Track/LayoutBuilder.php index 85fefd2..e3bdd61 100644 --- a/src/Plugin/EntityUsage/Track/LayoutBuilder.php +++ b/src/Plugin/EntityUsage/Track/LayoutBuilder.php @@ -9,12 +9,12 @@ use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityRepositoryInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Field\FieldItemInterface; +use Drupal\Core\Path\PathValidatorInterface; +use Drupal\Core\StreamWrapper\StreamWrapperInterface; use Drupal\entity_usage\EntityUsageInterface; use Drupal\entity_usage\EntityUsageTrackBase; use Drupal\layout_builder\Plugin\Field\FieldType\LayoutSectionItem; use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\Core\Path\PathValidatorInterface; -use Drupal\Core\StreamWrapper\StreamWrapperInterface; /** * Tracks usage of entities related in Layout Builder layouts. @@ -194,7 +194,7 @@ class LayoutBuilder extends EntityUsageTrackBase { $ids = array_filter($ebbContentIds, function ($item) { // Entity Browser Block stores each entity in "entity_ids" in the format: // "{$entity_type_id}:{$entity_id}". - list($entity_type_id, $entity_id) = explode(":", $item); + [$entity_type_id, $entity_id] = explode(":", $item); $storage = $this->entityTypeManager->getStorage($entity_type_id); if (!$storage) { return FALSE; @@ -236,7 +236,7 @@ class LayoutBuilder extends EntityUsageTrackBase { $ids = array_map(function ($item) { // Content dependencies are stored in the format: // "{$entity_type_id}:{$bundle_id}:{$entity_uuid}". - list($entity_type_id, , $entity_uuid) = explode(':', $item); + [$entity_type_id, , $entity_uuid] = explode(':', $item); if ($entity = $this->entityRepository->loadEntityByUuid($entity_type_id, $entity_uuid)) { return "{$entity_type_id}|{$entity->id()}"; } diff --git a/src/Plugin/EntityUsage/Track/LinkIt.php b/src/Plugin/EntityUsage/Track/LinkIt.php index 49b32fc..0ba551d 100644 --- a/src/Plugin/EntityUsage/Track/LinkIt.php +++ b/src/Plugin/EntityUsage/Track/LinkIt.php @@ -37,7 +37,7 @@ class LinkIt extends TextFieldEmbedBase { // when we should record 2. The alternative is to add a lot of complexity // to the update logic of our plugin, to deal with all possible // combinations in the update scenario. - // @TODO Re-evaluate if this is worth the effort and overhead. + // @todo Re-evaluate if this is worth the effort and overhead. $entities[$node->getAttribute('data-entity-uuid')] = $node->getAttribute('data-entity-type'); } return $entities; diff --git a/src/Plugin/EntityUsage/Track/MediaEmbed.php b/src/Plugin/EntityUsage/Track/MediaEmbed.php index d04bd67..41c267e 100644 --- a/src/Plugin/EntityUsage/Track/MediaEmbed.php +++ b/src/Plugin/EntityUsage/Track/MediaEmbed.php @@ -34,7 +34,7 @@ class MediaEmbed extends TextFieldEmbedBase { // when we should record 2. The alternative is to add a lot of complexity // to the update logic of our plugin, to deal with all possible // combinations in the update scenario. - // @TODO Re-evaluate if this is worth the effort and overhead. + // @todo Re-evaluate if this is worth the effort and overhead. $entities[$node->getAttribute('data-entity-uuid')] = $node->getAttribute('data-entity-type'); } return $entities; diff --git a/tests/modules/entity_usage_test/src/Plugin/Block/DependenciesBlock.php b/tests/modules/entity_usage_test/src/Plugin/Block/DependenciesBlock.php index 75eb9f0..a35004f 100644 --- a/tests/modules/entity_usage_test/src/Plugin/Block/DependenciesBlock.php +++ b/tests/modules/entity_usage_test/src/Plugin/Block/DependenciesBlock.php @@ -42,4 +42,5 @@ class DependenciesBlock extends BlockBase { } return $dependencies; } + } diff --git a/tests/src/Functional/EntityUsageLayoutBuilderTest.php b/tests/src/Functional/EntityUsageLayoutBuilderTest.php index 303c0c0..149a1f4 100644 --- a/tests/src/Functional/EntityUsageLayoutBuilderTest.php +++ b/tests/src/Functional/EntityUsageLayoutBuilderTest.php @@ -2,9 +2,10 @@ namespace Drupal\Tests\entity_usage\Functional; +use Drupal\Core\Url; +use Drupal\Tests\BrowserTestBase; use Drupal\block_content\Entity\BlockContent; use Drupal\block_content\Entity\BlockContentType; -use Drupal\Core\Url; use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; @@ -12,7 +13,6 @@ use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay; use Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage; use Drupal\layout_builder\Section; use Drupal\layout_builder\SectionComponent; -use Drupal\Tests\BrowserTestBase; /** * Tests layout builder usage through Inline Blocks displays in UI. diff --git a/tests/src/FunctionalJavascript/ConfigEntityTrackingTest.php b/tests/src/FunctionalJavascript/ConfigEntityTrackingTest.php index 05bdf91..f0fb508 100644 --- a/tests/src/FunctionalJavascript/ConfigEntityTrackingTest.php +++ b/tests/src/FunctionalJavascript/ConfigEntityTrackingTest.php @@ -2,11 +2,11 @@ namespace Drupal\Tests\entity_usage\FunctionalJavascript; +use Drupal\Tests\entity_usage\Traits\EntityUsageLastEntityQueryTrait; use Drupal\block_content\Entity\BlockContent; use Drupal\block_content\Entity\BlockContentType; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; -use Drupal\Tests\entity_usage\Traits\EntityUsageLastEntityQueryTrait; use Drupal\user\Entity\Role; /** diff --git a/tests/src/FunctionalJavascript/ConfigurationFormTest.php b/tests/src/FunctionalJavascript/ConfigurationFormTest.php index a781752..6eff988 100644 --- a/tests/src/FunctionalJavascript/ConfigurationFormTest.php +++ b/tests/src/FunctionalJavascript/ConfigurationFormTest.php @@ -3,11 +3,11 @@ namespace Drupal\Tests\entity_usage\FunctionalJavascript; use Drupal\Core\Entity\ContentEntityTypeInterface; +use Drupal\Tests\media\Traits\MediaTypeCreationTrait; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; use Drupal\media\Entity\Media; use Drupal\node\Entity\Node; -use Drupal\Tests\media\Traits\MediaTypeCreationTrait; /** * Tests the configuration form. diff --git a/tests/src/FunctionalJavascript/DynamicEntityReferenceTest.php b/tests/src/FunctionalJavascript/DynamicEntityReferenceTest.php index b4ce858..56ecc01 100644 --- a/tests/src/FunctionalJavascript/DynamicEntityReferenceTest.php +++ b/tests/src/FunctionalJavascript/DynamicEntityReferenceTest.php @@ -3,9 +3,9 @@ namespace Drupal\Tests\entity_usage\FunctionalJavascript; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Tests\entity_usage\Traits\EntityUsageLastEntityQueryTrait; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; -use Drupal\Tests\entity_usage\Traits\EntityUsageLastEntityQueryTrait; /** * Tests the integration with the Dynamic Entity Reference module. diff --git a/tests/src/FunctionalJavascript/EmbeddedContentTest.php b/tests/src/FunctionalJavascript/EmbeddedContentTest.php index 50f84f1..6cedbb7 100644 --- a/tests/src/FunctionalJavascript/EmbeddedContentTest.php +++ b/tests/src/FunctionalJavascript/EmbeddedContentTest.php @@ -2,12 +2,12 @@ namespace Drupal\Tests\entity_usage\FunctionalJavascript; +use Drupal\Tests\entity_usage\Traits\EntityUsageLastEntityQueryTrait; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; -use Drupal\node\Entity\Node; -use Drupal\Tests\entity_usage\Traits\EntityUsageLastEntityQueryTrait; use Drupal\file\Entity\File; use Drupal\media\Entity\Media; +use Drupal\node\Entity\Node; /** * Basic functional tests for the usage tracking of embedded content. diff --git a/tests/src/FunctionalJavascript/EntityUsageLayoutBuilderEntityBrowserBlockTest.php b/tests/src/FunctionalJavascript/EntityUsageLayoutBuilderEntityBrowserBlockTest.php index 0a056b3..96d5baf 100644 --- a/tests/src/FunctionalJavascript/EntityUsageLayoutBuilderEntityBrowserBlockTest.php +++ b/tests/src/FunctionalJavascript/EntityUsageLayoutBuilderEntityBrowserBlockTest.php @@ -2,11 +2,11 @@ namespace Drupal\Tests\entity_usage\FunctionalJavascript; +use Drupal\Tests\contextual\FunctionalJavascript\ContextualLinkClickTrait; +use Drupal\Tests\entity_usage\Traits\EntityUsageLastEntityQueryTrait; use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay; use Drupal\node\Entity\Node; use Drupal\node\Entity\NodeType; -use Drupal\Tests\contextual\FunctionalJavascript\ContextualLinkClickTrait; -use Drupal\Tests\entity_usage\Traits\EntityUsageLastEntityQueryTrait; use Drupal\user\Entity\Role; /** @@ -167,7 +167,7 @@ class EntityUsageLayoutBuilderEntityBrowserBlockTest extends EntityUsageJavascri $assert_session->assertWaitOnAjaxRequest(); $this->saveHtmlOutput(); $this->getSession()->switchToIFrame(); - // wait for the table to finish loading. + // Wait for the table to finish loading. $assert_session->waitForElement('css', '#drupal-off-canvas table .entity-browser-block-delta-order'); // Verify we have selected in the block config the node that was created. $assert_session->elementTextContains('css', '#drupal-off-canvas table', 'First target node'); @@ -228,7 +228,7 @@ class EntityUsageLayoutBuilderEntityBrowserBlockTest extends EntityUsageJavascri $assert_session->assertWaitOnAjaxRequest(); $this->saveHtmlOutput(); $this->getSession()->switchToIFrame(); - // wait for the table to finish loading. + // Wait for the table to finish loading. $assert_session->waitForElement('css', '#drupal-off-canvas table .entity-browser-block-delta-order'); $assert_session->elementTextContains('css', '#drupal-off-canvas table', 'Second target node'); $add_block_button = $assert_session->elementExists('css', '#drupal-off-canvas input[value="Add block"]'); diff --git a/tests/src/FunctionalJavascript/IntegrationTest.php b/tests/src/FunctionalJavascript/IntegrationTest.php index 827e4dc..5a342f3 100644 --- a/tests/src/FunctionalJavascript/IntegrationTest.php +++ b/tests/src/FunctionalJavascript/IntegrationTest.php @@ -4,10 +4,10 @@ namespace Drupal\Tests\entity_usage\FunctionalJavascript; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Url; +use Drupal\Tests\entity_usage\Traits\EntityUsageLastEntityQueryTrait; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; use Drupal\link\LinkItemInterface; -use Drupal\Tests\entity_usage\Traits\EntityUsageLastEntityQueryTrait; /** * Basic functional tests for the usage tracking. @@ -469,4 +469,5 @@ class IntegrationTest extends EntityUsageJavascriptTestBase { ]; $this->assertEquals($expected, $usage); } + } diff --git a/tests/src/FunctionalJavascript/ListControllerTest.php b/tests/src/FunctionalJavascript/ListControllerTest.php index 606e735..5080108 100644 --- a/tests/src/FunctionalJavascript/ListControllerTest.php +++ b/tests/src/FunctionalJavascript/ListControllerTest.php @@ -2,9 +2,9 @@ namespace Drupal\Tests\entity_usage\FunctionalJavascript; +use Drupal\Tests\entity_usage\Traits\EntityUsageLastEntityQueryTrait; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\node\Entity\Node; -use Drupal\Tests\entity_usage\Traits\EntityUsageLastEntityQueryTrait; use Drupal\user\Entity\Role; /** diff --git a/tests/src/FunctionalJavascript/ParagraphsTest.php b/tests/src/FunctionalJavascript/ParagraphsTest.php index ee6a27f..e7d31c3 100644 --- a/tests/src/FunctionalJavascript/ParagraphsTest.php +++ b/tests/src/FunctionalJavascript/ParagraphsTest.php @@ -2,12 +2,12 @@ namespace Drupal\Tests\entity_usage\FunctionalJavascript; -use Drupal\field\Entity\FieldConfig; -use Drupal\field\Entity\FieldStorageConfig; -use Drupal\media\Entity\Media; use Drupal\Tests\entity_usage\Traits\EntityUsageLastEntityQueryTrait; use Drupal\Tests\media\Traits\MediaTypeCreationTrait; use Drupal\Tests\paragraphs\FunctionalJavascript\ParagraphsTestBaseTrait; +use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; +use Drupal\media\Entity\Media; use Drupal\user\Entity\Role; /** diff --git a/tests/src/FunctionalJavascript/RevisionsTranslationsTest.php b/tests/src/FunctionalJavascript/RevisionsTranslationsTest.php index 4cebd65..d78d6d1 100644 --- a/tests/src/FunctionalJavascript/RevisionsTranslationsTest.php +++ b/tests/src/FunctionalJavascript/RevisionsTranslationsTest.php @@ -3,10 +3,10 @@ namespace Drupal\Tests\entity_usage\FunctionalJavascript; use Drupal\Core\Entity\RevisionableInterface; +use Drupal\Tests\entity_usage\Traits\EntityUsageLastEntityQueryTrait; use Drupal\entity_test\Entity\EntityTest; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\node\Entity\Node; -use Drupal\Tests\entity_usage\Traits\EntityUsageLastEntityQueryTrait; use Drupal\user\Entity\Role; /** @@ -28,7 +28,7 @@ class RevisionsTranslationsTest extends EntityUsageJavascriptTestBase { 'content_translation', // To test entities which implement RevisionableInterface but do have // revisions. - 'entity_test' + 'entity_test', ]; /** diff --git a/tests/src/Kernel/EntityUsageLayoutBuilderTest.php b/tests/src/Kernel/EntityUsageLayoutBuilderTest.php index 6b60013..e90b036 100644 --- a/tests/src/Kernel/EntityUsageLayoutBuilderTest.php +++ b/tests/src/Kernel/EntityUsageLayoutBuilderTest.php @@ -2,10 +2,10 @@ namespace Drupal\Tests\entity_usage\Kernel; +use Drupal\KernelTests\KernelTestBase; use Drupal\block_content\Entity\BlockContent; use Drupal\block_content\Entity\BlockContentType; use Drupal\entity_test\Entity\EntityTest; -use Drupal\KernelTests\KernelTestBase; use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay; use Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage; use Drupal\layout_builder\Section; diff --git a/tests/src/Kernel/EntityUsageTest.php b/tests/src/Kernel/EntityUsageTest.php index efb5378..6ce4e0a 100644 --- a/tests/src/Kernel/EntityUsageTest.php +++ b/tests/src/Kernel/EntityUsageTest.php @@ -2,13 +2,13 @@ namespace Drupal\Tests\entity_usage\Kernel; -use Drupal\Core\Entity\RevisionableInterface; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Entity\RevisionableInterface; +use Drupal\KernelTests\Core\Entity\EntityKernelTestBase; use Drupal\entity_test\Entity\EntityTest; use Drupal\entity_test\Entity\EntityTestMulRevPub; use Drupal\entity_usage\Events\EntityUsageEvent; use Drupal\entity_usage\Events\Events; -use Drupal\KernelTests\Core\Entity\EntityKernelTestBase; /** * Tests the basic API operations of our tracking service. @@ -259,6 +259,8 @@ class EntityUsageTest extends EntityKernelTestBase { * The source entity. * @param \Drupal\Core\Entity\EntityInterface $target * The target entity. + * @param string $field_name + * The field name. */ protected function insertEntityUsage(EntityInterface $source, EntityInterface $target, string $field_name) { $source_vid = ($source instanceof RevisionableInterface && $source->getRevisionId()) ? $source->getRevisionId() : 0; -- GitLab