diff --git a/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php b/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php index ef05717..8377958 100644 --- a/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php +++ b/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php @@ -16,13 +16,6 @@ abstract class EntityConfirmFormBase extends EntityFormController implements ConfirmFormInterface { /** - * The request object. - * - * @var \Symfony\Component\HttpFoundation\Request - */ - protected $request; - - /** * {@inheritdoc} */ public function getBaseFormID() { @@ -60,8 +53,7 @@ public function getFormName() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Request $request = NULL) { - $this->request = $request; + public function buildForm(array $form, array &$form_state) { $form = parent::buildForm($form, $form_state); $form['#attributes']['class'][] = 'confirmation'; @@ -94,8 +86,8 @@ protected function actions(array $form, array &$form_state) { $path = $this->getCancelPath(); // Prepare cancel link. - if ($this->request->query->has('destination')) { - $options = drupal_parse_url($this->request->query->get('destination')); + if ($this->getRequest()->query->has('destination')) { + $options = drupal_parse_url($this->getRequest()->query->get('destination')); } elseif (is_array($path)) { $options = $path; diff --git a/core/lib/Drupal/Core/Entity/EntityFormController.php b/core/lib/Drupal/Core/Entity/EntityFormController.php index ceb09de..a008f90 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormController.php +++ b/core/lib/Drupal/Core/Entity/EntityFormController.php @@ -7,6 +7,8 @@ namespace Drupal\Core\Entity; +use Drupal\Core\Form\FormBase; +use Drupal\Core\StringTranslation\Translator\TranslatorInterface; use Drupal\entity\EntityFormDisplayInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\Language; @@ -15,7 +17,7 @@ /** * Base class for entity form controllers. */ -class EntityFormController implements EntityFormControllerInterface { +class EntityFormController extends FormBase implements EntityFormControllerInterface { /** * The name of the current operation. @@ -42,35 +44,14 @@ class EntityFormController implements EntityFormControllerInterface { protected $entity; /** - * Constructs an EntityFormController object. - * - * @param \Drupal\Core\Extension\ModuleHandlerInterface - * The module handler service. - */ - public function __construct(ModuleHandlerInterface $module_handler) { - $this->moduleHandler = $module_handler; - } - - /** * {@inheritdoc} */ - public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { - return new static( - $container->get('module_handler') - ); - } - - /** - * Sets the operation for this form. - * - * @param string $operation - * The name of the current operation. - */ public function setOperation($operation) { // If NULL is passed, do not overwrite the operation. if ($operation) { $this->operation = $operation; } + return $this; } /** @@ -129,12 +110,6 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { - } - - /** - * {@inheritdoc} - */ public function submitForm(array &$form, array &$form_state) { } @@ -269,7 +244,7 @@ protected function actions(array $form, array &$form_state) { return array( // @todo Rename the action key from submit to save. 'submit' => array( - '#value' => t('Save'), + '#value' => $this->t('Save'), '#validate' => array( array($this, 'validate'), ), @@ -279,7 +254,7 @@ protected function actions(array $form, array &$form_state) { ), ), 'delete' => array( - '#value' => t('Delete'), + '#value' => $this->t('Delete'), // No need to validate the form when deleting the entity. '#submit' => array( array($this, 'delete'), @@ -566,4 +541,21 @@ public function setFormDisplay(EntityFormDisplayInterface $form_display, array & public function getOperation() { return $this->operation; } + + /** + * {@inheritdoc} + */ + public function setTranslationManager(TranslatorInterface $translation_manager) { + $this->translationManager = $translation_manager; + return $this; + } + + /** + * {@inheritdoc} + */ + public function setModuleHandler(ModuleHandlerInterface $module_handler) { + $this->moduleHandler = $module_handler; + return $this; + } + } diff --git a/core/lib/Drupal/Core/Entity/EntityFormControllerInterface.php b/core/lib/Drupal/Core/Entity/EntityFormControllerInterface.php index d52363c..1f0664a 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormControllerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityFormControllerInterface.php @@ -7,7 +7,9 @@ namespace Drupal\Core\Entity; +use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\BaseFormIdInterface; +use Drupal\Core\StringTranslation\Translator\TranslatorInterface; use Drupal\entity\EntityFormDisplayInterface; /** @@ -38,6 +40,17 @@ public function getFormLangcode(array $form_state); public function isDefaultFormLangcode(array $form_state); /** + * Sets the operation for this form. + * + * @param string $operation + * The name of the current operation. + * + * @return self + * The entity form. + */ + public function setOperation($operation); + + /** * Returns the operation identifying the form controller. * * @return string @@ -139,4 +152,26 @@ public function validate(array $form, array &$form_state); */ public function submit(array $form, array &$form_state); + /** + * Sets the translation manager for this form. + * + * @param \Drupal\Core\StringTranslation\Translator\TranslatorInterface $translation_manager + * The translation manager. + * + * @return self + * The entity form. + */ + public function setTranslationManager(TranslatorInterface $translation_manager); + + /** + * Sets the module handler for this form. + * + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler. + * + * @return self + * The entity form. + */ + public function setModuleHandler(ModuleHandlerInterface $module_handler); + } diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 5321099..a4619ba 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -230,12 +230,17 @@ public function getFormController($entity_type, $operation) { if (!isset($this->controllers['form'][$operation][$entity_type])) { $class = $this->getControllerClass($entity_type, 'form', $operation); if (in_array('Drupal\Core\Entity\EntityControllerInterface', class_implements($class))) { - $this->controllers['form'][$operation][$entity_type] = $class::createInstance($this->container, $entity_type, $this->getDefinition($entity_type)); + $controller = $class::createInstance($this->container, $entity_type, $this->getDefinition($entity_type)); } else { - $this->controllers['form'][$operation][$entity_type] = new $class($this->container->get('module_handler')); + $controller = new $class(); } - $this->controllers['form'][$operation][$entity_type]->setOperation($operation); + + $controller + ->setTranslationManager($this->container->get('string_translation')) + ->setModuleHandler($this->container->get('module_handler')) + ->setOperation($operation); + $this->controllers['form'][$operation][$entity_type] = $controller; } return $this->controllers['form'][$operation][$entity_type]; } diff --git a/core/lib/Drupal/Core/Entity/EntityNGConfirmFormBase.php b/core/lib/Drupal/Core/Entity/EntityNGConfirmFormBase.php index fd04241..88d9d25 100644 --- a/core/lib/Drupal/Core/Entity/EntityNGConfirmFormBase.php +++ b/core/lib/Drupal/Core/Entity/EntityNGConfirmFormBase.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Entity; use Drupal\Core\Form\ConfirmFormInterface; -use Symfony\Component\HttpFoundation\Request; /** * Provides a generic base class for an entity-based confirmation form. @@ -16,13 +15,6 @@ abstract class EntityNGConfirmFormBase extends EntityFormControllerNG implements ConfirmFormInterface { /** - * The request object. - * - * @var \Symfony\Component\HttpFoundation\Request - */ - protected $request; - - /** * {@inheritdoc} */ public function getBaseFormID() { @@ -60,8 +52,7 @@ public function getFormName() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Request $request = NULL) { - $this->request = $request; + public function buildForm(array $form, array &$form_state) { $form = parent::buildForm($form, $form_state); $form['#attributes']['class'][] = 'confirmation'; @@ -94,8 +85,8 @@ protected function actions(array $form, array &$form_state) { $path = $this->getCancelPath(); // Prepare cancel link. - if ($this->request->query->has('destination')) { - $options = drupal_parse_url($this->request->query->get('destination')); + if ($this->getRequest()->query->has('destination')) { + $options = drupal_parse_url($this->getRequest()->query->get('destination')); } elseif (is_array($path)) { $options = $path; diff --git a/core/lib/Drupal/Core/Form/ConfirmFormBase.php b/core/lib/Drupal/Core/Form/ConfirmFormBase.php index e5899c5..884c7c9 100644 --- a/core/lib/Drupal/Core/Form/ConfirmFormBase.php +++ b/core/lib/Drupal/Core/Form/ConfirmFormBase.php @@ -7,12 +7,10 @@ namespace Drupal\Core\Form; -use Symfony\Component\HttpFoundation\Request; - /** * Provides an generic base class for a confirmation form. */ -abstract class ConfirmFormBase implements ConfirmFormInterface { +abstract class ConfirmFormBase extends FormBase implements ConfirmFormInterface { /** * {@inheritdoc} @@ -45,11 +43,11 @@ public function getFormName() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Request $request = NULL) { + public function buildForm(array $form, array &$form_state) { $path = $this->getCancelPath(); // Prepare cancel link. - if ($request->query->has('destination')) { - $options = drupal_parse_url($request->query->get('destination')); + if ($this->getRequest()->query->has('destination')) { + $options = drupal_parse_url($this->getRequest()->query->get('destination')); } elseif (is_array($path)) { $options = $path; @@ -82,10 +80,4 @@ public function buildForm(array $form, array &$form_state, Request $request = NU return $form; } - /** - * {@inheritdoc} - */ - public function validateForm(array &$form, array &$form_state) { - } - } diff --git a/core/lib/Drupal/Core/Form/FormBase.php b/core/lib/Drupal/Core/Form/FormBase.php new file mode 100644 index 0000000..e433828 --- /dev/null +++ b/core/lib/Drupal/Core/Form/FormBase.php @@ -0,0 +1,131 @@ +translator()->translate($string, $args, $options); + } + + /** + * Gets the translator object. + * + * @return \Drupal\Core\StringTranslation\TranslationManager|TranslatorInterface + * The translator object. + */ + protected function translator() { + if (!$this->translationManager) { + $this->translationManager = \Drupal::translation(); + } + return $this->translationManager; + } + + /** + * Sets the translation manager for this form. + * + * @param \Drupal\Core\StringTranslation\Translator\TranslatorInterface $translation_manager + * The translation manager. + * + * @return self + * The entity form. + */ + public function setTranslationManager(TranslatorInterface $translation_manager) { + $this->translationManager = $translation_manager; + return $this; + } + + /** + * Gets the request object. + * + * @return \Symfony\Component\HttpFoundation\Request $request + * The request object. + */ + public function getRequest() { + if (!$this->request) { + $this->request = \Drupal::request(); + } + return $this->request; + } + + /** + * Sets the request object to use. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * The request object. + */ + public function setRequest(Request $request) { + $this->request = $request; + } + + /** + * Gets the current user. + * + * @return \Drupal\Core\Session\AccountInterface + * The current user. + */ + public function getCurrentUser() { + return $this->getRequest()->attributes->get('_account'); + } + +} diff --git a/core/modules/action/lib/Drupal/action/ActionAddFormController.php b/core/modules/action/lib/Drupal/action/ActionAddFormController.php index 56d7bbf..85db8fe 100644 --- a/core/modules/action/lib/Drupal/action/ActionAddFormController.php +++ b/core/modules/action/lib/Drupal/action/ActionAddFormController.php @@ -11,7 +11,6 @@ use Drupal\Core\Action\ActionManager; use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -29,15 +28,13 @@ class ActionAddFormController extends ActionFormControllerBase implements Entity /** * Constructs a new ActionAddFormController. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface - * The module handler service. * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage_controller * The action storage controller. * @param \Drupal\Core\Action\ActionManager $action_manager * The action plugin manager. */ - public function __construct(ModuleHandlerInterface $module_handler, EntityStorageControllerInterface $storage_controller, ActionManager $action_manager) { - parent::__construct($module_handler, $storage_controller); + public function __construct(EntityStorageControllerInterface $storage_controller, ActionManager $action_manager) { + parent::__construct($storage_controller); $this->actionManager = $action_manager; } @@ -47,7 +44,6 @@ public function __construct(ModuleHandlerInterface $module_handler, EntityStorag */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('plugin.manager.entity')->getStorageController($entity_type), $container->get('plugin.manager.action') ); diff --git a/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php b/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php index e9df397..0cef03d 100644 --- a/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php +++ b/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php @@ -9,7 +9,6 @@ use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityFormController; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Plugin\PluginFormInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -36,14 +35,10 @@ /** * Constructs a new action form. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface - * The module handler service. * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage_controller * The action storage controller. */ - public function __construct(ModuleHandlerInterface $module_handler, EntityStorageControllerInterface $storage_controller) { - parent::__construct($module_handler); - + public function __construct(EntityStorageControllerInterface $storage_controller) { $this->storageController = $storage_controller; } @@ -52,7 +47,6 @@ public function __construct(ModuleHandlerInterface $module_handler, EntityStorag */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('plugin.manager.entity')->getStorageController($entity_type) ); } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/CategoryDeleteForm.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/CategoryDeleteForm.php index 038e3cc..9cfba21 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/CategoryDeleteForm.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/CategoryDeleteForm.php @@ -13,10 +13,8 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\ConfirmFormBase; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; - /** * Provides a confirm delete form. */ @@ -51,13 +49,6 @@ class CategoryDeleteForm extends ConfirmFormBase implements ControllerInterface protected $categoryStorageController; /** - * The current request. - * - * @var \Symfony\Component\HttpFoundation\Request - */ - protected $request; - - /** * Creates a new CategoryDeleteForm. * * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler @@ -126,8 +117,6 @@ public function getDescription() { * An associative array containing the structure of the form. * @param array $form_state * An associative array containing the current state of the form. - * @param \Symfony\Component\HttpFoundation\Request $request - * The current request. * @param int|null $cid * The category ID. * @@ -137,14 +126,13 @@ public function getDescription() { * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * If the cid param or category is not found. */ - public function buildForm(array $form, array &$form_state, Request $request = NULL, $cid = NULL) { + public function buildForm(array $form, array &$form_state, $cid = NULL) { $category = $this->categoryStorageController->load($cid); if (empty($cid) || empty($category)) { throw new NotFoundHttpException(); } $this->category = $category; - $this->request = $request; - return parent::buildForm($form, $form_state, $request); + return parent::buildForm($form, $form_state); } /** @@ -158,7 +146,7 @@ public function submitForm(array &$form, array &$form_state) { $this->deleteBlocks($cid); watchdog('aggregator', 'Category %category deleted.', array('%category' => $title)); drupal_set_message(t('The category %category has been deleted.', array('%category' => $title))); - if (preg_match('/^\/admin/', $this->request->getPathInfo())) { + if (preg_match('/^\/admin/', $this->getRequest()->getPathInfo())) { $form_state['redirect'] = 'admin/config/services/aggregator/'; } else { diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/SettingsForm.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/SettingsForm.php index bb46647..0bc2e80 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/SettingsForm.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/SettingsForm.php @@ -7,6 +7,7 @@ namespace Drupal\aggregator\Form; +use Drupal\Core\Config\Context\ContextInterface; use Drupal\system\SystemConfigFormBase; use Drupal\Core\Config\ConfigFactory; use Drupal\aggregator\Plugin\AggregatorPluginManager; @@ -40,6 +41,8 @@ class SettingsForm extends SystemConfigFormBase { * * @param \Drupal\Core\Config\ConfigFactory $config_factory * The factory for configuration objects. + * @param \Drupal\Core\Config\Context\ContextInterface $context + * The configuration context to use. * @param \Drupal\aggregator\Plugin\AggregatorPluginManager $fetcher_manager * The aggregator fetcher plugin manager. * @param \Drupal\aggregator\Plugin\AggregatorPluginManager $parser_manager @@ -47,8 +50,9 @@ class SettingsForm extends SystemConfigFormBase { * @param \Drupal\aggregator\Plugin\AggregatorPluginManager $processor_manager * The aggregator processor plugin manager. */ - public function __construct(ConfigFactory $config_factory, AggregatorPluginManager $fetcher_manager, AggregatorPluginManager $parser_manager, AggregatorPluginManager $processor_manager) { - $this->configFactory = $config_factory; + public function __construct(ConfigFactory $config_factory, ContextInterface $context, AggregatorPluginManager $fetcher_manager, AggregatorPluginManager $parser_manager, AggregatorPluginManager $processor_manager) { + parent::__construct($config_factory, $context); + $this->managers = array( 'fetcher' => $fetcher_manager, 'parser' => $parser_manager, @@ -68,6 +72,7 @@ public function __construct(ConfigFactory $config_factory, AggregatorPluginManag public static function create(ContainerInterface $container) { return new static( $container->get('config.factory'), + $container->get('config.context.free'), $container->get('plugin.manager.aggregator.fetcher'), $container->get('plugin.manager.aggregator.parser'), $container->get('plugin.manager.aggregator.processor') diff --git a/core/modules/ban/lib/Drupal/ban/Form/BanDelete.php b/core/modules/ban/lib/Drupal/ban/Form/BanDelete.php index ac1aa91..980c92b 100644 --- a/core/modules/ban/lib/Drupal/ban/Form/BanDelete.php +++ b/core/modules/ban/lib/Drupal/ban/Form/BanDelete.php @@ -11,7 +11,6 @@ use Drupal\Core\Form\ConfirmFormBase; use Drupal\ban\BanIpManager; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** @@ -30,6 +29,7 @@ class BanDelete extends ConfirmFormBase implements ControllerInterface { * Constructs a new BanDelete object. * * @param \Drupal\ban\BanIpManager $ip_manager + * The IP manager. */ public function __construct(BanIpManager $ip_manager) { $this->ipManager = $ip_manager; @@ -55,14 +55,14 @@ public function getFormID() { * {@inheritdoc} */ public function getQuestion() { - return t('Are you sure you want to unblock %ip?', array('%ip' => $this->banIp)); + return $this->t('Are you sure you want to unblock %ip?', array('%ip' => $this->banIp)); } /** * {@inheritdoc} */ public function getConfirmText() { - return t('Delete'); + return $this->t('Delete'); } /** @@ -78,11 +78,11 @@ public function getCancelPath() { * @param string $ban_id * The IP address record ID to unban. */ - public function buildForm(array $form, array &$form_state, $ban_id = '', Request $request = NULL) { + public function buildForm(array $form, array &$form_state, $ban_id = '') { if (!$this->banIp = $this->ipManager->findById($ban_id)) { throw new NotFoundHttpException(); } - return parent::buildForm($form, $form_state, $request); + return parent::buildForm($form, $form_state); } /** diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockTypeDeleteForm.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockTypeDeleteForm.php index 4b7c220..7d19e0e 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockTypeDeleteForm.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockTypeDeleteForm.php @@ -10,9 +10,7 @@ use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\Query\QueryFactory; -use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; /** * Provides a confirmation form for deleting a custom block type entity. @@ -29,13 +27,10 @@ class CustomBlockTypeDeleteForm extends EntityConfirmFormBase implements EntityC /** * Constructs a query factory object. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface - * The module handler service. * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory * The entity query object. */ - public function __construct(ModuleHandlerInterface $module_handler, QueryFactory $query_factory) { - parent::__construct($module_handler); + public function __construct(QueryFactory $query_factory) { $this->queryFactory = $query_factory; } @@ -44,7 +39,6 @@ public function __construct(ModuleHandlerInterface $module_handler, QueryFactory */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('entity.query') ); } @@ -73,7 +67,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Request $request = NULL) { + public function buildForm(array $form, array &$form_state) { $blocks = $this->queryFactory->get('custom_block')->condition('type', $this->entity->id())->execute(); if (!empty($blocks)) { $caption = '
' . format_plural(count($blocks), '%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', '%label is used by @count custom blocks on your site. You may not remove %label until you have removed all of the %label custom blocks.', array('%label' => $this->entity->label())) . '
'; @@ -81,7 +75,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU return $form; } else { - return parent::buildForm($form, $form_state, $request); + return parent::buildForm($form, $form_state); } } diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index fdb72fe..0a7394e 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -11,7 +11,6 @@ use Drupal\Core\Entity\EntityFormController; use Drupal\Core\Entity\EntityManager; use Drupal\Core\Entity\Query\QueryFactory; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\Language; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -37,16 +36,12 @@ class BlockFormController extends EntityFormController implements EntityControll /** * Constructs a BlockFormController object. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface - * The module handler service. * @param \Drupal\Core\Entity\EntityManager $entity_manager * The entity manager. * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query_factory * The entity query factory. */ - public function __construct(ModuleHandlerInterface $module_handler, EntityManager $entity_manager, QueryFactory $entity_query_factory) { - parent::__construct($module_handler); - + public function __construct(EntityManager $entity_manager, QueryFactory $entity_query_factory) { $this->storageController = $entity_manager->getStorageController('block'); $this->entityQueryFactory = $entity_query_factory; } @@ -56,7 +51,6 @@ public function __construct(ModuleHandlerInterface $module_handler, EntityManage */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('plugin.manager.entity'), $container->get('entity.query') ); diff --git a/core/modules/block/tests/lib/Drupal/block/Tests/BlockFormControllerTest.php b/core/modules/block/tests/lib/Drupal/block/Tests/BlockFormControllerTest.php index e57e877..8b40333 100644 --- a/core/modules/block/tests/lib/Drupal/block/Tests/BlockFormControllerTest.php +++ b/core/modules/block/tests/lib/Drupal/block/Tests/BlockFormControllerTest.php @@ -78,10 +78,7 @@ public function testGetUniqueMachineName() { ->method('getStorageController') ->will($this->returnValue($block_storage)); - $module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandlerInterface') - ->getMock(); - - $block_form_controller = new BlockFormController($module_handler, $entity_manager, $query_factory); + $block_form_controller = new BlockFormController($entity_manager, $query_factory); // Ensure that the block with just one other instance gets the next available // name suggestion. diff --git a/core/modules/config/lib/Drupal/config/Form/ConfigSync.php b/core/modules/config/lib/Drupal/config/Form/ConfigSync.php index 8c5cb96..76fe775 100644 --- a/core/modules/config/lib/Drupal/config/Form/ConfigSync.php +++ b/core/modules/config/lib/Drupal/config/Form/ConfigSync.php @@ -7,25 +7,23 @@ namespace Drupal\config\Form; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; - +use Drupal\Core\Entity\EntityManager; +use Drupal\Core\Form\FormBase; use Drupal\Core\Controller\ControllerInterface; -use Drupal\Core\Form\FormInterface; use Drupal\Core\Config\StorageInterface; use Drupal\Core\Lock\LockBackendInterface; use Drupal\Core\Config\StorageComparer; use Drupal\Core\Config\ConfigImporter; use Drupal\Core\Config\ConfigException; use Drupal\Core\Config\ConfigFactory; -use Drupal\Core\StringTranslation\Translator\TranslatorInterface; use Drupal\Core\Routing\PathBasedGeneratorInterface; -use \Drupal\Core\Entity\EntityManager; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Construct the storage changes in a configuration synchronization form. */ -class ConfigSync implements ControllerInterface, FormInterface { +class ConfigSync extends FormBase implements ControllerInterface { /** * The database lock object. @@ -66,14 +64,6 @@ class ConfigSync implements ControllerInterface, FormInterface { protected $entity_manager; /** - * The translation manager service. - * - * @var \Drupal\Core\StringTranslation\Translator\TranslatorInterface - */ - protected $translationManager; - - - /** * URL generator service. * * @var \Drupal\Core\Routing\PathBasedGeneratorInterface @@ -83,8 +73,6 @@ class ConfigSync implements ControllerInterface, FormInterface { /** * Constructs the object. * - * @param \Drupal\Core\Database\Connection; $database - * The database object. * @param \Drupal\Core\Config\StorageInterface $sourceStorage * The source storage object. * @param \Drupal\Core\Config\StorageInterface $targetStorage @@ -95,21 +83,18 @@ class ConfigSync implements ControllerInterface, FormInterface { * Event dispatcher. * @param \Drupal\Core\Config\ConfigFactory $config_factory * Configuration object factory. - * @param \Drupal\Core\Entity\EntityManager + * @param \Drupal\Core\Entity\EntityManager $entity_manager * Entity manager. - * @param \Drupal\Core\StringTranslation\Translator\TranslatorInterface $translation_manager - * The translation manager. * @param \Drupal\Core\Routing\PathBasedGeneratorInterface $url_generator * The url generator service. */ - public function __construct(StorageInterface $sourceStorage, StorageInterface $targetStorage, LockBackendInterface $lock, EventDispatcherInterface $event_dispatcher, ConfigFactory $config_factory, EntityManager $entity_manger, TranslatorInterface $translation_manager, PathBasedGeneratorInterface $url_generator) { + public function __construct(StorageInterface $sourceStorage, StorageInterface $targetStorage, LockBackendInterface $lock, EventDispatcherInterface $event_dispatcher, ConfigFactory $config_factory, EntityManager $entity_manager, PathBasedGeneratorInterface $url_generator) { $this->sourceStorage = $sourceStorage; $this->targetStorage = $targetStorage; $this->lock = $lock; $this->eventDispatcher = $event_dispatcher; $this->configFactory = $config_factory; - $this->entity_manager = $entity_manger; - $this->translationManager = $translation_manager; + $this->entity_manager = $entity_manager; $this->urlGenerator = $url_generator; } @@ -124,7 +109,6 @@ public static function create(ContainerInterface $container) { $container->get('event_dispatcher'), $container->get('config.factory'), $container->get('plugin.manager.entity'), - $container->get('string_translation'), $container->get('url_generator') ); } @@ -143,14 +127,14 @@ public function buildForm(array $form, array &$form_state) { $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', - '#value' => $this->translationManager->translate('Import all'), + '#value' => $this->t('Import all'), ); $source_list = $this->sourceStorage->listAll(); $config_comparer = new StorageComparer($this->sourceStorage, $this->targetStorage); if (empty($source_list) || !$config_comparer->createChangelist()->hasChanges()) { $form['no_changes'] = array( - '#markup' => $this->translationManager->translate('There are no configuration changes.'), + '#markup' => $this->t('There are no configuration changes.'), ); $form['actions']['#access'] = FALSE; return $form; @@ -194,7 +178,7 @@ public function buildForm(array $form, array &$form_state) { foreach ($config_files as $config_file) { $links['view_diff'] = array( - 'title' => $this->translationManager->translate('View differences'), + 'title' => $this->t('View differences'), 'href' => $this->urlGenerator->getPathFromRoute('config_diff', array('config_file' => $config_file)), 'attributes' => array( 'class' => array('use-ajax'), @@ -222,12 +206,6 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { - } - - /** - * {@inheritdoc} - */ public function submitForm(array &$form, array &$form_state) { $config_importer = new ConfigImporter( $form_state['storage_comparer'], @@ -237,13 +215,13 @@ public function submitForm(array &$form, array &$form_state) { $this->lock ); if ($config_importer->alreadyImporting()) { - drupal_set_message($this->translationManager->translate('Another request may be synchronizing configuration already.')); + drupal_set_message($this->t('Another request may be synchronizing configuration already.')); } else{ try { $config_importer->import(); drupal_flush_all_caches(); - drupal_set_message($this->translationManager->translate('The configuration was imported successfully.')); + drupal_set_message($this->t('The configuration was imported successfully.')); } catch (ConfigException $e) { // Return a negative result for UI purposes. We do not differentiate @@ -252,7 +230,7 @@ public function submitForm(array &$form, array &$form_state) { // multiple developers or site builders attempt to do it without // coordinating. watchdog_exception('config_import', $e); - drupal_set_message($this->translationManager->translate('The import failed due to an error. Any errors have been logged.'), 'error'); + drupal_set_message($this->t('The import failed due to an error. Any errors have been logged.'), 'error'); } } } diff --git a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php index ad67f5a..feab27b 100644 --- a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php +++ b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php @@ -9,7 +9,6 @@ use Drupal\Component\Plugin\PluginManagerInterface; use Drupal\Core\Entity\Query\QueryFactory; -use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -33,8 +32,6 @@ class EntityDisplayModeAddForm extends EntityDisplayModeFormBase { /** * Constructs a new EntityDisplayModeAddForm. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler. * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory * The entity query factory. * @param array $entity_info @@ -42,8 +39,8 @@ class EntityDisplayModeAddForm extends EntityDisplayModeFormBase { * @param \Drupal\Component\Plugin\PluginManagerInterface $entity_manager * The entity manager. */ - public function __construct(ModuleHandlerInterface $module_handler, QueryFactory $query_factory, array $entity_info, PluginManagerInterface $entity_manager) { - parent::__construct($module_handler, $query_factory, $entity_info); + public function __construct(QueryFactory $query_factory, array $entity_info, PluginManagerInterface $entity_manager) { + parent::__construct($query_factory, $entity_info); $this->entityManager = $entity_manager; } @@ -53,7 +50,6 @@ public function __construct(ModuleHandlerInterface $module_handler, QueryFactory */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('entity.query'), $entity_info, $container->get('plugin.manager.entity') diff --git a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php index 787432a..6a47e0b 100644 --- a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php +++ b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php @@ -10,7 +10,6 @@ use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityFormController; use Drupal\Core\Entity\Query\QueryFactory; -use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -35,16 +34,12 @@ /** * Constructs a new EntityDisplayModeFormBase. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler. * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory * The entity query factory. * @param array $entity_info * The entity type definition. */ - public function __construct(ModuleHandlerInterface $module_handler, QueryFactory $query_factory, array $entity_info) { - parent::__construct($module_handler); - + public function __construct(QueryFactory $query_factory, array $entity_info) { $this->queryFactory = $query_factory; $this->entityInfo = $entity_info; } @@ -54,7 +49,6 @@ public function __construct(ModuleHandlerInterface $module_handler, QueryFactory */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('entity.query'), $entity_info ); diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldDeleteForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldDeleteForm.php index e53eec9..cb02252 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldDeleteForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldDeleteForm.php @@ -10,7 +10,6 @@ use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityManager; -use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -28,13 +27,10 @@ class FieldDeleteForm extends EntityConfirmFormBase implements EntityControllerI /** * Constructs a new FieldDeleteForm object. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface - * The module handler service. * @param \Drupal\Core\Entity\EntityManager $entity_manager * The entity manager. */ - public function __construct(ModuleHandlerInterface $module_handler, EntityManager $entity_manager) { - parent::__construct($module_handler); + public function __construct(EntityManager $entity_manager) { $this->entityManager = $entity_manager; } @@ -43,7 +39,6 @@ public function __construct(ModuleHandlerInterface $module_handler, EntityManage */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('plugin.manager.entity') ); } diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php b/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php index e715e4a..55719f8 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php @@ -11,7 +11,6 @@ use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityFormController; use Drupal\Core\Entity\Query\QueryFactory; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\filter\Plugin\Filter\FilterNull; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -37,15 +36,12 @@ /** * Constructs a new FilterFormatFormControllerBase. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface - * The module handler service. * @param \Drupal\Core\Config\ConfigFactory $config_factory * The config factory. * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory * The entity query factory. */ - public function __construct(ModuleHandlerInterface $module_handler, ConfigFactory $config_factory, QueryFactory $query_factory) { - parent::__construct($module_handler); + public function __construct(ConfigFactory $config_factory, QueryFactory $query_factory) { $this->configFactory = $config_factory; $this->queryFactory = $query_factory; } @@ -55,7 +51,6 @@ public function __construct(ModuleHandlerInterface $module_handler, ConfigFactor */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('config.factory'), $container->get('entity.query') ); diff --git a/core/modules/forum/lib/Drupal/forum/Form/DeleteForm.php b/core/modules/forum/lib/Drupal/forum/Form/DeleteForm.php index ded6bb5..5cfba76 100644 --- a/core/modules/forum/lib/Drupal/forum/Form/DeleteForm.php +++ b/core/modules/forum/lib/Drupal/forum/Form/DeleteForm.php @@ -9,7 +9,6 @@ use Drupal\Core\Form\ConfirmFormBase; use Drupal\taxonomy\Entity\Term; -use Symfony\Component\HttpFoundation\Request; /** * Builds the form to delete a forum term. @@ -54,10 +53,10 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Term $taxonomy_term = NULL, Request $request = NULL) { + public function buildForm(array $form, array &$form_state, Term $taxonomy_term = NULL) { $this->taxonomyTerm = $taxonomy_term; - return parent::buildForm($form, $form_state, $request); + return parent::buildForm($form, $form_state); } /** diff --git a/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php b/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php index b517747..ee38dec 100644 --- a/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php +++ b/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php @@ -10,7 +10,6 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Entity\EntityControllerInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\taxonomy\TermFormController; use Drupal\taxonomy\TermStorageControllerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -59,8 +58,6 @@ class ForumFormController extends TermFormController implements EntityController /** * Constructs a new ForumFormController object. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler. * @param \Drupal\Core\Config\ConfigFactory $config_factory * The config factory service. * @param \Symfony\Component\HttpFoundation\Request $request @@ -68,8 +65,7 @@ class ForumFormController extends TermFormController implements EntityController * @param \Drupal\taxonomy\TermStorageControllerInterface $storage_controller * The storage controller. */ - public function __construct(ModuleHandlerInterface $module_handler, ConfigFactory $config_factory, Request $request, TermStorageControllerInterface $storage_controller) { - parent::__construct($module_handler); + public function __construct(ConfigFactory $config_factory, Request $request, TermStorageControllerInterface $storage_controller) { $this->config = $config_factory->get('forum.settings'); $this->request = $request; $this->storageController = $storage_controller; @@ -80,7 +76,6 @@ public function __construct(ModuleHandlerInterface $module_handler, ConfigFactor */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('config.factory'), $container->get('request'), $container->get('plugin.manager.entity')->getStorageController('taxonomy_term') diff --git a/core/modules/image/lib/Drupal/image/Form/ImageEffectDeleteForm.php b/core/modules/image/lib/Drupal/image/Form/ImageEffectDeleteForm.php index 5a75985..c3a99ed 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageEffectDeleteForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageEffectDeleteForm.php @@ -9,7 +9,6 @@ use Drupal\Core\Form\ConfirmFormBase; use Drupal\image\ImageStyleInterface; -use Symfony\Component\HttpFoundation\Request; /** * Form for deleting an image effect. @@ -61,11 +60,11 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, ImageStyleInterface $image_style = NULL, $image_effect = NULL, Request $request = NULL) { + public function buildForm(array $form, array &$form_state, ImageStyleInterface $image_style = NULL, $image_effect = NULL) { $this->imageStyle = $image_style; $this->imageEffect = $this->imageStyle->getEffect($image_effect); - return parent::buildForm($form, $form_state, $request); + return parent::buildForm($form, $form_state); } /** diff --git a/core/modules/image/lib/Drupal/image/Form/ImageStyleAddForm.php b/core/modules/image/lib/Drupal/image/Form/ImageStyleAddForm.php index 8af0640..64c2a37 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageStyleAddForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageStyleAddForm.php @@ -7,8 +7,6 @@ namespace Drupal\image\Form; -use Drupal\image\Form\ImageStyleFormBase; - /** * Controller for image style addition forms. */ @@ -19,7 +17,7 @@ class ImageStyleAddForm extends ImageStyleFormBase { */ public function save(array $form, array &$form_state) { parent::save($form, $form_state); - drupal_set_message($this->translator->translate('Style %name was created.', array('%name' => $this->entity->label()))); + drupal_set_message($this->t('Style %name was created.', array('%name' => $this->entity->label()))); } /** @@ -27,7 +25,7 @@ public function save(array $form, array &$form_state) { */ public function actions(array $form, array &$form_state) { $actions = parent::actions($form, $form_state); - $actions['submit']['#value'] = $this->translator->translate('Create new style'); + $actions['submit']['#value'] = $this->t('Create new style'); return $actions; } diff --git a/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php b/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php index 0625cdd..9f5d1e8 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php @@ -8,10 +8,7 @@ namespace Drupal\image\Form; use Drupal\Core\Entity\EntityStorageControllerInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\StringTranslation\Translator\TranslatorInterface; use Drupal\image\ConfigurableImageEffectInterface; -use Drupal\image\Form\ImageStyleFormBase; use Drupal\image\ImageEffectManager; use Drupal\Component\Utility\String; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -31,17 +28,13 @@ class ImageStyleEditForm extends ImageStyleFormBase { /** * Constructs an ImageStyleEditForm object. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler service. * @param \Drupal\Core\Entity\EntityStorageControllerInterface $image_style_storage * The storage controller. * @param \Drupal\image\ImageEffectManager $image_effect_manager * The image effect manager service. - * @param \Drupal\Core\StringTranslation\Translator\TranslatorInterface $translator - * The translator service. */ - public function __construct(ModuleHandlerInterface $module_handler, EntityStorageControllerInterface $image_style_storage, TranslatorInterface $translator, ImageEffectManager $image_effect_manager) { - parent::__construct($module_handler, $image_style_storage, $translator); + public function __construct(EntityStorageControllerInterface $image_style_storage, ImageEffectManager $image_effect_manager) { + parent::__construct($image_style_storage); $this->imageEffectManager = $image_effect_manager; } @@ -50,9 +43,7 @@ public function __construct(ModuleHandlerInterface $module_handler, EntityStorag */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('plugin.manager.entity')->getStorageController($entity_type), - $container->get('string_translation'), $container->get('plugin.manager.image.effect') ); } @@ -63,7 +54,7 @@ public static function createInstance(ContainerInterface $container, $entity_typ public function form(array $form, array &$form_state) { // @todo Remove drupal_set_title() in http://drupal.org/node/1981644 - $title = $this->translator->translate('Edit style %name', array('%name' => $this->entity->label())); + $title = $this->t('Edit style %name', array('%name' => $this->entity->label())); drupal_set_title($title, PASS_THROUGH); $form['#tree'] = TRUE; @@ -73,7 +64,7 @@ public function form(array $form, array &$form_state) { $preview_arguments = array('#theme' => 'image_style_preview', '#style' => $this->entity); $form['preview'] = array( '#type' => 'item', - '#title' => $this->translator->translate('Preview'), + '#title' => $this->t('Preview'), '#markup' => drupal_render($preview_arguments), // Render preview above parent elements. '#weight' => -5, @@ -94,7 +85,7 @@ public function form(array $form, array &$form_state) { $form['effects'][$key]['summary'] = $effect->getSummary(); $form['effects'][$key]['weight'] = array( '#type' => 'weight', - '#title' => $this->translator->translate('Weight for @title', array('@title' => $effect->label())), + '#title' => $this->t('Weight for @title', array('@title' => $effect->label())), '#title_display' => 'invisible', '#default_value' => $effect->getWeight(), ); @@ -103,12 +94,12 @@ public function form(array $form, array &$form_state) { $is_configurable = $effect instanceof ConfigurableImageEffectInterface; if ($is_configurable) { $links['edit'] = array( - 'title' => $this->translator->translate('edit'), + 'title' => $this->t('edit'), 'href' => 'admin/config/media/image-styles/manage/' . $this->entity->id() . '/effects/' . $key, ); } $links['delete'] = array( - 'title' => $this->translator->translate('delete'), + 'title' => $this->t('delete'), 'href' => 'admin/config/media/image-styles/manage/' . $this->entity->id() . '/effects/' . $key . '/delete', ); $form['effects'][$key]['operations'] = array( @@ -117,13 +108,13 @@ public function form(array $form, array &$form_state) { ); $form['effects'][$key]['configure'] = array( '#type' => 'link', - '#title' => $this->translator->translate('edit'), + '#title' => $this->t('edit'), '#href' => 'admin/config/media/image-styles/manage/' . $this->entity->id() . '/effects/' . $key, '#access' => $is_configurable, ); $form['effects'][$key]['remove'] = array( '#type' => 'link', - '#title' => $this->translator->translate('delete'), + '#title' => $this->t('delete'), '#href' => 'admin/config/media/image-styles/manage/' . $this->entity->id() . '/effects/' . $key . '/delete', ); } @@ -143,20 +134,20 @@ public function form(array $form, array &$form_state) { ); $form['effects']['new']['new'] = array( '#type' => 'select', - '#title' => $this->translator->translate('Effect'), + '#title' => $this->t('Effect'), '#title_display' => 'invisible', '#options' => $new_effect_options, - '#empty_option' => $this->translator->translate('Select a new effect'), + '#empty_option' => $this->t('Select a new effect'), ); $form['effects']['new']['weight'] = array( '#type' => 'weight', - '#title' => $this->translator->translate('Weight for new effect'), + '#title' => $this->t('Weight for new effect'), '#title_display' => 'invisible', '#default_value' => count($form['effects']) - 1, ); $form['effects']['new']['add'] = array( '#type' => 'submit', - '#value' => $this->translator->translate('Add'), + '#value' => $this->t('Add'), '#validate' => array(array($this, 'effectValidate')), '#submit' => array(array($this, 'effectSave')), ); @@ -169,7 +160,7 @@ public function form(array $form, array &$form_state) { */ public function effectValidate($form, &$form_state) { if (!$form_state['values']['new']) { - form_error($form['effects']['new']['new'], $this->translator->translate('Select an effect to add.')); + form_error($form['effects']['new']['new'], $this->t('Select an effect to add.')); } } @@ -189,7 +180,7 @@ public function effectSave($form, &$form_state) { $status = parent::save($form, $form_state); if ($status == SAVED_UPDATED) { - drupal_set_message($this->translator->translate('Changes to the style have been saved.')); + drupal_set_message($this->t('Changes to the style have been saved.')); } // Check if this field has any configuration options. @@ -209,7 +200,7 @@ public function effectSave($form, &$form_state) { ); $effect_id = $this->entity->saveImageEffect($effect); if (!empty($effect_id)) { - drupal_set_message($this->translator->translate('The image effect was successfully applied.')); + drupal_set_message($this->t('The image effect was successfully applied.')); } } } @@ -225,7 +216,7 @@ public function save(array $form, array &$form_state) { } parent::save($form, $form_state); - drupal_set_message($this->translator->translate('Changes to the style have been saved.')); + drupal_set_message($this->t('Changes to the style have been saved.')); } /** @@ -233,7 +224,7 @@ public function save(array $form, array &$form_state) { */ public function actions(array $form, array &$form_state) { $actions = parent::actions($form, $form_state); - $actions['submit']['#value'] = $this->translator->translate('Update style'); + $actions['submit']['#value'] = $this->t('Update style'); return $actions; } diff --git a/core/modules/image/lib/Drupal/image/Form/ImageStyleFormBase.php b/core/modules/image/lib/Drupal/image/Form/ImageStyleFormBase.php index a050434..82727bc 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageStyleFormBase.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageStyleFormBase.php @@ -10,8 +10,6 @@ use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityFormController; use Drupal\Core\Entity\EntityStorageControllerInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\StringTranslation\Translator\TranslatorInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -27,26 +25,13 @@ protected $imageStyleStorage; /** - * The translator service. - * - * @var \Drupal\Core\StringTranslation\Translator\TranslatorInterface - */ - protected $translator; - - /** * Constructs a base class for image style add and edit forms. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler service. * @param \Drupal\Core\Entity\EntityStorageControllerInterface $image_style_storage * The image style entity storage controller. - * @param \Drupal\Core\StringTranslation\Translator\TranslatorInterface $translator - * The translator service. */ - public function __construct(ModuleHandlerInterface $module_handler, EntityStorageControllerInterface $image_style_storage, TranslatorInterface $translator) { - parent::__construct($module_handler); + public function __construct(EntityStorageControllerInterface $image_style_storage) { $this->imageStyleStorage = $image_style_storage; - $this->translator = $translator; } /** @@ -54,9 +39,7 @@ public function __construct(ModuleHandlerInterface $module_handler, EntityStorag */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), - $container->get('plugin.manager.entity')->getStorageController($entity_type), - $container->get('string_translation') + $container->get('plugin.manager.entity')->getStorageController($entity_type) ); } @@ -67,7 +50,7 @@ public function form(array $form, array &$form_state) { $form['label'] = array( '#type' => 'textfield', - '#title' => $this->translator->translate('Image style name'), + '#title' => $this->t('Image style name'), '#default_value' => $this->entity->label(), '#required' => TRUE, ); diff --git a/core/modules/menu/lib/Drupal/menu/Form/MenuDeleteForm.php b/core/modules/menu/lib/Drupal/menu/Form/MenuDeleteForm.php index febf8b9..599ba39 100644 --- a/core/modules/menu/lib/Drupal/menu/Form/MenuDeleteForm.php +++ b/core/modules/menu/lib/Drupal/menu/Form/MenuDeleteForm.php @@ -11,7 +11,6 @@ use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -36,15 +35,12 @@ class MenuDeleteForm extends EntityConfirmFormBase implements EntityControllerIn /** * Constructs a new MenuDeleteForm. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface - * The module handler service. * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage_controller * The menu link storage controller. * @param \Drupal\Core\Database\Connection $connection * The database connection. */ - public function __construct(ModuleHandlerInterface $module_handler, EntityStorageControllerInterface $storage_controller, Connection $connection) { - parent::__construct($module_handler); + public function __construct(EntityStorageControllerInterface $storage_controller, Connection $connection) { $this->storageController = $storage_controller; $this->connection = $connection; } @@ -54,7 +50,6 @@ public function __construct(ModuleHandlerInterface $module_handler, EntityStorag */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('plugin.manager.entity')->getStorageController('menu_link'), $container->get('database') ); diff --git a/core/modules/menu/lib/Drupal/menu/MenuFormController.php b/core/modules/menu/lib/Drupal/menu/MenuFormController.php index 6573865..022bf5d 100644 --- a/core/modules/menu/lib/Drupal/menu/MenuFormController.php +++ b/core/modules/menu/lib/Drupal/menu/MenuFormController.php @@ -11,7 +11,6 @@ use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityFormController; use Drupal\Core\Entity\Query\QueryFactory; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\Language; use Drupal\menu_link\MenuLinkStorageControllerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -45,16 +44,12 @@ class MenuFormController extends EntityFormController implements EntityControlle /** * Constructs a MenuFormController object. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke hooks on. * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query_factory * The factory for entity queries. * @param \Drupal\menu_link\MenuLinkStorageControllerInterface $menu_link_storage * The menu link storage controller. */ - public function __construct(ModuleHandlerInterface $module_handler, QueryFactory $entity_query_factory, MenuLinkStorageControllerInterface $menu_link_storage) { - parent::__construct($module_handler); - + public function __construct(QueryFactory $entity_query_factory, MenuLinkStorageControllerInterface $menu_link_storage) { $this->entityQueryFactory = $entity_query_factory; $this->menuLinkStorage = $menu_link_storage; } @@ -64,7 +59,6 @@ public function __construct(ModuleHandlerInterface $module_handler, QueryFactory */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('entity.query'), $container->get('plugin.manager.entity')->getStorageController('menu_link') ); diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php index 9d58de9..f429a3d 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php @@ -10,7 +10,6 @@ use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityFormController; use Drupal\Core\Language\Language; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Path\AliasManagerInterface; use Drupal\Core\Routing\UrlGenerator; use Drupal\menu_link\MenuLinkStorageControllerInterface; @@ -45,13 +44,14 @@ class MenuLinkFormController extends EntityFormController implements EntityContr /** * Constructs a new MenuLinkFormController object. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface - * The module handler service. + * @param \Drupal\menu_link\MenuLinkStorageControllerInterface $menu_link_storage_controller + * The menu link storage. * @param \Drupal\Core\Path\AliasManagerInterface $path_alias_manager * The path alias manager. + * @param \Drupal\Core\Routing\UrlGenerator $url_generator + * The URL generator. */ - public function __construct(ModuleHandlerInterface $module_handler, MenuLinkStorageControllerInterface $menu_link_storage_controller, AliasManagerInterface $path_alias_manager, UrlGenerator $url_generator) { - parent::__construct($module_handler); + public function __construct(MenuLinkStorageControllerInterface $menu_link_storage_controller, AliasManagerInterface $path_alias_manager, UrlGenerator $url_generator) { $this->menuLinkStorageController = $menu_link_storage_controller; $this->pathAliasManager = $path_alias_manager; $this->urlGenerator = $url_generator; @@ -62,7 +62,6 @@ public function __construct(ModuleHandlerInterface $module_handler, MenuLinkStor */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info, $operation = NULL) { return new static( - $container->get('module_handler'), $container->get('plugin.manager.entity')->getStorageController('menu_link'), $container->get('path.alias_manager.cached'), $container->get('url_generator') diff --git a/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php b/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php index 381ae80..8395fcb 100644 --- a/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php +++ b/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php @@ -14,7 +14,6 @@ use Drupal\user\TempStoreFactory; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; /** * Provides a node deletion confirmation form. @@ -96,7 +95,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Request $request = NULL) { + public function buildForm(array $form, array &$form_state) { $this->nodes = $this->tempStoreFactory->get('node_multiple_delete_confirm')->get($GLOBALS['user']->id()); if (empty($this->nodes)) { return new RedirectResponse(url($this->getCancelPath(), array('absolute' => TRUE))); @@ -108,7 +107,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU return String::checkPlain($node->label()); }, $this->nodes), ); - return parent::buildForm($form, $form_state, $request); + return parent::buildForm($form, $form_state); } /** diff --git a/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php b/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php index 5a3fdb0..5c8ff01 100644 --- a/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php +++ b/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php @@ -10,7 +10,6 @@ use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityNGConfirmFormBase; use Drupal\Core\Entity\EntityStorageControllerInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Routing\PathBasedGeneratorInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; @@ -37,16 +36,12 @@ class NodeDeleteForm extends EntityNGConfirmFormBase implements EntityController /** * Constructs a NodeDeleteForm object. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler service. * @param \Drupal\Core\Routing\PathBasedGeneratorInterface $url_generator * The URL generator. * @param \Drupal\Core\Entity\EntityStorageControllerInterface $node_type_storage * The node type storage. */ - public function __construct(ModuleHandlerInterface $module_handler, PathBasedGeneratorInterface $url_generator, EntityStorageControllerInterface $node_type_storage) { - parent::__construct($module_handler); - + public function __construct(PathBasedGeneratorInterface $url_generator, EntityStorageControllerInterface $node_type_storage) { $this->urlGenerator = $url_generator; $this->nodeTypeStorage = $node_type_storage; } @@ -56,7 +51,6 @@ public function __construct(ModuleHandlerInterface $module_handler, PathBasedGen */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('url_generator'), $container->get('plugin.manager.entity')->getStorageController('node_type') ); diff --git a/core/modules/node/lib/Drupal/node/Form/NodeRevisionDeleteForm.php b/core/modules/node/lib/Drupal/node/Form/NodeRevisionDeleteForm.php index 8c06d49..b84f151 100644 --- a/core/modules/node/lib/Drupal/node/Form/NodeRevisionDeleteForm.php +++ b/core/modules/node/lib/Drupal/node/Form/NodeRevisionDeleteForm.php @@ -13,7 +13,6 @@ use Drupal\Core\Form\ConfirmFormBase; use Drupal\node\NodeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; /** * Provides a form for reverting a node revision. @@ -107,9 +106,9 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Request $request = NULL, $node_revision = NULL) { + public function buildForm(array $form, array &$form_state, $node_revision = NULL) { $this->revision = $this->nodeStorage->loadRevision($node_revision); - return parent::buildForm($form, $form_state, $request); + return parent::buildForm($form, $form_state); } /** diff --git a/core/modules/node/lib/Drupal/node/Form/NodeRevisionRevertForm.php b/core/modules/node/lib/Drupal/node/Form/NodeRevisionRevertForm.php index d4c69ec..dfa8abf 100644 --- a/core/modules/node/lib/Drupal/node/Form/NodeRevisionRevertForm.php +++ b/core/modules/node/lib/Drupal/node/Form/NodeRevisionRevertForm.php @@ -12,7 +12,6 @@ use Drupal\Core\Form\ConfirmFormBase; use Drupal\node\NodeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; /** * Provides a form for reverting a node revision. @@ -90,9 +89,9 @@ public function getDescription() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Request $request = NULL, $node_revision = NULL) { + public function buildForm(array $form, array &$form_state, $node_revision = NULL) { $this->revision = $this->nodeStorage->loadRevision($node_revision); - return parent::buildForm($form, $form_state, $request); + return parent::buildForm($form, $form_state); } /** diff --git a/core/modules/node/lib/Drupal/node/Form/NodeTypeDeleteConfirm.php b/core/modules/node/lib/Drupal/node/Form/NodeTypeDeleteConfirm.php index d159b3d..1514854 100644 --- a/core/modules/node/lib/Drupal/node/Form/NodeTypeDeleteConfirm.php +++ b/core/modules/node/lib/Drupal/node/Form/NodeTypeDeleteConfirm.php @@ -9,10 +9,8 @@ use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityControllerInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Database\Connection; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; /** * Provides a form for content type deletion. @@ -29,13 +27,10 @@ class NodeTypeDeleteConfirm extends EntityConfirmFormBase implements EntityContr /** * Constructs a new NodeTypeDeleteConfirm object. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface - * The module handler service. * @param \Drupal\Core\Database\Connection $database * The database connection. */ - public function __construct(ModuleHandlerInterface $module_handler, Connection $database) { - parent::__construct($module_handler); + public function __construct(Connection $database) { $this->database = $database; } @@ -44,7 +39,6 @@ public function __construct(ModuleHandlerInterface $module_handler, Connection $ */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('database') ); } @@ -73,7 +67,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Request $request = NULL) { + public function buildForm(array $form, array &$form_state) { $num_nodes = $this->database->query("SELECT COUNT(*) FROM {node} WHERE type = :type", array(':type' => $this->entity->id()))->fetchField(); if ($num_nodes) { drupal_set_title($this->getQuestion(), PASS_THROUGH); @@ -82,7 +76,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU return $form; } - return parent::buildForm($form, $form_state, $request); + return parent::buildForm($form, $form_state); } /** diff --git a/core/modules/node/lib/Drupal/node/NodeTypeFormController.php b/core/modules/node/lib/Drupal/node/NodeTypeFormController.php index ec465e1..5071f4d 100644 --- a/core/modules/node/lib/Drupal/node/NodeTypeFormController.php +++ b/core/modules/node/lib/Drupal/node/NodeTypeFormController.php @@ -14,7 +14,7 @@ /** * Form controller for node type forms. */ -class NodeTypeFormController extends EntityFormController implements EntityControllerInterface { +class NodeTypeFormController extends EntityFormController { /** * {@inheritdoc} diff --git a/core/modules/path/lib/Drupal/path/Form/DeleteForm.php b/core/modules/path/lib/Drupal/path/Form/DeleteForm.php index 2d4bcff..caebcc3 100644 --- a/core/modules/path/lib/Drupal/path/Form/DeleteForm.php +++ b/core/modules/path/lib/Drupal/path/Form/DeleteForm.php @@ -11,7 +11,6 @@ use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Path\Path; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; /** * Builds the form to delete a path alias. @@ -75,10 +74,10 @@ public function getCancelPath() { /** * Overrides \Drupal\Core\Form\ConfirmFormBase::buildForm(). */ - public function buildForm(array $form, array &$form_state, $pid = NULL, Request $request = NULL) { + public function buildForm(array $form, array &$form_state, $pid = NULL) { $this->pathAlias = $this->path->load(array('pid' => $pid)); - return parent::buildForm($form, $form_state, $request); + return parent::buildForm($form, $form_state); } /** diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php index 75773de..76a62ae 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php @@ -9,7 +9,6 @@ use Drupal\Core\Form\ConfirmFormBase; use Drupal\menu_link\Entity\MenuLink; -use Symfony\Component\HttpFoundation\Request; /** * Builds the shortcut link deletion form. @@ -54,10 +53,10 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, MenuLink $menu_link = NULL, Request $request = NULL) { + public function buildForm(array $form, array &$form_state, MenuLink $menu_link = NULL) { $this->menuLink = $menu_link; - return parent::buildForm($form, $form_state, $request); + return parent::buildForm($form, $form_state); } /** diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutSetDeleteForm.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutSetDeleteForm.php index a12dbd8..b4000e6 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutSetDeleteForm.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutSetDeleteForm.php @@ -9,11 +9,9 @@ use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityControllerInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\shortcut\ShortcutSetStorageControllerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Database\Connection; -use Symfony\Component\HttpFoundation\Request; /** * Builds the shortcut set deletion form. @@ -37,8 +35,7 @@ class ShortcutSetDeleteForm extends EntityConfirmFormBase implements EntityContr /** * Constructs a ShortcutSetDeleteForm object. */ - public function __construct(ModuleHandlerInterface $module_handler, Connection $database, ShortcutSetStorageControllerInterface $storage_controller) { - parent::__construct($module_handler); + public function __construct(Connection $database, ShortcutSetStorageControllerInterface $storage_controller) { $this->database = $database; $this->storageController = $storage_controller; } @@ -48,7 +45,6 @@ public function __construct(ModuleHandlerInterface $module_handler, Connection $ */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('database'), $container->get('plugin.manager.entity')->getStorageController('shortcut_set') ); @@ -78,7 +74,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Request $request = NULL) { + public function buildForm(array $form, array &$form_state) { // Find out how many users are directly assigned to this shortcut set, and // make a message. $number = $this->storageController->countAssignedUsers($this->entity); @@ -99,7 +95,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU '#markup' => $info, ); - return parent::buildForm($form, $form_state, $request); + return parent::buildForm($form, $form_state); } /** diff --git a/core/modules/statistics/lib/Drupal/statistics/StatisticsSettingsForm.php b/core/modules/statistics/lib/Drupal/statistics/StatisticsSettingsForm.php index d1bb1c4..5bd9199 100644 --- a/core/modules/statistics/lib/Drupal/statistics/StatisticsSettingsForm.php +++ b/core/modules/statistics/lib/Drupal/statistics/StatisticsSettingsForm.php @@ -6,6 +6,7 @@ namespace Drupal\statistics; +use Drupal\Core\Config\Context\ContextInterface; use Drupal\system\SystemConfigFormBase; use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Extension\ModuleHandler; @@ -28,11 +29,14 @@ class StatisticsSettingsForm extends SystemConfigFormBase { * * @param \Drupal\Core\Config\ConfigFactory $config_factory * The factory for configuration objects. + * @param \Drupal\Core\Config\Context\ContextInterface $context + * The configuration context to use. * @param \Drupal\Core\Extension\ModuleHandler $module_handler * The module handler. */ - public function __construct(ConfigFactory $config_factory, ModuleHandler $module_handler) { - $this->configFactory = $config_factory; + public function __construct(ConfigFactory $config_factory, ContextInterface $context, ModuleHandler $module_handler) { + parent::__construct($config_factory, $context); + $this->moduleHandler = $module_handler; } @@ -42,6 +46,7 @@ public function __construct(ConfigFactory $config_factory, ModuleHandler $module public static function create(ContainerInterface $container) { return new static( $container->get('config.factory'), + $container->get('config.context.free'), $container->get('module_handler') ); } diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php b/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php index 3d3dfc7..20f1bdb 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php @@ -7,11 +7,9 @@ namespace Drupal\system\Form; -use Drupal\Core\Controller\ControllerInterface; use Drupal\Core\Datetime\Date; use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityControllerInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -29,14 +27,10 @@ class DateFormatDeleteForm extends EntityConfirmFormBase implements EntityContro /** * Constructs an DateFormatDeleteForm object. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler service. * @param \Drupal\Core\Datetime\Date $date_service * The date service. */ - public function __construct(ModuleHandlerInterface $module_handler, Date $date_service) { - parent::__construct($module_handler); - + public function __construct(Date $date_service) { $this->dateService = $date_service; } @@ -45,7 +39,6 @@ public function __construct(ModuleHandlerInterface $module_handler, Date $date_s */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('date') ); } diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php b/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php index d6aac67..8ae140c 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php @@ -11,7 +11,6 @@ use Drupal\Core\Ajax\ReplaceCommand; use Drupal\Core\Datetime\Date; use Drupal\Core\Entity\EntityControllerInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Entity\Query\QueryFactory; @@ -46,16 +45,12 @@ /** * Constructs a new date format form. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler. * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory * The entity query factory. * @param \Drupal\Core\Datetime\Date $date_service * The date service. */ - function __construct(ModuleHandlerInterface $module_handler, QueryFactory $query_factory, Date $date_service) { - parent::__construct($module_handler); - + function __construct(QueryFactory $query_factory, Date $date_service) { $date = new DrupalDateTime(); $this->patternType = $date->canUseIntl() ? DrupalDateTime::INTL : DrupalDateTime::PHP; @@ -68,7 +63,6 @@ function __construct(ModuleHandlerInterface $module_handler, QueryFactory $query */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('entity.query'), $container->get('date') ); diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php b/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php index d3de481..53ce314 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php @@ -11,7 +11,6 @@ use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Config\ConfigFactory; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; /** * Builds a form for enabling a module. @@ -34,6 +33,9 @@ class DateFormatLocalizeResetForm extends ConfirmFormBase implements ControllerI /** * Constructs a DateFormatLocalizeResetForm object. + * + * @param \Drupal\Core\Config\ConfigFactory $config_factory + * The config factory. */ public function __construct(ConfigFactory $config_factory) { $this->configFactory = $config_factory; @@ -92,10 +94,10 @@ public function getDescription() { * The language code. * */ - public function buildForm(array $form, array &$form_state, $langcode = NULL, Request $request = NULL) { + public function buildForm(array $form, array &$form_state, $langcode = NULL) { $this->language = language_load($langcode); - return parent::buildForm($form, $form_state, $request); + return parent::buildForm($form, $form_state); } /** diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesListConfirmForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesListConfirmForm.php index 8296ba6..986b4d6 100644 --- a/core/modules/system/lib/Drupal/system/Form/ModulesListConfirmForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ModulesListConfirmForm.php @@ -11,10 +11,8 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; -use Drupal\Core\StringTranslation\TranslationManager; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; /** * Builds a confirmation form for enabling modules with dependencies. @@ -36,20 +34,6 @@ class ModulesListConfirmForm extends ConfirmFormBase implements ControllerInterf protected $keyValueExpirable; /** - * The translation manager service. - * - * @var \Drupal\Core\StringTranslation\TranslationManager - */ - protected $translationManager; - - /** - * The request object. - * - * @var \Symfony\Component\HttpFoundation\Request - */ - protected $request; - - /** * An associative list of modules to enable or disable. * * @var array @@ -57,37 +41,33 @@ class ModulesListConfirmForm extends ConfirmFormBase implements ControllerInterf protected $modules = array(); /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('module_handler'), - $container->get('keyvalue.expirable')->get('module_list'), - $container->get('string_translation') - ); - } - - /** * Constructs a ModulesListConfirmForm object. * * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. * @param \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface $key_value_expirable * The key value expirable factory. - * @param \Drupal\Core\StringTranslation\TranslationManager - * The translation manager. */ - public function __construct(ModuleHandlerInterface $module_handler, KeyValueStoreExpirableInterface $key_value_expirable, TranslationManager $translation_manager) { + public function __construct(ModuleHandlerInterface $module_handler, KeyValueStoreExpirableInterface $key_value_expirable) { $this->moduleHandler = $module_handler; $this->keyValueExpirable = $key_value_expirable; - $this->translationManager = $translation_manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('module_handler'), + $container->get('keyvalue.expirable')->get('module_list') + ); } /** * {@inheritdoc} */ public function getQuestion() { - return $this->translationManager->translate('Some required modules must be enabled'); + return $this->t('Some required modules must be enabled'); } /** @@ -101,14 +81,14 @@ public function getCancelPath() { * {@inheritdoc} */ public function getConfirmText() { - return $this->translationManager->translate('Continue'); + return $this->t('Continue'); } /** * {@inheritdoc} */ public function getDescription() { - return $this->translationManager->translate('Would you like to continue with the above?'); + return $this->t('Would you like to continue with the above?'); } /** @@ -121,8 +101,8 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Request $request = NULL) { - $account = $request->attributes->get('_account')->id(); + public function buildForm(array $form, array &$form_state) { + $account = $this->getCurrentUser()->id(); $this->modules = $this->keyValueExpirable->get($account); // Redirect to the modules list page if the key value store is empty. @@ -130,9 +110,6 @@ public function buildForm(array $form, array &$form_state, Request $request = NU return new RedirectResponse(url($this->getCancelPath(), array('absolute' => TRUE))); } - // Store the request for use in the submit handler. - $this->request = $request; - $items = array(); // Display a list of required modules that have to be installed as well but // were not manually selected. @@ -155,7 +132,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU '#items' => $items, ); - return parent::buildForm($form, $form_state, $this->request); + return parent::buildForm($form, $form_state); } /** @@ -163,7 +140,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU */ public function submitForm(array &$form, array &$form_state) { // Remove the key value store entry. - $account = $this->request->attributes->get('_account')->id(); + $account = $this->getCurrentUser()->id(); $this->keyValueExpirable->delete($account); // Gets list of modules prior to install process. @@ -181,7 +158,7 @@ public function submitForm(array &$form, array &$form_state) { // message if there are changes. if ($before != $this->moduleHandler->getModuleList()) { drupal_flush_all_caches(); - drupal_set_message($this->translationManager->translate('The configuration options have been saved.')); + drupal_set_message($this->t('The configuration options have been saved.')); } $form_state['redirect'] = $this->getCancelPath(); diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php index c699c09..267b6fd 100644 --- a/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php @@ -9,13 +9,10 @@ use Drupal\Core\Controller\ControllerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Form\FormInterface; -use Drupal\Core\KeyValueStore\KeyValueExpirableFactory; +use Drupal\Core\Form\FormBase; use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; -use Drupal\Core\StringTranslation\TranslationManager; use Drupal\Component\Utility\Unicode; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; /** * Provides module enable/disable interface. @@ -25,7 +22,7 @@ * requires. See drupal_parse_info_file() for info on module.info.yml * descriptors. */ -class ModulesListForm implements FormInterface, ControllerInterface { +class ModulesListForm extends FormBase implements ControllerInterface { /** * The module handler service. @@ -42,27 +39,12 @@ class ModulesListForm implements FormInterface, ControllerInterface { protected $keyValueExpirable; /** - * The translation manager service. - * - * @var \Drupal\Core\StringTranslation\TranslationManager - */ - protected $translationManager; - - /** - * The request object. - * - * @var \Symfony\Component\HttpFoundation\Request - */ - protected $request; - - /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( $container->get('module_handler'), - $container->get('keyvalue.expirable')->get('module_list'), - $container->get('string_translation') + $container->get('keyvalue.expirable')->get('module_list') ); } @@ -73,13 +55,10 @@ public static function create(ContainerInterface $container) { * The module handler. * @param \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface $key_value_expirable * The key value expirable factory. - * @param \Drupal\Core\StringTranslation\TranslationManager - * The translation manager. */ - public function __construct(ModuleHandlerInterface $module_handler, KeyValueStoreExpirableInterface $key_value_expirable, TranslationManager $translation_manager) { + public function __construct(ModuleHandlerInterface $module_handler, KeyValueStoreExpirableInterface $key_value_expirable) { $this->moduleHandler = $module_handler; $this->keyValueExpirable = $key_value_expirable; - $this->translationManager = $translation_manager; } /** @@ -92,16 +71,13 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Request $request = NULL) { + public function buildForm(array $form, array &$form_state) { require_once DRUPAL_ROOT . '/core/includes/install.inc'; $distribution = check_plain(drupal_install_profile_distribution_name()); // Include system.admin.inc so we can use the sort callbacks. $this->moduleHandler->loadInclude('system', 'inc', 'system.admin'); - // Store the request for use in the submit handler. - $this->request = $request; - $form['filters'] = array( '#type' => 'container', '#attributes' => array( @@ -111,14 +87,14 @@ public function buildForm(array $form, array &$form_state, Request $request = NU $form['filters']['text'] = array( '#type' => 'search', - '#title' => $this->translationManager->translate('Search'), + '#title' => $this->t('Search'), '#size' => 30, - '#placeholder' => $this->translationManager->translate('Enter module name'), + '#placeholder' => $this->t('Enter module name'), '#attributes' => array( 'class' => array('table-filter-text'), 'data-table' => '#system-modules', 'autocomplete' => 'off', - 'title' => $this->translationManager->translate('Enter a part of the module name or description to filter by.'), + 'title' => $this->t('Enter a part of the module name or description to filter by.'), ), ); @@ -139,12 +115,12 @@ public function buildForm(array $form, array &$form_state, Request $request = NU foreach (element_children($form['modules']) as $package) { $form['modules'][$package] += array( '#type' => 'details', - '#title' => $this->translationManager->translate($package), + '#title' => $this->t($package), '#theme' => 'system_modules_details', '#header' => array( - array('data' => '' . $this->translationManager->translate('Enabled') . '', 'class' => array('checkbox')), - array('data' => $this->translationManager->translate('Name'), 'class' => array('name')), - array('data' => $this->translationManager->translate('Description'), 'class' => array('description', RESPONSIVE_PRIORITY_LOW)), + array('data' => '' . $this->t('Enabled') . '', 'class' => array('checkbox')), + array('data' => $this->t('Name'), 'class' => array('name')), + array('data' => $this->t('Description'), 'class' => array('description', RESPONSIVE_PRIORITY_LOW)), ), '#attributes' => array('class' => array('package-listing')), // Ensure that the "Core" package comes first. @@ -159,7 +135,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', - '#value' => $this->translationManager->translate('Save configuration'), + '#value' => $this->t('Save configuration'), ); return $form; @@ -184,7 +160,7 @@ protected function buildRow(array $modules, $module, $distribution) { $row['#required_by'] = array(); $row['name']['#markup'] = $module->info['name']; - $row['description']['#markup'] = $this->translationManager->translate($module->info['description']); + $row['description']['#markup'] = $this->t($module->info['description']); $row['version']['#markup'] = $module->info['version']; // Add links for each module. @@ -197,9 +173,9 @@ protected function buildRow(array $modules, $module, $distribution) { if ($this->moduleHandler->invoke($module->name, 'help', array("admin/help#$module->name", $help))) { $row['links']['help'] = array( '#type' => 'link', - '#title' => $this->translationManager->translate('Help'), + '#title' => $this->t('Help'), '#href' => "admin/help/$module->name", - '#options' => array('attributes' => array('class' => array('module-link', 'module-link-help'), 'title' => $this->translationManager->translate('Help'))), + '#options' => array('attributes' => array('class' => array('module-link', 'module-link-help'), 'title' => $this->t('Help'))), ); } } @@ -209,9 +185,9 @@ protected function buildRow(array $modules, $module, $distribution) { if ($module->status && user_access('administer permissions') && in_array($module->name, $this->moduleHandler->getImplementations('permission'))) { $row['links']['permissions'] = array( '#type' => 'link', - '#title' => $this->translationManager->translate('Permissions'), + '#title' => $this->t('Permissions'), '#href' => 'admin/people/permissions', - '#options' => array('fragment' => 'module-' . $module->name, 'attributes' => array('class' => array('module-link', 'module-link-permissions'), 'title' => $this->translationManager->translate('Configure permissions'))), + '#options' => array('fragment' => 'module-' . $module->name, 'attributes' => array('class' => array('module-link', 'module-link-permissions'), 'title' => $this->t('Configure permissions'))), ); } @@ -221,7 +197,7 @@ protected function buildRow(array $modules, $module, $distribution) { if (($configure = menu_get_item($module->info['configure'])) && $configure['access']) { $row['links']['configure'] = array( '#type' => 'link', - '#title' => $this->translationManager->translate('Configure'), + '#title' => $this->t('Configure'), '#href' => $configure['href'], '#options' => array('attributes' => array('class' => array('module-link', 'module-link-configure'), 'title' => $configure['description'])), ); @@ -231,7 +207,7 @@ protected function buildRow(array $modules, $module, $distribution) { // Present a checkbox for installing and indicating the status of a module. $row['enable'] = array( '#type' => 'checkbox', - '#title' => $this->translationManager->translate('Enable'), + '#title' => $this->t('Enable'), '#default_value' => (bool) $module->status, ); @@ -249,7 +225,7 @@ protected function buildRow(array $modules, $module, $distribution) { // Check the core compatibility. if ($module->info['core'] != DRUPAL_CORE_COMPATIBILITY) { $compatible = FALSE; - $status .= $this->translationManager->translate('This version is not compatible with Drupal !core_version and should be replaced.', array( + $status .= $this->t('This version is not compatible with Drupal !core_version and should be replaced.', array( '!core_version' => DRUPAL_CORE_COMPATIBILITY, )); } @@ -258,7 +234,7 @@ protected function buildRow(array $modules, $module, $distribution) { if (version_compare(phpversion(), $module->info['php']) < 0) { $compatible = FALSE; $required = $module->info['php'] . (substr_count($module->info['php'], '.') < 2 ? '.*' : ''); - $status .= $this->translationManager->translate('This module requires PHP version @php_required and is incompatible with PHP version !php_version.', array( + $status .= $this->t('This module requires PHP version @php_required and is incompatible with PHP version !php_version.', array( '@php_required' => $required, '!php_version' => phpversion(), )); @@ -276,7 +252,7 @@ protected function buildRow(array $modules, $module, $distribution) { // If this module requires other modules, add them to the array. foreach ($module->requires as $dependency => $version) { if (!isset($modules[$dependency])) { - $row['#requires'][$dependency] = $this->translationManager->translate('@module (missing)', array('@module' => Unicode::ucfirst($dependency))); + $row['#requires'][$dependency] = $this->t('@module (missing)', array('@module' => Unicode::ucfirst($dependency))); $row['enable']['#disabled'] = TRUE; } // Only display visible modules. @@ -285,7 +261,7 @@ protected function buildRow(array $modules, $module, $distribution) { // Disable the module's checkbox if it is incompatible with the // dependency's version. if ($incompatible_version = drupal_check_incompatibility($version, str_replace(DRUPAL_CORE_COMPATIBILITY . '-', '', $modules[$dependency]->info['version']))) { - $row['#requires'][$dependency] = $this->translationManager->translate('@module (incompatible with version @version)', array( + $row['#requires'][$dependency] = $this->t('@module (incompatible with version @version)', array( '@module' => $name . $incompatible_version, '@version' => $modules[$dependency]->info['version'], )); @@ -294,16 +270,16 @@ protected function buildRow(array $modules, $module, $distribution) { // Disable the checkbox if the dependency is incompatible with this // version of Drupal core. elseif ($modules[$dependency]->info['core'] != DRUPAL_CORE_COMPATIBILITY) { - $row['#requires'][$dependency] = $this->translationManager->translate('@module (incompatible with this version of Drupal core)', array( + $row['#requires'][$dependency] = $this->t('@module (incompatible with this version of Drupal core)', array( '@module' => $name, )); $row['enable']['#disabled'] = TRUE; } elseif ($modules[$dependency]->status) { - $row['#requires'][$dependency] = $this->translationManager->translate('@module', array('@module' => $name)); + $row['#requires'][$dependency] = $this->t('@module', array('@module' => $name)); } else { - $row['#requires'][$dependency] = $this->translationManager->translate('@module (disabled)', array('@module' => $name)); + $row['#requires'][$dependency] = $this->t('@module (disabled)', array('@module' => $name)); } } } @@ -313,11 +289,11 @@ protected function buildRow(array $modules, $module, $distribution) { foreach ($module->required_by as $dependent => $version) { if (isset($modules[$dependent]) && empty($modules[$dependent]->info['hidden'])) { if ($modules[$dependent]->status == 1 && $module->status == 1) { - $row['#required_by'][$dependent] = $this->translationManager->translate('@module', array('@module' => $modules[$dependent]->info['name'])); + $row['#required_by'][$dependent] = $this->t('@module', array('@module' => $modules[$dependent]->info['name'])); $row['enable']['#disabled'] = TRUE; } else { - $row['#required_by'][$dependent] = $this->translationManager->translate('@module (disabled)', array('@module' => $modules[$dependent]->info['name'])); + $row['#required_by'][$dependent] = $this->t('@module (disabled)', array('@module' => $modules[$dependent]->info['name'])); } } } @@ -412,12 +388,6 @@ protected function buildModuleList(array $form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { - } - - /** - * {@inheritdoc} - */ public function submitForm(array &$form, array &$form_state) { // Retrieve a list of modules to enable/disable and their dependencies. $modules = $this->buildModuleList($form_state); @@ -426,7 +396,7 @@ public function submitForm(array &$form, array &$form_state) { // dependencies that are not enabled yet, redirect to the confirmation form. if (!empty($modules['dependencies']) || !empty($modules['missing'])) { // Write the list of changed module states into a key value store. - $account = $this->request->attributes->get('_account')->id(); + $account = $this->getCurrentUser()->id(); $this->keyValueExpirable->setWithExpire($account, $modules, 60); // Redirect to the confirmation form. diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmForm.php index 463eb5a..e8ebd46 100644 --- a/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmForm.php @@ -8,12 +8,9 @@ namespace Drupal\system\Form; use Drupal\Core\Form\ConfirmFormBase; -use Drupal\Core\StringTranslation\TranslationManager; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Controller\ControllerInterface; -use Drupal\Core\KeyValueStore\KeyValueExpirableFactory; use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; use Drupal\Core\Extension\ModuleHandlerInterface; @@ -37,20 +34,6 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase implements ControllerI protected $keyValueExpirable; /** - * The translation manager service. - * - * @var \Drupal\Core\StringTranslation\TranslationManager - */ - protected $translationManager; - - /** - * The request object. - * - * @var \Symfony\Component\HttpFoundation\Request - */ - protected $request; - - /** * An array of modules to uninstall. * * @var array @@ -58,44 +41,40 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase implements ControllerI protected $modules = array(); /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('module_handler'), - $container->get('keyvalue.expirable')->get('modules_uninstall'), - $container->get('string_translation') - ); - } - - /** * Constructs a ModulesUninstallConfirmForm object. * * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. * @param \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface $key_value_expirable * The key value expirable factory. - * @param \Drupal\Core\StringTranslation\TranslationManager - * The translation manager. */ - public function __construct(ModuleHandlerInterface $module_handler, KeyValueStoreExpirableInterface $key_value_expirable, TranslationManager $translation_manager) { + public function __construct(ModuleHandlerInterface $module_handler, KeyValueStoreExpirableInterface $key_value_expirable) { $this->moduleHandler = $module_handler; $this->keyValueExpirable = $key_value_expirable; - $this->translationManager = $translation_manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('module_handler'), + $container->get('keyvalue.expirable')->get('modules_uninstall') + ); } /** * {@inheritdoc} */ public function getQuestion() { - return $this->translationManager->translate('Confirm uninstall'); + return $this->t('Confirm uninstall'); } /** * {@inheritdoc} */ public function getConfirmText() { - return $this->translationManager->translate('Uninstall'); + return $this->t('Uninstall'); } /** @@ -109,7 +88,7 @@ public function getCancelPath() { * {@inheritdoc} */ public function getDescription() { - return $this->translationManager->translate('Would you like to continue with uninstalling the above?'); + return $this->t('Would you like to continue with uninstalling the above?'); } /** @@ -122,12 +101,9 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Request $request = NULL) { - // Store the request for use in the submit handler. - $this->request = $request; - + public function buildForm(array $form, array &$form_state) { // Retrieve the list of modules from the key value store. - $account = $request->attributes->get('_account')->id(); + $account = $this->getCurrentUser()->id(); $this->modules = $this->keyValueExpirable->get($account); // Prevent this page from showing when the module list is empty. @@ -136,7 +112,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU } $data = system_rebuild_module_data(); - $form['text']['#markup'] = '' . $this->translationManager->translate('The following modules will be completely uninstalled from your site, and all data from these modules will be lost!') . '
'; + $form['text']['#markup'] = '' . $this->t('The following modules will be completely uninstalled from your site, and all data from these modules will be lost!') . '
'; $form['modules'] = array( '#theme' => 'item_list', '#items' => array_map(function ($module) use ($data) { @@ -144,7 +120,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU }, $this->modules), ); - return parent::buildForm($form, $form_state, $request); + return parent::buildForm($form, $form_state); } /** @@ -152,13 +128,13 @@ public function buildForm(array $form, array &$form_state, Request $request = NU */ public function submitForm(array &$form, array &$form_state) { // Clear the key value store entry. - $account = $this->request->attributes->get('_account')->id(); + $account = $this->getCurrentUser()->id(); $this->keyValueExpirable->delete($account); // Uninstall the modules. $this->moduleHandler->uninstall($this->modules); - drupal_set_message($this->translationManager->translate('The selected modules have been uninstalled.')); + drupal_set_message($this->t('The selected modules have been uninstalled.')); $form_state['redirect'] = 'admin/modules/uninstall'; } diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesUninstallForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesUninstallForm.php index a6b3dea..859da70 100644 --- a/core/modules/system/lib/Drupal/system/Form/ModulesUninstallForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ModulesUninstallForm.php @@ -7,19 +7,16 @@ namespace Drupal\system\Form; -use Drupal\Core\Form\FormInterface; -use Drupal\Core\StringTranslation\TranslationManager; -use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Controller\ControllerInterface; -use Drupal\Core\KeyValueStore\KeyValueExpirableFactory; -use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; use Drupal\Core\Extension\ModuleHandlerInterface; -use Symfony\Component\HttpFoundation\Request; +use Drupal\Core\Form\FormBase; +use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides a form for uninstalling modules. */ -class ModulesUninstallForm implements FormInterface, ControllerInterface { +class ModulesUninstallForm extends FormBase implements ControllerInterface { /** * The module handler service. @@ -36,27 +33,12 @@ class ModulesUninstallForm implements FormInterface, ControllerInterface { protected $keyValueExpirable; /** - * The translation manager service. - * - * @var \Drupal\Core\StringTranslation\TranslationManager - */ - protected $translationManager; - - /** - * The request object. - * - * @var \Symfony\Component\HttpFoundation\Request - */ - protected $request; - - /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( $container->get('module_handler'), - $container->get('keyvalue.expirable')->get('modules_uninstall'), - $container->get('string_translation') + $container->get('keyvalue.expirable')->get('modules_uninstall') ); } @@ -67,13 +49,10 @@ public static function create(ContainerInterface $container) { * The module handler. * @param \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface $key_value_expirable * The key value expirable factory. - * @param \Drupal\Core\StringTranslation\TranslationManager $translation_manager - * The translation manager. */ - public function __construct(ModuleHandlerInterface $module_handler, KeyValueStoreExpirableInterface $key_value_expirable, TranslationManager $translation_manager) { + public function __construct(ModuleHandlerInterface $module_handler, KeyValueStoreExpirableInterface $key_value_expirable) { $this->moduleHandler = $module_handler; $this->keyValueExpirable = $key_value_expirable; - $this->translationManager = $translation_manager; } /** @@ -86,10 +65,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Request $request = NULL) { - // Store the request for use in the submit handler. - $this->request = $request; - + public function buildForm(array $form, array &$form_state) { // Make sure the install API is available. include_once DRUPAL_ROOT . '/core/includes/install.inc'; @@ -118,11 +94,11 @@ public function buildForm(array $form, array &$form_state, Request $request = NU $name = $module->info['name'] ?: $module->name; $form['modules'][$module->name]['#module_name'] = $name; $form['modules'][$module->name]['name']['#markup'] = $name; - $form['modules'][$module->name]['description']['#markup'] = $this->translationManager->translate($module->info['description']); + $form['modules'][$module->name]['description']['#markup'] = $this->t($module->info['description']); $form['uninstall'][$module->name] = array( '#type' => 'checkbox', - '#title' => $this->translationManager->translate('Uninstall @module module', array('@module' => $name)), + '#title' => $this->t('Uninstall @module module', array('@module' => $name)), '#title_display' => 'invisible', ); @@ -141,7 +117,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', - '#value' => $this->translationManager->translate('Uninstall'), + '#value' => $this->t('Uninstall'), ); return $form; @@ -153,7 +129,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU public function validateForm(array &$form, array &$form_state) { // Form submitted, but no modules selected. if (!array_filter($form_state['values']['uninstall'])) { - drupal_set_message($this->translationManager->translate('No modules selected.'), 'error'); + drupal_set_message($this->t('No modules selected.'), 'error'); $form_state['redirect'] = 'admin/modules/uninstall'; } } @@ -165,7 +141,7 @@ public function submitForm(array &$form, array &$form_state) { // Save all the values in an expirable key value store. $modules = $form_state['values']['uninstall']; $uninstall = array_keys(array_filter($modules)); - $account = $this->request->attributes->get('_account')->id(); + $account = $this->getCurrentUser()->id(); $this->keyValueExpirable->setWithExpire($account, $uninstall, 60); // Redirect to the confirm form. diff --git a/core/modules/system/lib/Drupal/system/Form/ThemeSettingsForm.php b/core/modules/system/lib/Drupal/system/Form/ThemeSettingsForm.php index 216d0d1..4312241 100644 --- a/core/modules/system/lib/Drupal/system/Form/ThemeSettingsForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ThemeSettingsForm.php @@ -34,7 +34,7 @@ class ThemeSettingsForm extends SystemConfigFormBase { * The factory for configuration objects. * @param \Drupal\Core\Config\Context\ContextInterface $context * The configuration context to use. - * @param Drupal\Core\Extension\ModuleHandlerInterface + * @param \Drupal\Core\Extension\ModuleHandlerInterface * The module handler instance to use. */ public function __construct(ConfigFactory $config_factory, ContextInterface $context, ModuleHandlerInterface $module_handler) { diff --git a/core/modules/system/lib/Drupal/system/SystemConfigFormBase.php b/core/modules/system/lib/Drupal/system/SystemConfigFormBase.php index eb82bdc..da7a32c 100644 --- a/core/modules/system/lib/Drupal/system/SystemConfigFormBase.php +++ b/core/modules/system/lib/Drupal/system/SystemConfigFormBase.php @@ -7,7 +7,7 @@ namespace Drupal\system; -use Drupal\Core\Form\FormInterface; +use Drupal\Core\Form\FormBase; use Drupal\Core\Controller\ControllerInterface; use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\Context\ContextInterface; @@ -16,7 +16,7 @@ /** * Base class for implementing system configuration forms. */ -abstract class SystemConfigFormBase implements FormInterface, ControllerInterface { +abstract class SystemConfigFormBase extends FormBase implements ControllerInterface { /** * Stores the configuration factory. @@ -55,7 +55,7 @@ public function buildForm(array $form, array &$form_state) { $form['actions']['#type'] = 'actions'; $form['actions']['submit'] = array( '#type' => 'submit', - '#value' => t('Save configuration'), + '#value' => $this->t('Save configuration'), '#button_type' => 'primary', ); @@ -66,16 +66,10 @@ public function buildForm(array $form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::validateForm(). - */ - public function validateForm(array &$form, array &$form_state) { - } - - /** * Implements \Drupal\Core\Form\FormInterface::submitForm(). */ public function submitForm(array &$form, array &$form_state) { - drupal_set_message(t('The configuration options have been saved.')); + drupal_set_message($this->t('The configuration options have been saved.')); } } diff --git a/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/ConfirmFormTestForm.php b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/ConfirmFormTestForm.php index f18ffa2..e1a3097 100644 --- a/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/ConfirmFormTestForm.php +++ b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/ConfirmFormTestForm.php @@ -8,7 +8,6 @@ namespace Drupal\form_test; use Drupal\Core\Form\ConfirmFormBase; -use Symfony\Component\HttpFoundation\Request; /** * Provides a test confirmation form. @@ -60,10 +59,10 @@ public function getCancelText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Request $request = NULL) { + public function buildForm(array $form, array &$form_state) { $form['element'] = array('#markup' => 'The ConfirmFormTestForm::buildForm() method was used for this form.
'); - return parent::buildForm($form, $form_state, $request); + return parent::buildForm($form, $form_state); } /** diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php index fe8dffb..80513ed 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php @@ -11,7 +11,6 @@ use Drupal\Core\Entity\EntityControllerInterface; use Drupal\taxonomy\VocabularyStorageControllerInterface; use Drupal\Core\Entity\EntityNGConfirmFormBase; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Cache\Cache; /** @@ -29,11 +28,10 @@ class TermDeleteForm extends EntityNGConfirmFormBase implements EntityController /** * Constructs a new TermDelete object. * - * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage_controller + * @param \Drupal\taxonomy\VocabularyStorageControllerInterface $storage_controller * The Entity manager. */ - public function __construct(ModuleHandlerInterface $module_handler, VocabularyStorageControllerInterface $storage_controller) { - parent::__construct($module_handler); + public function __construct(VocabularyStorageControllerInterface $storage_controller) { $this->vocabularyStorageController = $storage_controller; } @@ -42,7 +40,6 @@ public function __construct(ModuleHandlerInterface $module_handler, VocabularySt */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('plugin.manager.entity')->getStorageController('taxonomy_vocabulary') ); } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyResetForm.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyResetForm.php index 4366cb2..317487b 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyResetForm.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyResetForm.php @@ -10,9 +10,7 @@ use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityControllerInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; /** * Provides confirmation form for resetting a vocabulary to alphabetical order. @@ -29,9 +27,7 @@ class VocabularyResetForm extends EntityConfirmFormBase implements EntityControl /** * Constructs a new VocabularyResetForm object. */ - public function __construct(ModuleHandlerInterface $module_handler, Connection $connection) { - parent::__construct($module_handler); - + public function __construct(Connection $connection) { $this->connection = $connection; } @@ -40,7 +36,6 @@ public function __construct(ModuleHandlerInterface $module_handler, Connection $ */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('database') ); } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php index 0c92528..406b756 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php @@ -205,4 +205,5 @@ public function delete(array $form, array &$form_state) { } $form_state['redirect'] = array('taxonomy/term/' . $this->entity->id() . '/delete', array('query' => $destination)); } + } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Form/BreakLockForm.php b/core/modules/views_ui/lib/Drupal/views_ui/Form/BreakLockForm.php index a161caf..27a6e6e 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Form/BreakLockForm.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Form/BreakLockForm.php @@ -12,7 +12,6 @@ use Drupal\Core\Entity\EntityManager; use Drupal\user\TempStoreFactory; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; /** * Builds the form to break the lock of an edited view. @@ -100,12 +99,12 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Request $request = NULL) { + public function buildForm(array $form, array &$form_state) { if (!$this->tempStore->getMetadata($this->entity->id())) { $form['message']['#markup'] = t('There is no lock on view %name to break.', array('%name' => $this->entity->id())); return $form; } - return parent::buildForm($form, $form_state, $request); + return parent::buildForm($form, $form_state); } /** diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php index 4ad9376..53920b4 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php @@ -8,7 +8,6 @@ namespace Drupal\views_ui; use Drupal\Core\Entity\EntityControllerInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\views\Plugin\views\wizard\WizardPluginBase; use Drupal\views\Plugin\views\wizard\WizardException; use Drupal\views\Plugin\ViewsPluginManager; @@ -29,14 +28,10 @@ class ViewAddFormController extends ViewFormControllerBase implements EntityCont /** * Constructs a new ViewEditFormController object. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface - * The module handler service. * @param \Drupal\views\Plugin\ViewsPluginManager $wizard_manager * The wizard plugin manager. */ - public function __construct(ModuleHandlerInterface $module_handler, ViewsPluginManager $wizard_manager) { - parent::__construct($module_handler); - + public function __construct(ViewsPluginManager $wizard_manager) { $this->wizardManager = $wizard_manager; } @@ -45,7 +40,6 @@ public function __construct(ModuleHandlerInterface $module_handler, ViewsPluginM */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('plugin.manager.views.wizard') ); } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php index 6048d35..ae36441 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php @@ -10,9 +10,7 @@ use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\HtmlCommand; use Drupal\Core\Ajax\ReplaceCommand; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Component\Utility\NestedArray; -use Drupal\views\ViewExecutable; use Drupal\Core\Entity\EntityControllerInterface; use Drupal\user\TempStoreFactory; use Symfony\Component\HttpFoundation\Request; @@ -40,16 +38,12 @@ class ViewEditFormController extends ViewFormControllerBase implements EntityCon /** * Constructs a new ViewEditFormController object. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface - * The module handler service. * @param \Drupal\user\TempStoreFactory $temp_store_factory * The factory for the temp store object. * @param \Symfony\Component\HttpFoundation\Request $request * The request object. */ - public function __construct(ModuleHandlerInterface $module_handler, TempStoreFactory $temp_store_factory, Request $request) { - parent::__construct($module_handler); - + public function __construct(TempStoreFactory $temp_store_factory, Request $request) { $this->tempStore = $temp_store_factory->get('views'); $this->request = $request; } @@ -59,7 +53,6 @@ public function __construct(ModuleHandlerInterface $module_handler, TempStoreFac */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info, $operation = NULL) { return new static( - $container->get('module_handler'), $container->get('user.tempstore'), $container->get('request') ); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewPreviewFormController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewPreviewFormController.php index de4bd60..c714b08 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewPreviewFormController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewPreviewFormController.php @@ -8,7 +8,6 @@ namespace Drupal\views_ui; use Drupal\Core\Entity\EntityControllerInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\user\TempStoreFactory; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -27,14 +26,10 @@ class ViewPreviewFormController extends ViewFormControllerBase implements Entity /** * Constructs a new ViewPreviewFormController object. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface - * The module handler service. * @param \Drupal\user\TempStoreFactory $temp_store_factory * The factory for the temp store object. */ - public function __construct(ModuleHandlerInterface $module_handler, TempStoreFactory $temp_store_factory) { - parent::__construct($module_handler); - + public function __construct(TempStoreFactory $temp_store_factory) { $this->tempStore = $temp_store_factory->get('views'); } @@ -43,7 +38,6 @@ public function __construct(ModuleHandlerInterface $module_handler, TempStoreFac */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( - $container->get('module_handler'), $container->get('user.tempstore') ); }