Skip to content
Snippets Groups Projects
Commit 19dc7336 authored by Andrey Tymchuk's avatar Andrey Tymchuk Committed by A.Tymchuk
Browse files

Issue #3487526 by walkingdexter: Use AutowireTrait where possible

parent c4c00c84
No related branches found
No related tags found
No related merge requests found
Pipeline #338849 passed
Showing with 21 additions and 171 deletions
......@@ -4,7 +4,6 @@ namespace Drupal\simple_sitemap_engines\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\simple_sitemap_engines\Submitter\IndexNowSubmitter;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
......@@ -31,15 +30,6 @@ class IndexNowController extends ControllerBase {
$this->submitter = $submitter;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container): IndexNowController {
return new static(
$container->get('simple_sitemap.engines.index_now_submitter')
);
}
/**
* Return dynamically created text file content.
*
......
......@@ -4,7 +4,8 @@ namespace Drupal\simple_sitemap_engines\Form;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\DependencyInjection\AutowireTrait;
use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\ConfigFormBase;
......@@ -16,13 +17,14 @@ use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Url;
use Drupal\simple_sitemap\Entity\SimpleSitemap;
use Drupal\simple_sitemap_engines\Entity\SimpleSitemapEngine;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Form for managing search engine submission settings.
*/
class SimplesitemapEnginesForm extends ConfigFormBase {
use AutowireTrait;
/**
* The entity type manager service.
*
......@@ -40,7 +42,7 @@ class SimplesitemapEnginesForm extends ConfigFormBase {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\DateFormatter
* @var \Drupal\Core\Datetime\DateFormatterInterface
*/
protected $dateFormatter;
......@@ -62,7 +64,7 @@ class SimplesitemapEnginesForm extends ConfigFormBase {
* The entity type manager service.
* @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
* The entity field manager.
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
* The date formatter service.
* @param \Drupal\Core\State\StateInterface $state
* The state service.
......@@ -72,7 +74,7 @@ class SimplesitemapEnginesForm extends ConfigFormBase {
TypedConfigManagerInterface $typedConfigManager,
EntityTypeManagerInterface $entity_type_manager,
EntityFieldManagerInterface $entity_field_manager,
DateFormatter $date_formatter,
DateFormatterInterface $date_formatter,
StateInterface $state,
) {
parent::__construct($config_factory, $typedConfigManager);
......@@ -82,20 +84,6 @@ class SimplesitemapEnginesForm extends ConfigFormBase {
$this->state = $state;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
$container->get('config.typed'),
$container->get('entity_type.manager'),
$container->get('entity_field.manager'),
$container->get('date.formatter'),
$container->get('state')
);
}
/**
* {@inheritdoc}
*/
......
......@@ -5,7 +5,6 @@ namespace Drupal\simple_sitemap_views\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Url;
use Drupal\simple_sitemap_views\SimpleSitemapViews;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Controller for Simple XML Sitemap Views admin page.
......@@ -29,15 +28,6 @@ class SimpleSitemapViewsController extends ControllerBase {
$this->sitemapViews = $sitemap_views;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container): SimpleSitemapViewsController {
return new static(
$container->get('simple_sitemap.views')
);
}
/**
* Builds a listing of indexed views displays.
*
......
......@@ -7,7 +7,6 @@ use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableResponse;
use Drupal\Core\Controller\ControllerBase;
use Drupal\simple_sitemap\Manager\Generator;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
......@@ -34,15 +33,6 @@ class SimpleSitemapController extends ControllerBase {
$this->generator = $generator;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container): SimpleSitemapController {
return new static(
$container->get('simple_sitemap.generator')
);
}
/**
* Returns a specific sitemap, its chunk, or its index.
*
......
......@@ -8,7 +8,6 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Path\PathValidatorInterface;
use Drupal\simple_sitemap\Manager\Generator;
use Drupal\simple_sitemap\Settings;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides form to manage custom links.
......@@ -56,20 +55,6 @@ class CustomLinksForm extends SimpleSitemapFormBase {
$this->pathValidator = $path_validator;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
$container->get('config.typed'),
$container->get('simple_sitemap.generator'),
$container->get('simple_sitemap.settings'),
$container->get('simple_sitemap.form_helper'),
$container->get('path.validator')
);
}
/**
* {@inheritdoc}
*/
......
......@@ -11,7 +11,6 @@ use Drupal\simple_sitemap\Entity\SimpleSitemap;
use Drupal\simple_sitemap\Manager\EntityManager;
use Drupal\simple_sitemap\Manager\Generator;
use Drupal\simple_sitemap\Settings;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides form to manage entity settings.
......@@ -70,21 +69,6 @@ class EntitiesForm extends SimpleSitemapFormBase {
$this->entityManager = $entity_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
$container->get('config.typed'),
$container->get('simple_sitemap.generator'),
$container->get('simple_sitemap.settings'),
$container->get('simple_sitemap.form_helper'),
$container->get('simple_sitemap.entity_helper'),
$container->get('simple_sitemap.entity_manager')
);
}
/**
* {@inheritdoc}
*/
......
......@@ -10,7 +10,6 @@ use Drupal\simple_sitemap\Entity\EntityHelper;
use Drupal\simple_sitemap\Manager\EntityManager;
use Drupal\simple_sitemap\Manager\Generator;
use Drupal\simple_sitemap\Settings;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
......@@ -81,22 +80,6 @@ class EntityBundlesForm extends SimpleSitemapFormBase {
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
$container->get('config.typed'),
$container->get('simple_sitemap.generator'),
$container->get('simple_sitemap.settings'),
$container->get('simple_sitemap.form_helper'),
$container->get('simple_sitemap.entity_helper'),
$container->get('simple_sitemap.entity_manager'),
$container->get('entity_type.manager')
);
}
/**
* {@inheritdoc}
*/
......
......@@ -405,7 +405,7 @@ class FormHelper {
* Cron intervals.
*/
public static function getCronIntervalOptions(): array {
/** @var \Drupal\Core\Datetime\DateFormatter $formatter */
/** @var \Drupal\Core\Datetime\DateFormatterInterface $formatter */
$formatter = \Drupal::service('date.formatter');
$intervals = array_flip(static::$cronIntervals);
foreach ($intervals as $interval => &$label) {
......
......@@ -11,7 +11,6 @@ use Drupal\Core\Url;
use Drupal\simple_sitemap\Entity\SimpleSitemap;
use Drupal\simple_sitemap\Manager\Generator;
use Drupal\simple_sitemap\Settings;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides form to manage settings.
......@@ -59,20 +58,6 @@ class SettingsForm extends SimpleSitemapFormBase {
$this->languageManager = $language_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
$container->get('config.typed'),
$container->get('simple_sitemap.generator'),
$container->get('simple_sitemap.settings'),
$container->get('simple_sitemap.form_helper'),
$container->get('language_manager')
);
}
/**
* {@inheritdoc}
*/
......
......@@ -2,19 +2,21 @@
namespace Drupal\simple_sitemap\Form;
use Drupal\Core\DependencyInjection\AutowireTrait;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\simple_sitemap\Entity\SimpleSitemapType;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Form handler for sitemap edit forms.
*/
class SimpleSitemapEntityForm extends EntityForm {
use AutowireTrait;
/**
* The entity being used by this form.
*
......@@ -29,15 +31,6 @@ class SimpleSitemapEntityForm extends EntityForm {
*/
protected $entityTypeManager;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity_type.manager')
);
}
/**
* SimpleSitemapEntityForm constructor.
*
......
......@@ -4,17 +4,19 @@ namespace Drupal\simple_sitemap\Form;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\DependencyInjection\AutowireTrait;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\simple_sitemap\Manager\Generator;
use Drupal\simple_sitemap\Settings;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Base class for Simple XML Sitemap forms.
*/
abstract class SimpleSitemapFormBase extends ConfigFormBase {
use AutowireTrait;
/**
* The sitemap generator service.
*
......@@ -64,19 +66,6 @@ abstract class SimpleSitemapFormBase extends ConfigFormBase {
parent::__construct($config_factory, $typedConfigManager);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
$container->get('config.typed'),
$container->get('simple_sitemap.generator'),
$container->get('simple_sitemap.settings'),
$container->get('simple_sitemap.form_helper')
);
}
/**
* {@inheritdoc}
*/
......
......@@ -2,19 +2,21 @@
namespace Drupal\simple_sitemap\Form;
use Drupal\Core\DependencyInjection\AutowireTrait;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator\SitemapGeneratorManager;
use Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator\UrlGeneratorManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Form handler for sitemap type edit forms.
*/
class SimpleSitemapTypeEntityForm extends EntityForm {
use AutowireTrait;
/**
* The entity being used by this form.
*
......@@ -43,17 +45,6 @@ class SimpleSitemapTypeEntityForm extends EntityForm {
*/
protected $urlGeneratorManager;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity_type.manager'),
$container->get('plugin.manager.simple_sitemap.sitemap_generator'),
$container->get('plugin.manager.simple_sitemap.url_generator')
);
}
/**
* SimpleSitemapTypeEntityForm constructor.
*
......
......@@ -5,13 +5,12 @@ namespace Drupal\simple_sitemap\Form;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Database\Connection;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\RendererInterface;
use Drupal\simple_sitemap\Manager\Generator as SimplesitemapOld;
use Drupal\simple_sitemap\Queue\QueueWorker;
use Drupal\simple_sitemap\Settings;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides form to manage sitemap status.
......@@ -28,7 +27,7 @@ class StatusForm extends SimpleSitemapFormBase {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\DateFormatter
* @var \Drupal\Core\Datetime\DateFormatterInterface
*/
protected $dateFormatter;
......@@ -61,7 +60,7 @@ class StatusForm extends SimpleSitemapFormBase {
* Helper class for working with forms.
* @param \Drupal\Core\Database\Connection $database
* The database connection.
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
* The date formatter service.
* @param \Drupal\simple_sitemap\Queue\QueueWorker $queue_worker
* The simple_sitemap.queue_worker service.
......@@ -75,7 +74,7 @@ class StatusForm extends SimpleSitemapFormBase {
Settings $settings,
FormHelper $form_helper,
Connection $database,
DateFormatter $date_formatter,
DateFormatterInterface $date_formatter,
QueueWorker $queue_worker,
RendererInterface $renderer,
) {
......@@ -92,23 +91,6 @@ class StatusForm extends SimpleSitemapFormBase {
$this->renderer = $renderer;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
$container->get('config.typed'),
$container->get('simple_sitemap.generator'),
$container->get('simple_sitemap.settings'),
$container->get('simple_sitemap.form_helper'),
$container->get('database'),
$container->get('date.formatter'),
$container->get('simple_sitemap.queue_worker'),
$container->get('renderer')
);
}
/**
* {@inheritdoc}
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment