diff --git a/phpstan.neon b/phpstan.neon index 48d0f50e7e870d64ea84a77f6ed66ab64f7af554..79e62569e68d80eb370ae21c80c365a1263cc501 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -67,34 +67,3 @@ parameters: paths: - tests/src/Kernel/CoreNotUpdatedValidatorTest.php reportUnmatched: false - - # @todo: Remove the following rules when support is dropped for Drupal 10.2, which does not have recipes. - - - message: "#^Access to constant COMPOSER_PROJECT_TYPE on an unknown class Drupal\\\\Core\\\\Recipe\\\\Recipe\\.$#" - paths: - - src/Plugin/ProjectBrowserSource/Recipes.php - - src/Activator/RecipeActivator.php - - tests/src/Kernel/RecipesSourceTest.php - reportUnmatched: false - - - message: "#^Call to static method [a-zA-Z]+\\(\\) on an unknown class Drupal\\\\Core\\\\Recipe\\\\Recipe[a-zA-Z]*\\.$#" - path: src/Activator/RecipeActivator.php - reportUnmatched: false - - - message: "#^Class Drupal\\\\Core\\\\Recipe\\\\RecipeAppliedEvent not found\\.$#" - path: src/Activator/RecipeActivator.php - reportUnmatched: false - - - message: "#^Parameter \\$event of method Drupal\\\\project_browser\\\\Activator\\\\RecipeActivator\\:\\:onApply\\(\\) has invalid type Drupal\\\\Core\\\\Recipe\\\\RecipeAppliedEvent\\.$#" - path: src/Activator/RecipeActivator.php - reportUnmatched: false - - - - message: "#^Call to static method createFromDirectory\\(\\) on an unknown class Drupal\\\\Core\\\\Recipe\\\\Recipe\\.$#" - path: tests/src/Kernel/RecipeActivatorTest.php - reportUnmatched: false - - - - message: "#^Call to static method processRecipe\\(\\) on an unknown class Drupal\\\\Core\\\\Recipe\\\\RecipeRunner\\.$#" - path: tests/src/Kernel/RecipeActivatorTest.php - reportUnmatched: false diff --git a/project_browser.info.yml b/project_browser.info.yml index d0f4aad7f288b5d7cf577c479d6186a053afc7c5..57dc124901ddf5678bbdcd4b2b4255269a0b732b 100644 --- a/project_browser.info.yml +++ b/project_browser.info.yml @@ -1,5 +1,5 @@ name: Project Browser type: module description: Provides a user interface for browsing available Drupal projects. -core_version_requirement: ^10 || ^11 +core_version_requirement: ^10.3 || ^11 configure: project_browser.settings diff --git a/project_browser.services.yml b/project_browser.services.yml index aa19f8e83418255af608b33dc7c23c9cb9b50209..4e2e42215233b7bccbd3109191c28ffd8e2ec63b 100644 --- a/project_browser.services.yml +++ b/project_browser.services.yml @@ -27,6 +27,12 @@ services: public: false tags: - { name: project_browser.activator } + Drupal\project_browser\Activator\RecipeActivator: + arguments: + '$appRoot': '%app.root%' + tags: + - { name: project_browser.activator } + - { name: event_subscriber } Drupal\project_browser\Routing\ProjectEnhancer: public: false tags: diff --git a/src/Controller/InstallerController.php b/src/Controller/InstallerController.php index 1e717e4ed89543b4b61de34396c966e0058006f1..63de1704249e36746facede51c379d91c7606969 100644 --- a/src/Controller/InstallerController.php +++ b/src/Controller/InstallerController.php @@ -3,7 +3,6 @@ namespace Drupal\project_browser\Controller; use Drupal\Component\Datetime\TimeInterface; -use Drupal\Component\Utility\DeprecationHelper; use Drupal\Core\Access\AccessResult; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Url; @@ -225,15 +224,8 @@ final class InstallerController extends ControllerBase { ]; $generated_url->applyTo($url_with_csrf_token_placeholder); - $renderer = \Drupal::service('renderer'); - $output = DeprecationHelper::backwardsCompatibleCall( - currentVersion: \Drupal::VERSION, - deprecatedVersion: '10.3', - currentCallable: fn() => $renderer->renderInIsolation($url_with_csrf_token_placeholder), - deprecatedCallable: fn() => $renderer->renderPlain($url_with_csrf_token_placeholder), - ); - - return (string) $output; + return (string) \Drupal::service('renderer') + ->renderInIsolation($url_with_csrf_token_placeholder); } /** diff --git a/src/Element/ProjectBrowser.php b/src/Element/ProjectBrowser.php index 254d547618533c20dd38c9ee5a726931fd49cc88..7ef1973da2aa0bfd5cc426b722131c52d79adecd 100644 --- a/src/Element/ProjectBrowser.php +++ b/src/Element/ProjectBrowser.php @@ -2,7 +2,6 @@ namespace Drupal\project_browser\Element; -use Drupal\Component\Utility\DeprecationHelper; use Drupal\Component\Uuid\UuidInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\DependencyInjection\DependencySerializationTrait; @@ -10,7 +9,6 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Path\CurrentPathStack; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Render\Attribute\RenderElement; -use Drupal\Core\Render\Element; use Drupal\Core\Render\Element\ElementInterface; use Drupal\Core\Render\Element\RenderElementBase; use Drupal\project_browser\Plugin\ProjectBrowserSourceInterface; @@ -144,12 +142,7 @@ final class ProjectBrowser implements ElementInterface, ContainerFactoryPluginIn * {@inheritdoc} */ public static function setAttributes(&$element, $class = []): void { - DeprecationHelper::backwardsCompatibleCall( - \Drupal::VERSION, - '10.3', - static fn () => RenderElementBase::setAttributes($element, $class), - static fn () => Element::setAttributes($element, $class) - ); + RenderElementBase::setAttributes($element, $class); } } diff --git a/src/ProjectBrowserServiceProvider.php b/src/ProjectBrowserServiceProvider.php index c833a3c1fb5138cb47f4ca3d0bfdf790fbb4e641..7d3bc3c73022496eba0e8c44264e92efc3cf71c6 100644 --- a/src/ProjectBrowserServiceProvider.php +++ b/src/ProjectBrowserServiceProvider.php @@ -2,24 +2,11 @@ namespace Drupal\project_browser; -use Drupal\Core\Config\ConfigFactoryInterface; -use Drupal\Core\Database\Connection; use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\DependencyInjection\ServiceProviderBase; -use Drupal\Core\Extension\ModuleExtensionList; -use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Extension\ThemeExtensionList; -use Drupal\Core\PrivateKey; -use Drupal\Core\Queue\QueueFactory; -use Drupal\Core\Queue\QueueInterface; -use Drupal\Core\Recipe\Recipe; -use Drupal\Core\State\StateInterface; -use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface; -use Drupal\project_browser\Activator\RecipeActivator; use Drupal\project_browser\ComposerInstaller\Installer; use Drupal\project_browser\ComposerInstaller\Validator\CoreNotUpdatedValidator; use Drupal\project_browser\ComposerInstaller\Validator\PackageNotInstalledValidator; -use Symfony\Component\DependencyInjection\Parameter; use Symfony\Component\DependencyInjection\Reference; /** @@ -50,35 +37,6 @@ class ProjectBrowserServiceProvider extends ServiceProviderBase { ->addTag('event_subscriber') ->setAutowired(TRUE); } - - if (class_exists(Recipe::class)) { - $container->register(RecipeActivator::class, RecipeActivator::class) - ->setAutowired(TRUE) - ->setArgument('$appRoot', new Parameter('app.root')) - ->addTag('project_browser.activator') - // Because it's an event subscriber, the activator needs to be public. - ->addTag('event_subscriber'); - } - - // @todo Remove the following Drupal 10.0 autowiring shim in - // https://www.drupal.org/i/3349193. - $autowire_aliases = [ - ConfigFactoryInterface::class => 'config.factory', - QueueInterface::class => 'queue', - ModuleHandlerInterface::class => 'module_handler', - StateInterface::class => 'state', - ModuleExtensionList::class => 'extension.list.module', - ThemeExtensionList::class => 'extension.list.theme', - StreamWrapperManagerInterface::class => 'stream_wrapper_manager', - Connection::class => 'database', - QueueFactory::class => 'queue', - PrivateKey::class => 'private_key', - ]; - foreach ($autowire_aliases as $interface => $service_id) { - if (!$container->hasAlias($interface)) { - $container->setAlias($interface, $service_id); - } - } } }