diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3504bef450ab0b41ccdbd76cc3cca567248e300d..b95e909772ecaca6ced610a1fb3ac6476d30d09e 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 fb52e1ae741c9272e56a13427f6e85f37105c049..80bf3c6ff1347f5c7a52f3838ffd9ee7c1004ac2 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 6556436b72f4b287a61fb1bb9e10825c8e1aa555..e4e9873f3500d16182e6b96d05311175a718a256 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 2149b0b019ea378176c57d3307ad9ec450b2bd57..2721712d30ada24d584132820f15ed9525b4d720 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 f745a00fd9121f1d8b76c81a78b7de44b2ccf838..4fa9d42d361a497962814698b4d4d0924991500d 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 afc643981322e47ff85eecd891e4be480a0a0d66..4aeb3f590e8ecf71520b91a195dd2dc3b239da93 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 ff0ee8f23431c622f025e053a0108d99ee837bb9..f565b9887bb004cf21f6ab2df83760e054069467 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 da958492ffcbbcb5656b0822f9b837e53623ba6a..1385378470b9a0a2510137439f2bd16c7d147096 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 adfdf7aa31c6f969aca178d6dfb48ac974c2c286..fccbca54e7b315e6d3ebe0d421ace7fb4a03e11d 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 0fbf34a4a9d917b4325e7a3fd302263ef9914ae5..27f6419579b5601dcea17bd0e6a803ab0140c8eb 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 f74639f3bc6666d2a05b06d45d361eaf02f378ee..ea52b74fc36ca37d89dc33277fa48cb2b8a3b145 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 179d248657a6067e7413652b62bca8648a0a9234..87414dff9dd8768cf4cc55b240fcf14ecce7e2c9 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 d68d82d4824c8e3ccab460e18308371792c024b1..81f44ea1cd0a7810929cbfe667d5d19f10b7ede1 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 712a9509f7223cf8ec5d6e7d69cec36daafbbdc5..420a70d54b5be91793527fdf6dbc37f686efdd60 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 0086b2017ca889f5aca62bd269fd59cf09921c2f..5170dd7b6b5db5db674497d739f418262ecabd49 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 0c473970e7205dea52bb9be2136536835fd6431b..4f39f6c712df80f522f7d6fe29083ec41d0784ea 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 a3f0bc55792cc474068d1ddb7217f0a57eec48af..ad5adceaaa81aea5aa4475845c038bf15d069d56 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 85fefd203ff53efb63b81f3382c7481645e5a398..e3bdd61e0e3417ba0c8dee1ca629d34497bfb2f7 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 49b32fcf909fc1111ceb15793b8ea8057404759a..0ba551d8e90524104ce1db2c61f593cd3b513f67 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 d04bd67866587da02fc30b79fa33b52cc5e0439f..41c267e78cd99bc95bf1d75d8fcabd68b8b8d182 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 75eb9f05a2d6aba9a39230ae8874a0f47b533621..a35004f48531b5a9ddacead5fce62377e3bb0ba3 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 303c0c0bf04d6cf6345fcf5b3e780dda8a79cf0c..149a1f492d6e9d449b373fa52440861031f9a868 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 05bdf91334b4992b5e29e7f45fe59c0ff088a0a5..f0fb508cd529ffd4efab2729d6c08229900e9b94 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 a781752add9cf852d13252ff29324cb18ed91785..6eff98875c7e31455ce9d2236c6e0b07a20538cb 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 b4ce858a10a514206a5f691e1dbaa1733038ffea..56ecc01775eb8744d7e89f0e6a8cad8adc0e1907 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 50f84f1737d6733018a96a5a500d6699f1ce252d..6cedbb761f7d771a0d88770d1873ecccba213d19 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 0a056b3d63b05b7379f39f14a7c69492733502ce..96d5bafaec092e2ab8b634b27d23de9d39262190 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 827e4dcb881c50278d71771fd21db8b33b26e6df..5a342f37ce1b59dd0b76912416df1ccb1723a720 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 606e73533a1d3b5852898eef0eee3564e7ad1d23..508010826b9407548add2a25a807dc3cd9414ee4 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 ee6a27f9bf762be30c46114a3e349c993be3db68..e7d31c3b8bc10a59e8a54d0dba93d767a19f293e 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 4cebd65c322351d8669333224a06739fc1918873..d78d6d17461a126a4d6ed6b7ea3a5eee947b709c 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 6b6001331c3f2319ee7683ff3a31a62f843cfd95..e90b0366181238396f29a1e11322200236ce28e7 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 efb5378688fc30b6e4d6219a6ddba7c2cd540a32..6ce4e0ae2ff80c0680264ab55f8fe7bc558eb848 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;