diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..da927e0f44d6c87b917596ad3ab0b448ac719a6d --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,25 @@ +include: + ################ + # DrupalCI includes: + # As long as you include this, any future includes added by the Drupal Association will be accessible to your pipelines automatically. + # View these include files at https://git.drupalcode.org/project/gitlab_templates/ + ################ + - project: $_GITLAB_TEMPLATES_REPO + ref: $_GITLAB_TEMPLATES_REF + file: + - '/includes/include.drupalci.main.yml' + - '/includes/include.drupalci.variables.yml' + - '/includes/include.drupalci.workflows.yml' + +################ +# Pipeline configuration variables +# +# These are the variables provided to the Run Pipeline form that a user may want to override. +# +# Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/includes/include.drupalci.variables.yml +################ +variables: + OPT_IN_TEST_PREVIOUS_MAJOR: 1 + OPT_IN_TEST_PREVIOUS_MINOR: 1 + OPT_IN_TEST_NEXT_MINOR: 1 + OPT_IN_TEST_NEXT_MAJOR: 1 diff --git a/composer.json b/composer.json index bf249d258e4d4ead8ac7bccec9fc9a8485d19268..a8292bbeac01a23bf6403265062f7fd6ca7bdf50 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,6 @@ }, "license": "GPL-2.0-or-later", "require": { - "drupal/core": "^9.3 || ^10" + "drupal/core": "^9.3 || ^10 || ^11" } } diff --git a/crop.info.yml b/crop.info.yml index 774f8694e18f61c6f257103a19b08b7f10ba9732..0269e732de8e80661766c1bdb0b924aba90894c1 100644 --- a/crop.info.yml +++ b/crop.info.yml @@ -1,6 +1,6 @@ name: Crop API description: 'Provides storage and API for image crops.' -core_version_requirement: '^9.3 || ^10' +core_version_requirement: '^9.3 || ^10 || ^11' package: Media type: module dependencies: diff --git a/crop.module b/crop.module index aa7d5f8f77a6d2fec8c033eb645774dfc627240e..6ce1395f274f5950928ac911317a578142231119 100644 --- a/crop.module +++ b/crop.module @@ -9,13 +9,12 @@ use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Routing\RouteMatchInterface; +use Drupal\Core\StreamWrapper\StreamWrapperManager; use Drupal\crop\Entity\Crop; -use Drupal\image\Entity\ImageStyle; +use Drupal\file\FileInterface; use Drupal\media\MediaSourceInterface; use Drupal\media\MediaTypeInterface; -use Drupal\file\FileInterface; -use Drupal\Core\Routing\RouteMatchInterface; -use Drupal\Core\StreamWrapper\StreamWrapperManager; /** * Implements hook_theme(). diff --git a/modules/crop_media_entity/crop_media_entity.info.yml b/modules/crop_media_entity/crop_media_entity.info.yml index 70abdbfd93bc4fcea1020448c5e100320f147d32..49b0d919687a96c7e166dd934a8566c413b35ca4 100644 --- a/modules/crop_media_entity/crop_media_entity.info.yml +++ b/modules/crop_media_entity/crop_media_entity.info.yml @@ -1,6 +1,6 @@ name: Media entity crop description: 'Deprecated.' -core_version_requirement: '^9.3 || ^10' +core_version_requirement: '^9.3 || ^10 || ^11' package: Media type: module hidden: true diff --git a/src/CropInterface.php b/src/CropInterface.php index f37c8729bc34cb9d5562f1fca3d73d15f0283c5c..78c185e3613cb49eaa192ed93725a2300fd196a8 100644 --- a/src/CropInterface.php +++ b/src/CropInterface.php @@ -7,6 +7,9 @@ use Drupal\image\ImageStyleInterface; /** * Provides an interface defining the crop entity. + * + * @phpcs:disable Drupal.Commenting.Deprecated.DeprecatedMissingSeeTag + * @phpcs:disable Drupal.Commenting.Deprecated.IncorrectTextLayout */ interface CropInterface extends ContentEntityInterface { diff --git a/src/CropTypeListBuilder.php b/src/CropTypeListBuilder.php index 8c845ee85aaae2aca1eaad5b00bbb93c624736fd..60b4babf6b6f06cecea88912c27f2b088885455d 100644 --- a/src/CropTypeListBuilder.php +++ b/src/CropTypeListBuilder.php @@ -2,15 +2,15 @@ namespace Drupal\crop; +use Drupal\Component\Utility\Xss; use Drupal\Core\Config\Entity\ConfigEntityListBuilder; -use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Core\Entity\EntityTypeInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Routing\UrlGeneratorInterface; -use Drupal\Core\Entity\EntityInterface; -use Drupal\Component\Utility\Xss; use Drupal\image\Entity\ImageStyle; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Defines a class to build a listing of crop type entities. diff --git a/src/Entity/Crop.php b/src/Entity/Crop.php index 9266d13c789182da6eaa7dd0eb9edfbc880ddd04..6bd6b7f4a4158faf94be455e589643f342493d49 100644 --- a/src/Entity/Crop.php +++ b/src/Entity/Crop.php @@ -151,6 +151,7 @@ class Crop extends ContentEntityBase implements CropInterface { * {@inheritdoc} */ public static function getCropFromImageStyle($uri, ImageStyleInterface $image_style) { + //phpcs:ignore Drupal.Semantics.FunctionTriggerError.TriggerErrorTextLayoutRelaxed @trigger_error('Crop::getCropFromImageStyle() is deprecated, use Crop::getCropFromImageStyleId() instead.', E_USER_DEPRECATED); return static::getCropFromImageStyleId($uri, $image_style->id()); } @@ -321,8 +322,8 @@ class Crop extends ContentEntityBase implements CropInterface { // Denormalized information, which is calculated in storage plugin for a // given entity type. Saved here for performance reasons in image effects. - // --- - // TODO - we are not enforcing uniqueness on this as we want to support more + // ---. + // @todo we are not enforcing uniqueness on this as we want to support more // crops per same image/image_style combination. However, image effect // operates with image URI only, which means we have no mechanism to // distinguish between multiple crops in there. If we really want to diff --git a/src/EntityProviderBase.php b/src/EntityProviderBase.php index 0a379a14ae93be3e1ada7296037b6148c6c7e696..114a84b80be75371e28817c608b3b06497b03a15 100644 --- a/src/EntityProviderBase.php +++ b/src/EntityProviderBase.php @@ -14,7 +14,7 @@ abstract class EntityProviderBase extends PluginBase implements EntityProviderIn * {@inheritdoc} */ public function label() { - $this->pluginDefinition['label']; + return $this->pluginDefinition['label']; } /** diff --git a/src/Events/AutomaticCrop.php b/src/Events/AutomaticCrop.php index c0ed87573b0d219aaac4c92511192c259e4ce554..db42d57a9ad0593c65926b3b9728c3becc9443c1 100644 --- a/src/Events/AutomaticCrop.php +++ b/src/Events/AutomaticCrop.php @@ -2,10 +2,10 @@ namespace Drupal\crop\Events; +use Drupal\Component\EventDispatcher\Event; use Drupal\Core\Image\ImageInterface; use Drupal\crop\CropInterface; use Drupal\crop\Entity\CropType; -use Drupal\Component\EventDispatcher\Event; /** * Represents automatic crop action as event. @@ -45,8 +45,11 @@ class AutomaticCrop extends Event { * Constructs a EntitySelectionEvent object. * * @param \Drupal\Core\Image\ImageInterface $image + * An image object. * @param \Drupal\crop\Entity\CropType $cropType - * @param $configuration + * A crop_type object. + * @param array $configuration + * An array of configurations. */ public function __construct(ImageInterface $image, CropType $cropType, array $configuration) { $this->image = $image; diff --git a/src/Form/CropTypeDeleteForm.php b/src/Form/CropTypeDeleteForm.php index 7ad44de7b5363ac49f83735a18f4fed55f58db8a..8a79d7ac7d49923f5c9037d8895230b7d0cfa39d 100644 --- a/src/Form/CropTypeDeleteForm.php +++ b/src/Form/CropTypeDeleteForm.php @@ -3,7 +3,6 @@ namespace Drupal\crop\Form; use Drupal\Core\Entity\EntityConfirmFormBase; -use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\Core\Url; diff --git a/src/Form/CropTypeForm.php b/src/Form/CropTypeForm.php index be8db5244ec568900ba91e386585764dd1db1547..34309ae0aab798b931464de1bcfa3422c5c50e3e 100644 --- a/src/Form/CropTypeForm.php +++ b/src/Form/CropTypeForm.php @@ -179,7 +179,7 @@ class CropTypeForm extends EntityForm { $this->logger('crop')->notice('Added crop type %name.', $context); } - $form_state->setRedirect('crop.overview_types'); + return $form_state->setRedirect('crop.overview_types'); } } diff --git a/src/Plugin/ImageEffect/CropEffect.php b/src/Plugin/ImageEffect/CropEffect.php index af27c8c072ee7190b7dd7fed7349edb39c46f9c6..770664f403e3de3ef35f6a5a3796fade130d664c 100644 --- a/src/Plugin/ImageEffect/CropEffect.php +++ b/src/Plugin/ImageEffect/CropEffect.php @@ -118,12 +118,12 @@ class CropEffect extends ConfigurableImageEffectBase implements ContainerFactory if (!$image->crop($anchor['x'], $anchor['y'], $size['width'], $size['height'])) { $this->logger->error('Manual image crop failed using the %toolkit toolkit on %path (%mimetype, %width x %height)', [ - '%toolkit' => $image->getToolkitId(), - '%path' => $image->getSource(), - '%mimetype' => $image->getMimeType(), - '%width' => $image->getWidth(), - '%height' => $image->getHeight(), - ] + '%toolkit' => $image->getToolkitId(), + '%path' => $image->getSource(), + '%mimetype' => $image->getMimeType(), + '%width' => $image->getWidth(), + '%height' => $image->getHeight(), + ] ); return FALSE; } diff --git a/src/Plugin/Validation/Constraint/CropTypeAspectRatioValidationConstraintValidator.php b/src/Plugin/Validation/Constraint/CropTypeAspectRatioValidationConstraintValidator.php index 4de8d009031fab958fdcbc88d9901f233416bdd0..3221789ef5fc57097cea2c89b578bf4821279008 100644 --- a/src/Plugin/Validation/Constraint/CropTypeAspectRatioValidationConstraintValidator.php +++ b/src/Plugin/Validation/Constraint/CropTypeAspectRatioValidationConstraintValidator.php @@ -10,13 +10,6 @@ use Symfony\Component\Validator\ConstraintValidator; */ class CropTypeAspectRatioValidationConstraintValidator extends ConstraintValidator { - /** - * Validator 2.5 and upwards compatible execution context. - * - * @var \Symfony\Component\Validator\Context\ExecutionContextInterface - */ - protected $context; - /** * {@inheritdoc} */ diff --git a/src/Plugin/Validation/Constraint/CropTypeMachineNameValidationConstraintValidator.php b/src/Plugin/Validation/Constraint/CropTypeMachineNameValidationConstraintValidator.php index 977155d61bc30fb7476189249dc84345c54ef69b..29fb5244a5f510cee36fee87350a7580b78cc626 100644 --- a/src/Plugin/Validation/Constraint/CropTypeMachineNameValidationConstraintValidator.php +++ b/src/Plugin/Validation/Constraint/CropTypeMachineNameValidationConstraintValidator.php @@ -10,13 +10,6 @@ use Symfony\Component\Validator\ConstraintValidator; */ class CropTypeMachineNameValidationConstraintValidator extends ConstraintValidator { - /** - * Validator 2.5 and upwards compatible execution context. - * - * @var \Symfony\Component\Validator\Context\ExecutionContextInterface - */ - protected $context; - /** * {@inheritdoc} */ diff --git a/tests/src/Functional/CropFunctionalTest.php b/tests/src/Functional/CropFunctionalTest.php index 677c5defaea85b58794b31e4f6e465c099354e0b..06ecfd416a2748eabed1e539b6c143db12550c19 100644 --- a/tests/src/Functional/CropFunctionalTest.php +++ b/tests/src/Functional/CropFunctionalTest.php @@ -6,8 +6,8 @@ use Drupal\Core\StreamWrapper\PublicStream; use Drupal\crop\Entity\Crop; use Drupal\crop\Entity\CropType; use Drupal\file\Entity\File; -use Drupal\Tests\BrowserTestBase; use Drupal\file\FileInterface; +use Drupal\Tests\BrowserTestBase; /** * Functional tests for crop API. @@ -77,7 +77,6 @@ class CropFunctionalTest extends BrowserTestBase { $this->drupalGet('admin/config/media/crop/add'); $this->assertSession()->statusCodeEquals(403); - // Can access pages if logged in and no crop types exist. $this->drupalLogin($this->adminUser); $this->drupalGet('admin/config/media/crop'); @@ -90,13 +89,12 @@ class CropFunctionalTest extends BrowserTestBase { $this->assertSession()->statusCodeEquals(200); $this->assertSession()->addressEquals('admin/config/media/crop/add'); - // Create crop type. $crop_type_id = strtolower($this->randomMachineName()); $edit = [ 'id' => $crop_type_id, 'label' => $this->randomMachineName(), - 'description' => $this->randomGenerator->sentences(10), + 'description' => $this->getRandomGenerator()->word(10), ]; $this->drupalGet('admin/config/media/crop/add'); $this->submitForm($edit, 'Save crop type'); @@ -107,7 +105,6 @@ class CropFunctionalTest extends BrowserTestBase { self::assertTrue(strpos($label[0]->getText(), $edit['label']) !== FALSE, 'Crop type label found on listing page.'); $this->assertSession()->pageTextContains($edit['description']); - // Check edit form. $this->clickLink(t('Edit')); $this->assertSession()->pageTextContains(t('Edit @name crop type', ['@name' => $edit['label']])); @@ -116,7 +113,6 @@ class CropFunctionalTest extends BrowserTestBase { $this->assertSession()->fieldExists('edit-label'); $this->assertSession()->responseContains($edit['description']); - // See if crop type appears on image effect configuration form. $this->drupalGet('admin/config/media/image-styles/manage/' . $this->testStyle->id() . '/add/crop_crop'); $option = $this->xpath("//select[@id='edit-data-crop-type']/option"); @@ -145,7 +141,6 @@ class CropFunctionalTest extends BrowserTestBase { $this->submitForm($edit, 'Save crop type'); $this->assertSession()->pageTextContains(t('The machine-readable name is already in use. It must be unique.')); - // Delete crop type. $this->drupalGet('admin/config/media/crop'); $this->assertSession()->linkExists('Test image style'); diff --git a/tests/src/Kernel/CropCRUDTest.php b/tests/src/Kernel/CropCRUDTest.php index aa69839355d9cb0d2c8a29d2d2368fdd614cd2c7..2d2f7bbf44882ef2938f075125b01e091427c745 100644 --- a/tests/src/Kernel/CropCRUDTest.php +++ b/tests/src/Kernel/CropCRUDTest.php @@ -26,7 +26,7 @@ class CropCRUDTest extends CropUnitTestBase { $values = [ 'id' => $this->randomMachineName(), 'label' => $this->randomString(), - 'description' => $this->randomGenerator->sentences(8), + 'description' => $this->getRandomGenerator()->word(8), ]; $crop_type = $this->cropTypeStorage->create($values); diff --git a/tests/src/Kernel/CropEffectTest.php b/tests/src/Kernel/CropEffectTest.php index fca6575a780beed3a789c13676bfb4ca299e804f..702071e4d1ae0a1ebc5ffb2dffff1bf268c8929e 100644 --- a/tests/src/Kernel/CropEffectTest.php +++ b/tests/src/Kernel/CropEffectTest.php @@ -65,7 +65,7 @@ class CropEffectTest extends CropUnitTestBase { /** * Test image crop effect dimensions. */ - public function testCropDimenssions() { + public function testCropDimensions() { // Create image to be cropped. $file = $this->getTestFile(); $file->save(); @@ -88,7 +88,7 @@ class CropEffectTest extends CropUnitTestBase { $crop = $this->container->get('entity_type.manager')->getStorage('crop')->create($values); $crop->save(); - /** @var $effect \Drupal\crop\Plugin\ImageEffect\CropEffect */ + /** @var \Drupal\crop\Plugin\ImageEffect\CropEffect $effect */ $effect = $this->imageEffectManager->createInstance('crop_crop', ['data' => ['crop_type' => $this->cropType->id()]]); $effect->transformDimensions($dimensions, $file_uri); diff --git a/tests/src/Kernel/CropUnitTestBase.php b/tests/src/Kernel/CropUnitTestBase.php index 82487a36018b01e72d74f902a315b9ba3bb391b9..7ceb824f7d343f8bd79ad1f167fa330726788102 100644 --- a/tests/src/Kernel/CropUnitTestBase.php +++ b/tests/src/Kernel/CropUnitTestBase.php @@ -3,8 +3,8 @@ namespace Drupal\Tests\crop\Kernel; use Drupal\Core\StreamWrapper\PublicStream; -use Drupal\KernelTests\KernelTestBase; use Drupal\file\FileInterface; +use Drupal\KernelTests\KernelTestBase; /** * Tests the crop entity CRUD operations.