Issue #2059245 by tim.plunkett, msonnabaum: Add a FormBase class containing useful methods.

8.0.x
Alex Pott 2013-08-22 03:02:00 +01:00
parent 5460c03e89
commit 410d56a7ba
57 changed files with 496 additions and 682 deletions

View File

@ -159,7 +159,7 @@ services:
- { name: persist } - { name: persist }
plugin.manager.entity: plugin.manager.entity:
class: Drupal\Core\Entity\EntityManager class: Drupal\Core\Entity\EntityManager
arguments: ['@container.namespaces', '@service_container', '@module_handler', '@cache.cache', '@language_manager'] arguments: ['@container.namespaces', '@service_container', '@module_handler', '@cache.cache', '@language_manager', '@string_translation']
plugin.manager.entity.field.field_type: plugin.manager.entity.field.field_type:
class: Drupal\Core\Entity\Field\FieldTypePluginManager class: Drupal\Core\Entity\Field\FieldTypePluginManager
arguments: ['@container.namespaces', '@cache.entity', '@language_manager', '@module_handler'] arguments: ['@container.namespaces', '@cache.entity', '@language_manager', '@module_handler']

View File

@ -7,6 +7,7 @@
namespace Drupal\Core\Entity; namespace Drupal\Core\Entity;
use Drupal\Component\Utility\Url;
use Drupal\Core\Form\ConfirmFormInterface; use Drupal\Core\Form\ConfirmFormInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -15,13 +16,6 @@ use Symfony\Component\HttpFoundation\Request;
*/ */
abstract class EntityConfirmFormBase extends EntityFormController implements ConfirmFormInterface { abstract class EntityConfirmFormBase extends EntityFormController implements ConfirmFormInterface {
/**
* The request object.
*
* @var \Symfony\Component\HttpFoundation\Request
*/
protected $request;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -60,8 +54,7 @@ abstract class EntityConfirmFormBase extends EntityFormController implements Con
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function buildForm(array $form, array &$form_state, Request $request = NULL) { public function buildForm(array $form, array &$form_state) {
$this->request = $request;
$form = parent::buildForm($form, $form_state); $form = parent::buildForm($form, $form_state);
$form['#attributes']['class'][] = 'confirmation'; $form['#attributes']['class'][] = 'confirmation';
@ -94,8 +87,9 @@ abstract class EntityConfirmFormBase extends EntityFormController implements Con
$path = $this->getCancelPath(); $path = $this->getCancelPath();
// Prepare cancel link. // Prepare cancel link.
if ($this->request->query->has('destination')) { $query = $this->getRequest()->query;
$options = drupal_parse_url($this->request->query->get('destination')); if ($query->has('destination')) {
$options = Url::parse($query->get('destination'));
} }
elseif (is_array($path)) { elseif (is_array($path)) {
$options = $path; $options = $path;

View File

@ -7,6 +7,7 @@
namespace Drupal\Core\Entity; namespace Drupal\Core\Entity;
use Drupal\Core\Form\FormBase;
use Drupal\entity\EntityFormDisplayInterface; use Drupal\entity\EntityFormDisplayInterface;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
@ -15,7 +16,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Base class for entity form controllers. * Base class for entity form controllers.
*/ */
class EntityFormController implements EntityFormControllerInterface { class EntityFormController extends FormBase implements EntityFormControllerInterface {
/** /**
* The name of the current operation. * The name of the current operation.
@ -41,36 +42,15 @@ class EntityFormController implements EntityFormControllerInterface {
*/ */
protected $entity; 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} * {@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) { public function setOperation($operation) {
// If NULL is passed, do not overwrite the operation. // If NULL is passed, do not overwrite the operation.
if ($operation) { if ($operation) {
$this->operation = $operation; $this->operation = $operation;
} }
return $this;
} }
/** /**
@ -126,12 +106,6 @@ class EntityFormController implements EntityFormControllerInterface {
return $form; return $form;
} }
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, array &$form_state) {
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -269,7 +243,7 @@ class EntityFormController implements EntityFormControllerInterface {
return array( return array(
// @todo Rename the action key from submit to save. // @todo Rename the action key from submit to save.
'submit' => array( 'submit' => array(
'#value' => t('Save'), '#value' => $this->t('Save'),
'#validate' => array( '#validate' => array(
array($this, 'validate'), array($this, 'validate'),
), ),
@ -279,7 +253,7 @@ class EntityFormController implements EntityFormControllerInterface {
), ),
), ),
'delete' => array( 'delete' => array(
'#value' => t('Delete'), '#value' => $this->t('Delete'),
// No need to validate the form when deleting the entity. // No need to validate the form when deleting the entity.
'#submit' => array( '#submit' => array(
array($this, 'delete'), array($this, 'delete'),
@ -566,4 +540,13 @@ class EntityFormController implements EntityFormControllerInterface {
public function getOperation() { public function getOperation() {
return $this->operation; return $this->operation;
} }
/**
* {@inheritdoc}
*/
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
return $this;
}
} }

View File

@ -7,7 +7,9 @@
namespace Drupal\Core\Entity; namespace Drupal\Core\Entity;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\BaseFormIdInterface; use Drupal\Core\Form\BaseFormIdInterface;
use Drupal\Core\StringTranslation\TranslationInterface;
use Drupal\entity\EntityFormDisplayInterface; use Drupal\entity\EntityFormDisplayInterface;
/** /**
@ -37,6 +39,17 @@ interface EntityFormControllerInterface extends BaseFormIdInterface {
*/ */
public function isDefaultFormLangcode(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. * Returns the operation identifying the form controller.
* *
@ -139,4 +152,26 @@ interface EntityFormControllerInterface extends BaseFormIdInterface {
*/ */
public function submit(array $form, array &$form_state); public function submit(array $form, array &$form_state);
/**
* Sets the translation manager for this form.
*
* @param \Drupal\Core\StringTranslation\TranslationInterface $translation_manager
* The translation manager.
*
* @return self
* The entity form.
*/
public function setTranslationManager(TranslationInterface $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);
} }

View File

@ -18,6 +18,7 @@ use Drupal\Core\Plugin\Discovery\CacheDecorator;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\InfoHookDecorator; use Drupal\Core\Plugin\Discovery\InfoHookDecorator;
use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\StringTranslation\TranslationInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
@ -87,6 +88,13 @@ class EntityManager extends PluginManagerBase {
*/ */
protected $fieldDefinitions; protected $fieldDefinitions;
/**
* The string translationManager.
*
* @var \Drupal\Core\StringTranslation\TranslationInterface
*/
protected $translationManager;
/** /**
* Constructs a new Entity plugin manager. * Constructs a new Entity plugin manager.
* *
@ -101,8 +109,10 @@ class EntityManager extends PluginManagerBase {
* The cache backend to use. * The cache backend to use.
* @param \Drupal\Core\Language\LanguageManager $language_manager * @param \Drupal\Core\Language\LanguageManager $language_manager
* The language manager. * The language manager.
* @param \Drupal\Core\StringTranslation\TranslationInterface $translation_manager
* The string translationManager.
*/ */
public function __construct(\Traversable $namespaces, ContainerInterface $container, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache, LanguageManager $language_manager) { public function __construct(\Traversable $namespaces, ContainerInterface $container, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache, LanguageManager $language_manager, TranslationInterface $translation_manager) {
// Allow the plugin definition to be altered by hook_entity_info_alter(). // Allow the plugin definition to be altered by hook_entity_info_alter().
$annotation_namespaces = array( $annotation_namespaces = array(
'Drupal\Core\Entity\Annotation' => DRUPAL_ROOT . '/core/lib', 'Drupal\Core\Entity\Annotation' => DRUPAL_ROOT . '/core/lib',
@ -111,6 +121,7 @@ class EntityManager extends PluginManagerBase {
$this->moduleHandler = $module_handler; $this->moduleHandler = $module_handler;
$this->cache = $cache; $this->cache = $cache;
$this->languageManager = $language_manager; $this->languageManager = $language_manager;
$this->translationManager = $translation_manager;
$this->discovery = new AnnotatedClassDiscovery('Entity', $namespaces, $annotation_namespaces, 'Drupal\Core\Entity\Annotation\EntityType'); $this->discovery = new AnnotatedClassDiscovery('Entity', $namespaces, $annotation_namespaces, 'Drupal\Core\Entity\Annotation\EntityType');
$this->discovery = new InfoHookDecorator($this->discovery, 'entity_info'); $this->discovery = new InfoHookDecorator($this->discovery, 'entity_info');
@ -229,13 +240,18 @@ class EntityManager extends PluginManagerBase {
public function getFormController($entity_type, $operation) { public function getFormController($entity_type, $operation) {
if (!isset($this->controllers['form'][$operation][$entity_type])) { if (!isset($this->controllers['form'][$operation][$entity_type])) {
$class = $this->getControllerClass($entity_type, 'form', $operation); $class = $this->getControllerClass($entity_type, 'form', $operation);
if (in_array('Drupal\Core\Entity\EntityControllerInterface', class_implements($class))) { if (in_array('Drupal\Core\Controller\ControllerInterface', class_implements($class))) {
$this->controllers['form'][$operation][$entity_type] = $class::createInstance($this->container, $entity_type, $this->getDefinition($entity_type)); $controller = $class::create($this->container);
} }
else { 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->translationManager)
->setModuleHandler($this->moduleHandler)
->setOperation($operation);
$this->controllers['form'][$operation][$entity_type] = $controller;
} }
return $this->controllers['form'][$operation][$entity_type]; return $this->controllers['form'][$operation][$entity_type];
} }

View File

@ -7,21 +7,14 @@
namespace Drupal\Core\Entity; namespace Drupal\Core\Entity;
use Drupal\Component\Utility\Url;
use Drupal\Core\Form\ConfirmFormInterface; use Drupal\Core\Form\ConfirmFormInterface;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Provides a generic base class for an entity-based confirmation form. * Provides a generic base class for an entity-based confirmation form.
*/ */
abstract class EntityNGConfirmFormBase extends EntityFormControllerNG implements ConfirmFormInterface { abstract class EntityNGConfirmFormBase extends EntityFormControllerNG implements ConfirmFormInterface {
/**
* The request object.
*
* @var \Symfony\Component\HttpFoundation\Request
*/
protected $request;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -60,8 +53,7 @@ abstract class EntityNGConfirmFormBase extends EntityFormControllerNG implements
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function buildForm(array $form, array &$form_state, Request $request = NULL) { public function buildForm(array $form, array &$form_state) {
$this->request = $request;
$form = parent::buildForm($form, $form_state); $form = parent::buildForm($form, $form_state);
$form['#attributes']['class'][] = 'confirmation'; $form['#attributes']['class'][] = 'confirmation';
@ -94,8 +86,9 @@ abstract class EntityNGConfirmFormBase extends EntityFormControllerNG implements
$path = $this->getCancelPath(); $path = $this->getCancelPath();
// Prepare cancel link. // Prepare cancel link.
if ($this->request->query->has('destination')) { $query = $this->getRequest()->query;
$options = drupal_parse_url($this->request->query->get('destination')); if ($query->has('destination')) {
$options = Url::parse($query->get('destination'));
} }
elseif (is_array($path)) { elseif (is_array($path)) {
$options = $path; $options = $path;

View File

@ -7,12 +7,12 @@
namespace Drupal\Core\Form; namespace Drupal\Core\Form;
use Symfony\Component\HttpFoundation\Request; use Drupal\Component\Utility\Url;
/** /**
* Provides an generic base class for a confirmation form. * Provides an generic base class for a confirmation form.
*/ */
abstract class ConfirmFormBase implements ConfirmFormInterface { abstract class ConfirmFormBase extends FormBase implements ConfirmFormInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -45,11 +45,12 @@ abstract class ConfirmFormBase implements ConfirmFormInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function buildForm(array $form, array &$form_state, Request $request = NULL) { public function buildForm(array $form, array &$form_state) {
$path = $this->getCancelPath(); $path = $this->getCancelPath();
// Prepare cancel link. // Prepare cancel link.
if ($request->query->has('destination')) { $query = $this->getRequest()->query;
$options = drupal_parse_url($request->query->get('destination')); if ($query->has('destination')) {
$options = Url::parse($query->get('destination'));
} }
elseif (is_array($path)) { elseif (is_array($path)) {
$options = $path; $options = $path;
@ -82,10 +83,4 @@ abstract class ConfirmFormBase implements ConfirmFormInterface {
return $form; return $form;
} }
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, array &$form_state) {
}
} }

View File

@ -0,0 +1,130 @@
<?php
/**
* @file
* Contains \Drupal\Core\Form\FormBase.
*/
namespace Drupal\Core\Form;
use Drupal\Core\Controller\ControllerInterface;
use Drupal\Core\StringTranslation\TranslationInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
/**
* Provides a base class for forms.
*/
abstract class FormBase implements FormInterface, ControllerInterface {
/**
* The translation manager service.
*
* @var \Drupal\Core\StringTranslation\TranslationInterface
*/
protected $translationManager;
/**
* The current request.
*
* @var \Symfony\Component\HttpFoundation\Request
*/
protected $request;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static();
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, array &$form_state) {
// Validation is optional.
}
/**
* Translates a string to the current language or to a given language.
*
* @param string $string
* A string containing the English string to translate.
* @param array $args
* An associative array of replacements to make after translation. Based
* on the first character of the key, the value is escaped and/or themed.
* See \Drupal\Core\Utility\String::format() for details.
* @param array $options
* An associative array of additional options, with the following elements:
* - 'langcode': The language code to translate to a language other than
* what is used to display the page.
* - 'context': The context the source string belongs to.
*
* @return string
* The translated string.
*/
protected function t($string, array $args = array(), array $options = array()) {
return $this->getTranslationManager()->translate($string, $args, $options);
}
/**
* Gets the translation manager.
*
* @return \Drupal\Core\StringTranslation\TranslationInterface
* The translation manager.
*/
protected function getTranslationManager() {
if (!$this->translationManager) {
$this->translationManager = \Drupal::translation();
}
return $this->translationManager;
}
/**
* Sets the translation manager for this form.
*
* @param \Drupal\Core\StringTranslation\TranslationInterface $translation_manager
* The translation manager.
*
* @return self
* The entity form.
*/
public function setTranslationManager(TranslationInterface $translation_manager) {
$this->translationManager = $translation_manager;
return $this;
}
/**
* Gets the request object.
*
* @return \Symfony\Component\HttpFoundation\Request $request
* The request object.
*/
protected 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.
*/
protected function getCurrentUser() {
return $this->getRequest()->attributes->get('_account');
}
}

View File

@ -9,15 +9,13 @@ namespace Drupal\action;
use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Crypt;
use Drupal\Core\Action\ActionManager; use Drupal\Core\Action\ActionManager;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityStorageControllerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Provides a form controller for action add forms. * Provides a form controller for action add forms.
*/ */
class ActionAddFormController extends ActionFormControllerBase implements EntityControllerInterface { class ActionAddFormController extends ActionFormControllerBase {
/** /**
* The action manager. * The action manager.
@ -29,15 +27,13 @@ class ActionAddFormController extends ActionFormControllerBase implements Entity
/** /**
* Constructs a new ActionAddFormController. * Constructs a new ActionAddFormController.
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface
* The module handler service.
* @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage_controller * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage_controller
* The action storage controller. * The action storage controller.
* @param \Drupal\Core\Action\ActionManager $action_manager * @param \Drupal\Core\Action\ActionManager $action_manager
* The action plugin manager. * The action plugin manager.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, EntityStorageControllerInterface $storage_controller, ActionManager $action_manager) { public function __construct(EntityStorageControllerInterface $storage_controller, ActionManager $action_manager) {
parent::__construct($module_handler, $storage_controller); parent::__construct($storage_controller);
$this->actionManager = $action_manager; $this->actionManager = $action_manager;
} }
@ -45,10 +41,9 @@ class ActionAddFormController extends ActionFormControllerBase implements Entity
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'), $container->get('plugin.manager.entity')->getStorageController('action'),
$container->get('plugin.manager.entity')->getStorageController($entity_type),
$container->get('plugin.manager.action') $container->get('plugin.manager.action')
); );
} }

View File

@ -7,9 +7,7 @@
namespace Drupal\action; namespace Drupal\action;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Entity\EntityFormController; use Drupal\Core\Entity\EntityFormController;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityStorageControllerInterface;
use Drupal\Core\Plugin\PluginFormInterface; use Drupal\Core\Plugin\PluginFormInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
@ -17,7 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Provides a base form controller for action forms. * Provides a base form controller for action forms.
*/ */
abstract class ActionFormControllerBase extends EntityFormController implements EntityControllerInterface { abstract class ActionFormControllerBase extends EntityFormController {
/** /**
* The action plugin being configured. * The action plugin being configured.
@ -36,24 +34,19 @@ abstract class ActionFormControllerBase extends EntityFormController implements
/** /**
* Constructs a new action form. * Constructs a new action form.
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface
* The module handler service.
* @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage_controller * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage_controller
* The action storage controller. * The action storage controller.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, EntityStorageControllerInterface $storage_controller) { public function __construct(EntityStorageControllerInterface $storage_controller) {
parent::__construct($module_handler);
$this->storageController = $storage_controller; $this->storageController = $storage_controller;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'), $container->get('plugin.manager.entity')->getStorageController('action')
$container->get('plugin.manager.entity')->getStorageController($entity_type)
); );
} }

View File

@ -13,10 +13,8 @@ use Drupal\Core\Entity\EntityManager;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\ConfirmFormBase;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
* Provides a confirm delete form. * Provides a confirm delete form.
*/ */
@ -50,13 +48,6 @@ class CategoryDeleteForm extends ConfirmFormBase implements ControllerInterface
*/ */
protected $categoryStorageController; protected $categoryStorageController;
/**
* The current request.
*
* @var \Symfony\Component\HttpFoundation\Request
*/
protected $request;
/** /**
* Creates a new CategoryDeleteForm. * Creates a new CategoryDeleteForm.
* *
@ -126,8 +117,6 @@ class CategoryDeleteForm extends ConfirmFormBase implements ControllerInterface
* An associative array containing the structure of the form. * An associative array containing the structure of the form.
* @param array $form_state * @param array $form_state
* An associative array containing the current state of the form. * An associative array containing the current state of the form.
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
* @param int|null $cid * @param int|null $cid
* The category ID. * The category ID.
* *
@ -137,14 +126,13 @@ class CategoryDeleteForm extends ConfirmFormBase implements ControllerInterface
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* If the cid param or category is not found. * 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); $category = $this->categoryStorageController->load($cid);
if (empty($cid) || empty($category)) { if (empty($cid) || empty($category)) {
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }
$this->category = $category; $this->category = $category;
$this->request = $request; return parent::buildForm($form, $form_state);
return parent::buildForm($form, $form_state, $request);
} }
/** /**
@ -158,7 +146,7 @@ class CategoryDeleteForm extends ConfirmFormBase implements ControllerInterface
$this->deleteBlocks($cid); $this->deleteBlocks($cid);
watchdog('aggregator', 'Category %category deleted.', array('%category' => $title)); watchdog('aggregator', 'Category %category deleted.', array('%category' => $title));
drupal_set_message(t('The category %category has been 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/'; $form_state['redirect'] = 'admin/config/services/aggregator/';
} }
else { else {

View File

@ -7,6 +7,7 @@
namespace Drupal\aggregator\Form; namespace Drupal\aggregator\Form;
use Drupal\Core\Config\Context\ContextInterface;
use Drupal\system\SystemConfigFormBase; use Drupal\system\SystemConfigFormBase;
use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\ConfigFactory;
use Drupal\aggregator\Plugin\AggregatorPluginManager; use Drupal\aggregator\Plugin\AggregatorPluginManager;
@ -40,6 +41,8 @@ class SettingsForm extends SystemConfigFormBase {
* *
* @param \Drupal\Core\Config\ConfigFactory $config_factory * @param \Drupal\Core\Config\ConfigFactory $config_factory
* The factory for configuration objects. * The factory for configuration objects.
* @param \Drupal\Core\Config\Context\ContextInterface $context
* The configuration context to use.
* @param \Drupal\aggregator\Plugin\AggregatorPluginManager $fetcher_manager * @param \Drupal\aggregator\Plugin\AggregatorPluginManager $fetcher_manager
* The aggregator fetcher plugin manager. * The aggregator fetcher plugin manager.
* @param \Drupal\aggregator\Plugin\AggregatorPluginManager $parser_manager * @param \Drupal\aggregator\Plugin\AggregatorPluginManager $parser_manager
@ -47,8 +50,9 @@ class SettingsForm extends SystemConfigFormBase {
* @param \Drupal\aggregator\Plugin\AggregatorPluginManager $processor_manager * @param \Drupal\aggregator\Plugin\AggregatorPluginManager $processor_manager
* The aggregator processor plugin manager. * The aggregator processor plugin manager.
*/ */
public function __construct(ConfigFactory $config_factory, AggregatorPluginManager $fetcher_manager, AggregatorPluginManager $parser_manager, AggregatorPluginManager $processor_manager) { public function __construct(ConfigFactory $config_factory, ContextInterface $context, AggregatorPluginManager $fetcher_manager, AggregatorPluginManager $parser_manager, AggregatorPluginManager $processor_manager) {
$this->configFactory = $config_factory; parent::__construct($config_factory, $context);
$this->managers = array( $this->managers = array(
'fetcher' => $fetcher_manager, 'fetcher' => $fetcher_manager,
'parser' => $parser_manager, 'parser' => $parser_manager,
@ -68,6 +72,7 @@ class SettingsForm extends SystemConfigFormBase {
public static function create(ContainerInterface $container) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('config.factory'), $container->get('config.factory'),
$container->get('config.context.free'),
$container->get('plugin.manager.aggregator.fetcher'), $container->get('plugin.manager.aggregator.fetcher'),
$container->get('plugin.manager.aggregator.parser'), $container->get('plugin.manager.aggregator.parser'),
$container->get('plugin.manager.aggregator.processor') $container->get('plugin.manager.aggregator.processor')

View File

@ -11,7 +11,6 @@ use Drupal\Core\Controller\ControllerInterface;
use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\ConfirmFormBase;
use Drupal\ban\BanIpManager; use Drupal\ban\BanIpManager;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
@ -30,6 +29,7 @@ class BanDelete extends ConfirmFormBase implements ControllerInterface {
* Constructs a new BanDelete object. * Constructs a new BanDelete object.
* *
* @param \Drupal\ban\BanIpManager $ip_manager * @param \Drupal\ban\BanIpManager $ip_manager
* The IP manager.
*/ */
public function __construct(BanIpManager $ip_manager) { public function __construct(BanIpManager $ip_manager) {
$this->ipManager = $ip_manager; $this->ipManager = $ip_manager;
@ -55,14 +55,14 @@ class BanDelete extends ConfirmFormBase implements ControllerInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getQuestion() { 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} * {@inheritdoc}
*/ */
public function getConfirmText() { public function getConfirmText() {
return t('Delete'); return $this->t('Delete');
} }
/** /**
@ -78,11 +78,11 @@ class BanDelete extends ConfirmFormBase implements ControllerInterface {
* @param string $ban_id * @param string $ban_id
* The IP address record ID to unban. * 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)) { if (!$this->banIp = $this->ipManager->findById($ban_id)) {
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }
return parent::buildForm($form, $form_state, $request); return parent::buildForm($form, $form_state);
} }
/** /**

View File

@ -8,16 +8,13 @@
namespace Drupal\custom_block\Form; namespace Drupal\custom_block\Form;
use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Provides a confirmation form for deleting a custom block type entity. * Provides a confirmation form for deleting a custom block type entity.
*/ */
class CustomBlockTypeDeleteForm extends EntityConfirmFormBase implements EntityControllerInterface { class CustomBlockTypeDeleteForm extends EntityConfirmFormBase {
/** /**
* The query factory to create entity queries. * The query factory to create entity queries.
@ -29,22 +26,18 @@ class CustomBlockTypeDeleteForm extends EntityConfirmFormBase implements EntityC
/** /**
* Constructs a query factory object. * Constructs a query factory object.
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface
* The module handler service.
* @param \Drupal\Core\Entity\Query\QueryFactory $query_factory * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory
* The entity query object. * The entity query object.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, QueryFactory $query_factory) { public function __construct(QueryFactory $query_factory) {
parent::__construct($module_handler);
$this->queryFactory = $query_factory; $this->queryFactory = $query_factory;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'),
$container->get('entity.query') $container->get('entity.query')
); );
} }
@ -73,7 +66,7 @@ class CustomBlockTypeDeleteForm extends EntityConfirmFormBase implements EntityC
/** /**
* {@inheritdoc} * {@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(); $blocks = $this->queryFactory->get('custom_block')->condition('type', $this->entity->id())->execute();
if (!empty($blocks)) { if (!empty($blocks)) {
$caption = '<p>' . 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())) . '</p>'; $caption = '<p>' . 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())) . '</p>';
@ -81,7 +74,7 @@ class CustomBlockTypeDeleteForm extends EntityConfirmFormBase implements EntityC
return $form; return $form;
} }
else { else {
return parent::buildForm($form, $form_state, $request); return parent::buildForm($form, $form_state);
} }
} }

View File

@ -7,18 +7,16 @@
namespace Drupal\block; namespace Drupal\block;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Entity\EntityFormController; use Drupal\Core\Entity\EntityFormController;
use Drupal\Core\Entity\EntityManager; use Drupal\Core\Entity\EntityManager;
use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Provides form controller for block instance forms. * Provides form controller for block instance forms.
*/ */
class BlockFormController extends EntityFormController implements EntityControllerInterface { class BlockFormController extends EntityFormController {
/** /**
* The block storage controller. * The block storage controller.
@ -37,16 +35,12 @@ class BlockFormController extends EntityFormController implements EntityControll
/** /**
* Constructs a BlockFormController object. * Constructs a BlockFormController object.
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface
* The module handler service.
* @param \Drupal\Core\Entity\EntityManager $entity_manager * @param \Drupal\Core\Entity\EntityManager $entity_manager
* The entity manager. * The entity manager.
* @param \Drupal\Core\Entity\Query\QueryFactory $entity_query_factory * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query_factory
* The entity query factory. * The entity query factory.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, EntityManager $entity_manager, QueryFactory $entity_query_factory) { public function __construct(EntityManager $entity_manager, QueryFactory $entity_query_factory) {
parent::__construct($module_handler);
$this->storageController = $entity_manager->getStorageController('block'); $this->storageController = $entity_manager->getStorageController('block');
$this->entityQueryFactory = $entity_query_factory; $this->entityQueryFactory = $entity_query_factory;
} }
@ -54,9 +48,8 @@ class BlockFormController extends EntityFormController implements EntityControll
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'),
$container->get('plugin.manager.entity'), $container->get('plugin.manager.entity'),
$container->get('entity.query') $container->get('entity.query')
); );

View File

@ -78,10 +78,7 @@ class BlockFormControllerTest extends UnitTestCase {
->method('getStorageController') ->method('getStorageController')
->will($this->returnValue($block_storage)); ->will($this->returnValue($block_storage));
$module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandlerInterface') $block_form_controller = new BlockFormController($entity_manager, $query_factory);
->getMock();
$block_form_controller = new BlockFormController($module_handler, $entity_manager, $query_factory);
// Ensure that the block with just one other instance gets the next available // Ensure that the block with just one other instance gets the next available
// name suggestion. // name suggestion.

View File

@ -7,25 +7,22 @@
namespace Drupal\config\Form; namespace Drupal\config\Form;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Drupal\Core\Entity\EntityManager;
use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Form\FormBase;
use Drupal\Core\Controller\ControllerInterface;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Config\StorageInterface; use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Lock\LockBackendInterface; use Drupal\Core\Lock\LockBackendInterface;
use Drupal\Core\Config\StorageComparer; use Drupal\Core\Config\StorageComparer;
use Drupal\Core\Config\ConfigImporter; use Drupal\Core\Config\ConfigImporter;
use Drupal\Core\Config\ConfigException; use Drupal\Core\Config\ConfigException;
use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\StringTranslation\Translator\TranslatorInterface;
use Drupal\Core\Routing\PathBasedGeneratorInterface; 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. * Construct the storage changes in a configuration synchronization form.
*/ */
class ConfigSync implements ControllerInterface, FormInterface { class ConfigSync extends FormBase {
/** /**
* The database lock object. * The database lock object.
@ -65,14 +62,6 @@ class ConfigSync implements ControllerInterface, FormInterface {
*/ */
protected $entity_manager; protected $entity_manager;
/**
* The translation manager service.
*
* @var \Drupal\Core\StringTranslation\Translator\TranslatorInterface
*/
protected $translationManager;
/** /**
* URL generator service. * URL generator service.
* *
@ -83,8 +72,6 @@ class ConfigSync implements ControllerInterface, FormInterface {
/** /**
* Constructs the object. * Constructs the object.
* *
* @param \Drupal\Core\Database\Connection; $database
* The database object.
* @param \Drupal\Core\Config\StorageInterface $sourceStorage * @param \Drupal\Core\Config\StorageInterface $sourceStorage
* The source storage object. * The source storage object.
* @param \Drupal\Core\Config\StorageInterface $targetStorage * @param \Drupal\Core\Config\StorageInterface $targetStorage
@ -95,21 +82,18 @@ class ConfigSync implements ControllerInterface, FormInterface {
* Event dispatcher. * Event dispatcher.
* @param \Drupal\Core\Config\ConfigFactory $config_factory * @param \Drupal\Core\Config\ConfigFactory $config_factory
* Configuration object factory. * Configuration object factory.
* @param \Drupal\Core\Entity\EntityManager * @param \Drupal\Core\Entity\EntityManager $entity_manager
* Entity manager. * Entity manager.
* @param \Drupal\Core\StringTranslation\Translator\TranslatorInterface $translation_manager
* The translation manager.
* @param \Drupal\Core\Routing\PathBasedGeneratorInterface $url_generator * @param \Drupal\Core\Routing\PathBasedGeneratorInterface $url_generator
* The url generator service. * 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->sourceStorage = $sourceStorage;
$this->targetStorage = $targetStorage; $this->targetStorage = $targetStorage;
$this->lock = $lock; $this->lock = $lock;
$this->eventDispatcher = $event_dispatcher; $this->eventDispatcher = $event_dispatcher;
$this->configFactory = $config_factory; $this->configFactory = $config_factory;
$this->entity_manager = $entity_manger; $this->entity_manager = $entity_manager;
$this->translationManager = $translation_manager;
$this->urlGenerator = $url_generator; $this->urlGenerator = $url_generator;
} }
@ -124,7 +108,6 @@ class ConfigSync implements ControllerInterface, FormInterface {
$container->get('event_dispatcher'), $container->get('event_dispatcher'),
$container->get('config.factory'), $container->get('config.factory'),
$container->get('plugin.manager.entity'), $container->get('plugin.manager.entity'),
$container->get('string_translation'),
$container->get('url_generator') $container->get('url_generator')
); );
} }
@ -143,14 +126,14 @@ class ConfigSync implements ControllerInterface, FormInterface {
$form['actions'] = array('#type' => 'actions'); $form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array( $form['actions']['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => $this->translationManager->translate('Import all'), '#value' => $this->t('Import all'),
); );
$source_list = $this->sourceStorage->listAll(); $source_list = $this->sourceStorage->listAll();
$config_comparer = new StorageComparer($this->sourceStorage, $this->targetStorage); $config_comparer = new StorageComparer($this->sourceStorage, $this->targetStorage);
if (empty($source_list) || !$config_comparer->createChangelist()->hasChanges()) { if (empty($source_list) || !$config_comparer->createChangelist()->hasChanges()) {
$form['no_changes'] = array( $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; $form['actions']['#access'] = FALSE;
return $form; return $form;
@ -194,7 +177,7 @@ class ConfigSync implements ControllerInterface, FormInterface {
foreach ($config_files as $config_file) { foreach ($config_files as $config_file) {
$links['view_diff'] = array( $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)), 'href' => $this->urlGenerator->getPathFromRoute('config_diff', array('config_file' => $config_file)),
'attributes' => array( 'attributes' => array(
'class' => array('use-ajax'), 'class' => array('use-ajax'),
@ -219,12 +202,6 @@ class ConfigSync implements ControllerInterface, FormInterface {
return $form; return $form;
} }
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, array &$form_state) {
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -237,13 +214,13 @@ class ConfigSync implements ControllerInterface, FormInterface {
$this->lock $this->lock
); );
if ($config_importer->alreadyImporting()) { 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{ else{
try { try {
$config_importer->import(); $config_importer->import();
drupal_flush_all_caches(); 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) { catch (ConfigException $e) {
// Return a negative result for UI purposes. We do not differentiate // Return a negative result for UI purposes. We do not differentiate
@ -252,7 +229,7 @@ class ConfigSync implements ControllerInterface, FormInterface {
// multiple developers or site builders attempt to do it without // multiple developers or site builders attempt to do it without
// coordinating. // coordinating.
watchdog_exception('config_import', $e); 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');
} }
} }
} }

View File

@ -7,10 +7,6 @@
namespace Drupal\entity\Form; namespace Drupal\entity\Form;
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; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
@ -23,43 +19,6 @@ class EntityDisplayModeAddForm extends EntityDisplayModeFormBase {
*/ */
protected $entityType; protected $entityType;
/**
* The entity manager.
*
* @var \Drupal\Component\Plugin\PluginManagerInterface
*/
protected $entityManager;
/**
* 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
* The entity type definition.
* @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);
$this->entityManager = $entity_manager;
}
/**
* {@inheritdoc}
*/
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')
);
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View File

@ -7,16 +7,15 @@
namespace Drupal\entity\Form; namespace Drupal\entity\Form;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Entity\EntityFormController; use Drupal\Core\Entity\EntityFormController;
use Drupal\Core\Entity\EntityManager;
use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Provides the generic base class for entity display mode forms. * Provides the generic base class for entity display mode forms.
*/ */
abstract class EntityDisplayModeFormBase extends EntityFormController implements EntityControllerInterface { abstract class EntityDisplayModeFormBase extends EntityFormController {
/** /**
* The entity query factory. * The entity query factory.
@ -32,34 +31,44 @@ abstract class EntityDisplayModeFormBase extends EntityFormController implements
*/ */
protected $entityInfo; protected $entityInfo;
/**
* The entity manager.
*
* @var \Drupal\Component\Plugin\PluginManagerInterface
*/
protected $entityManager;
/** /**
* Constructs a new EntityDisplayModeFormBase. * Constructs a new EntityDisplayModeFormBase.
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\Entity\Query\QueryFactory $query_factory * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory
* The entity query factory. * The entity query factory.
* @param array $entity_info * @param \Drupal\Core\Entity\EntityManager $entity_manager
* The entity type definition. * The entity manager.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, QueryFactory $query_factory, array $entity_info) { public function __construct(QueryFactory $query_factory, EntityManager $entity_manager) {
parent::__construct($module_handler);
$this->queryFactory = $query_factory; $this->queryFactory = $query_factory;
$this->entityInfo = $entity_info; $this->entityManager = $entity_manager;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'),
$container->get('entity.query'), $container->get('entity.query'),
$entity_info $container->get('plugin.manager.entity')
); );
} }
/**
* {@inheritdoc}
*/
protected function init(array &$form_state) {
parent::init($form_state);
$this->entityInfo = $this->entityManager->getDefinition($this->entity->entityType());
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View File

@ -8,15 +8,13 @@
namespace Drupal\field_ui\Form; namespace Drupal\field_ui\Form;
use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Entity\EntityManager; use Drupal\Core\Entity\EntityManager;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Provides a form for removing a field instance from a bundle. * Provides a form for removing a field instance from a bundle.
*/ */
class FieldDeleteForm extends EntityConfirmFormBase implements EntityControllerInterface { class FieldDeleteForm extends EntityConfirmFormBase {
/** /**
* The entity manager. * The entity manager.
@ -28,22 +26,18 @@ class FieldDeleteForm extends EntityConfirmFormBase implements EntityControllerI
/** /**
* Constructs a new FieldDeleteForm object. * Constructs a new FieldDeleteForm object.
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface
* The module handler service.
* @param \Drupal\Core\Entity\EntityManager $entity_manager * @param \Drupal\Core\Entity\EntityManager $entity_manager
* The entity manager. * The entity manager.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, EntityManager $entity_manager) { public function __construct(EntityManager $entity_manager) {
parent::__construct($module_handler);
$this->entityManager = $entity_manager; $this->entityManager = $entity_manager;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'),
$container->get('plugin.manager.entity') $container->get('plugin.manager.entity')
); );
} }

View File

@ -8,17 +8,15 @@
namespace Drupal\filter; namespace Drupal\filter;
use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Entity\EntityFormController; use Drupal\Core\Entity\EntityFormController;
use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\filter\Plugin\Filter\FilterNull; use Drupal\filter\Plugin\Filter\FilterNull;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Provides a base form controller for a filter format. * Provides a base form controller for a filter format.
*/ */
abstract class FilterFormatFormControllerBase extends EntityFormController implements EntityControllerInterface { abstract class FilterFormatFormControllerBase extends EntityFormController {
/** /**
* The config factory. * The config factory.
@ -37,15 +35,12 @@ abstract class FilterFormatFormControllerBase extends EntityFormController imple
/** /**
* Constructs a new FilterFormatFormControllerBase. * Constructs a new FilterFormatFormControllerBase.
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface
* The module handler service.
* @param \Drupal\Core\Config\ConfigFactory $config_factory * @param \Drupal\Core\Config\ConfigFactory $config_factory
* The config factory. * The config factory.
* @param \Drupal\Core\Entity\Query\QueryFactory $query_factory * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory
* The entity query factory. * The entity query factory.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, ConfigFactory $config_factory, QueryFactory $query_factory) { public function __construct(ConfigFactory $config_factory, QueryFactory $query_factory) {
parent::__construct($module_handler);
$this->configFactory = $config_factory; $this->configFactory = $config_factory;
$this->queryFactory = $query_factory; $this->queryFactory = $query_factory;
} }
@ -53,9 +48,8 @@ abstract class FilterFormatFormControllerBase extends EntityFormController imple
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'),
$container->get('config.factory'), $container->get('config.factory'),
$container->get('entity.query') $container->get('entity.query')
); );

View File

@ -9,7 +9,6 @@ namespace Drupal\forum\Form;
use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\ConfirmFormBase;
use Drupal\taxonomy\Entity\Term; use Drupal\taxonomy\Entity\Term;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Builds the form to delete a forum term. * Builds the form to delete a forum term.
@ -54,10 +53,10 @@ class DeleteForm extends ConfirmFormBase {
/** /**
* {@inheritdoc} * {@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; $this->taxonomyTerm = $taxonomy_term;
return parent::buildForm($form, $form_state, $request); return parent::buildForm($form, $form_state);
} }
/** /**

View File

@ -9,8 +9,6 @@ namespace Drupal\forum\Form;
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\taxonomy\TermFormController; use Drupal\taxonomy\TermFormController;
use Drupal\taxonomy\TermStorageControllerInterface; use Drupal\taxonomy\TermStorageControllerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
@ -19,7 +17,7 @@ use Symfony\Component\HttpFoundation\Request;
/** /**
* Base form controller for forum term edit forms. * Base form controller for forum term edit forms.
*/ */
class ForumFormController extends TermFormController implements EntityControllerInterface { class ForumFormController extends TermFormController {
/** /**
* Reusable type field to use in status messages. * Reusable type field to use in status messages.
@ -59,8 +57,6 @@ class ForumFormController extends TermFormController implements EntityController
/** /**
* Constructs a new ForumFormController object. * Constructs a new ForumFormController object.
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\Config\ConfigFactory $config_factory * @param \Drupal\Core\Config\ConfigFactory $config_factory
* The config factory service. * The config factory service.
* @param \Symfony\Component\HttpFoundation\Request $request * @param \Symfony\Component\HttpFoundation\Request $request
@ -68,8 +64,7 @@ class ForumFormController extends TermFormController implements EntityController
* @param \Drupal\taxonomy\TermStorageControllerInterface $storage_controller * @param \Drupal\taxonomy\TermStorageControllerInterface $storage_controller
* The storage controller. * The storage controller.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, ConfigFactory $config_factory, Request $request, TermStorageControllerInterface $storage_controller) { public function __construct(ConfigFactory $config_factory, Request $request, TermStorageControllerInterface $storage_controller) {
parent::__construct($module_handler);
$this->config = $config_factory->get('forum.settings'); $this->config = $config_factory->get('forum.settings');
$this->request = $request; $this->request = $request;
$this->storageController = $storage_controller; $this->storageController = $storage_controller;
@ -78,9 +73,8 @@ class ForumFormController extends TermFormController implements EntityController
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'),
$container->get('config.factory'), $container->get('config.factory'),
$container->get('request'), $container->get('request'),
$container->get('plugin.manager.entity')->getStorageController('taxonomy_term') $container->get('plugin.manager.entity')->getStorageController('taxonomy_term')

View File

@ -9,7 +9,6 @@ namespace Drupal\image\Form;
use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\ConfirmFormBase;
use Drupal\image\ImageStyleInterface; use Drupal\image\ImageStyleInterface;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Form for deleting an image effect. * Form for deleting an image effect.
@ -61,11 +60,11 @@ class ImageEffectDeleteForm extends ConfirmFormBase {
/** /**
* {@inheritdoc} * {@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->imageStyle = $image_style;
$this->imageEffect = $this->imageStyle->getEffect($image_effect); $this->imageEffect = $this->imageStyle->getEffect($image_effect);
return parent::buildForm($form, $form_state, $request); return parent::buildForm($form, $form_state);
} }
/** /**

View File

@ -7,8 +7,6 @@
namespace Drupal\image\Form; namespace Drupal\image\Form;
use Drupal\image\Form\ImageStyleFormBase;
/** /**
* Controller for image style addition forms. * Controller for image style addition forms.
*/ */
@ -19,7 +17,7 @@ class ImageStyleAddForm extends ImageStyleFormBase {
*/ */
public function save(array $form, array &$form_state) { public function save(array $form, array &$form_state) {
parent::save($form, $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 @@ class ImageStyleAddForm extends ImageStyleFormBase {
*/ */
public function actions(array $form, array &$form_state) { public function actions(array $form, array &$form_state) {
$actions = parent::actions($form, $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; return $actions;
} }

View File

@ -8,10 +8,7 @@
namespace Drupal\image\Form; namespace Drupal\image\Form;
use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityStorageControllerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\StringTranslation\Translator\TranslatorInterface;
use Drupal\image\ConfigurableImageEffectInterface; use Drupal\image\ConfigurableImageEffectInterface;
use Drupal\image\Form\ImageStyleFormBase;
use Drupal\image\ImageEffectManager; use Drupal\image\ImageEffectManager;
use Drupal\Component\Utility\String; use Drupal\Component\Utility\String;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
@ -31,28 +28,22 @@ class ImageStyleEditForm extends ImageStyleFormBase {
/** /**
* Constructs an ImageStyleEditForm object. * Constructs an ImageStyleEditForm object.
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler service.
* @param \Drupal\Core\Entity\EntityStorageControllerInterface $image_style_storage * @param \Drupal\Core\Entity\EntityStorageControllerInterface $image_style_storage
* The storage controller. * The storage controller.
* @param \Drupal\image\ImageEffectManager $image_effect_manager * @param \Drupal\image\ImageEffectManager $image_effect_manager
* The image effect manager service. * 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) { public function __construct(EntityStorageControllerInterface $image_style_storage, ImageEffectManager $image_effect_manager) {
parent::__construct($module_handler, $image_style_storage, $translator); parent::__construct($image_style_storage);
$this->imageEffectManager = $image_effect_manager; $this->imageEffectManager = $image_effect_manager;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'), $container->get('plugin.manager.entity')->getStorageController('image_style'),
$container->get('plugin.manager.entity')->getStorageController($entity_type),
$container->get('string_translation'),
$container->get('plugin.manager.image.effect') $container->get('plugin.manager.image.effect')
); );
} }
@ -63,7 +54,7 @@ class ImageStyleEditForm extends ImageStyleFormBase {
public function form(array $form, array &$form_state) { public function form(array $form, array &$form_state) {
// @todo Remove drupal_set_title() in http://drupal.org/node/1981644 // @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); drupal_set_title($title, PASS_THROUGH);
$form['#tree'] = TRUE; $form['#tree'] = TRUE;
@ -73,7 +64,7 @@ class ImageStyleEditForm extends ImageStyleFormBase {
$preview_arguments = array('#theme' => 'image_style_preview', '#style' => $this->entity); $preview_arguments = array('#theme' => 'image_style_preview', '#style' => $this->entity);
$form['preview'] = array( $form['preview'] = array(
'#type' => 'item', '#type' => 'item',
'#title' => $this->translator->translate('Preview'), '#title' => $this->t('Preview'),
'#markup' => drupal_render($preview_arguments), '#markup' => drupal_render($preview_arguments),
// Render preview above parent elements. // Render preview above parent elements.
'#weight' => -5, '#weight' => -5,
@ -94,7 +85,7 @@ class ImageStyleEditForm extends ImageStyleFormBase {
$form['effects'][$key]['summary'] = $effect->getSummary(); $form['effects'][$key]['summary'] = $effect->getSummary();
$form['effects'][$key]['weight'] = array( $form['effects'][$key]['weight'] = array(
'#type' => 'weight', '#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', '#title_display' => 'invisible',
'#default_value' => $effect->getWeight(), '#default_value' => $effect->getWeight(),
); );
@ -103,12 +94,12 @@ class ImageStyleEditForm extends ImageStyleFormBase {
$is_configurable = $effect instanceof ConfigurableImageEffectInterface; $is_configurable = $effect instanceof ConfigurableImageEffectInterface;
if ($is_configurable) { if ($is_configurable) {
$links['edit'] = array( $links['edit'] = array(
'title' => $this->translator->translate('edit'), 'title' => $this->t('edit'),
'href' => 'admin/config/media/image-styles/manage/' . $this->entity->id() . '/effects/' . $key, 'href' => 'admin/config/media/image-styles/manage/' . $this->entity->id() . '/effects/' . $key,
); );
} }
$links['delete'] = array( $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', 'href' => 'admin/config/media/image-styles/manage/' . $this->entity->id() . '/effects/' . $key . '/delete',
); );
$form['effects'][$key]['operations'] = array( $form['effects'][$key]['operations'] = array(
@ -117,13 +108,13 @@ class ImageStyleEditForm extends ImageStyleFormBase {
); );
$form['effects'][$key]['configure'] = array( $form['effects'][$key]['configure'] = array(
'#type' => 'link', '#type' => 'link',
'#title' => $this->translator->translate('edit'), '#title' => $this->t('edit'),
'#href' => 'admin/config/media/image-styles/manage/' . $this->entity->id() . '/effects/' . $key, '#href' => 'admin/config/media/image-styles/manage/' . $this->entity->id() . '/effects/' . $key,
'#access' => $is_configurable, '#access' => $is_configurable,
); );
$form['effects'][$key]['remove'] = array( $form['effects'][$key]['remove'] = array(
'#type' => 'link', '#type' => 'link',
'#title' => $this->translator->translate('delete'), '#title' => $this->t('delete'),
'#href' => 'admin/config/media/image-styles/manage/' . $this->entity->id() . '/effects/' . $key . '/delete', '#href' => 'admin/config/media/image-styles/manage/' . $this->entity->id() . '/effects/' . $key . '/delete',
); );
} }
@ -143,20 +134,20 @@ class ImageStyleEditForm extends ImageStyleFormBase {
); );
$form['effects']['new']['new'] = array( $form['effects']['new']['new'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => $this->translator->translate('Effect'), '#title' => $this->t('Effect'),
'#title_display' => 'invisible', '#title_display' => 'invisible',
'#options' => $new_effect_options, '#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( $form['effects']['new']['weight'] = array(
'#type' => 'weight', '#type' => 'weight',
'#title' => $this->translator->translate('Weight for new effect'), '#title' => $this->t('Weight for new effect'),
'#title_display' => 'invisible', '#title_display' => 'invisible',
'#default_value' => count($form['effects']) - 1, '#default_value' => count($form['effects']) - 1,
); );
$form['effects']['new']['add'] = array( $form['effects']['new']['add'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => $this->translator->translate('Add'), '#value' => $this->t('Add'),
'#validate' => array(array($this, 'effectValidate')), '#validate' => array(array($this, 'effectValidate')),
'#submit' => array(array($this, 'effectSave')), '#submit' => array(array($this, 'effectSave')),
); );
@ -169,7 +160,7 @@ class ImageStyleEditForm extends ImageStyleFormBase {
*/ */
public function effectValidate($form, &$form_state) { public function effectValidate($form, &$form_state) {
if (!$form_state['values']['new']) { 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 @@ class ImageStyleEditForm extends ImageStyleFormBase {
$status = parent::save($form, $form_state); $status = parent::save($form, $form_state);
if ($status == SAVED_UPDATED) { 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. // Check if this field has any configuration options.
@ -209,7 +200,7 @@ class ImageStyleEditForm extends ImageStyleFormBase {
); );
$effect_id = $this->entity->saveImageEffect($effect); $effect_id = $this->entity->saveImageEffect($effect);
if (!empty($effect_id)) { 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 @@ class ImageStyleEditForm extends ImageStyleFormBase {
} }
parent::save($form, $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 @@ class ImageStyleEditForm extends ImageStyleFormBase {
*/ */
public function actions(array $form, array &$form_state) { public function actions(array $form, array &$form_state) {
$actions = parent::actions($form, $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; return $actions;
} }

View File

@ -7,17 +7,14 @@
namespace Drupal\image\Form; namespace Drupal\image\Form;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Entity\EntityFormController; use Drupal\Core\Entity\EntityFormController;
use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityStorageControllerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\StringTranslation\Translator\TranslatorInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Base form controller for image style add and edit forms. * Base form controller for image style add and edit forms.
*/ */
abstract class ImageStyleFormBase extends EntityFormController implements EntityControllerInterface { abstract class ImageStyleFormBase extends EntityFormController {
/** /**
* The image style entity storage controller. * The image style entity storage controller.
@ -26,37 +23,22 @@ abstract class ImageStyleFormBase extends EntityFormController implements Entity
*/ */
protected $imageStyleStorage; protected $imageStyleStorage;
/**
* The translator service.
*
* @var \Drupal\Core\StringTranslation\Translator\TranslatorInterface
*/
protected $translator;
/** /**
* Constructs a base class for image style add and edit forms. * 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 * @param \Drupal\Core\Entity\EntityStorageControllerInterface $image_style_storage
* The image style entity storage controller. * 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) { public function __construct(EntityStorageControllerInterface $image_style_storage) {
parent::__construct($module_handler);
$this->imageStyleStorage = $image_style_storage; $this->imageStyleStorage = $image_style_storage;
$this->translator = $translator;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'), $container->get('plugin.manager.entity')->getStorageController('image_style')
$container->get('plugin.manager.entity')->getStorageController($entity_type),
$container->get('string_translation')
); );
} }
@ -67,7 +49,7 @@ abstract class ImageStyleFormBase extends EntityFormController implements Entity
$form['label'] = array( $form['label'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => $this->translator->translate('Image style name'), '#title' => $this->t('Image style name'),
'#default_value' => $this->entity->label(), '#default_value' => $this->entity->label(),
'#required' => TRUE, '#required' => TRUE,
); );

View File

@ -9,15 +9,13 @@ namespace Drupal\menu\Form;
use Drupal\Core\Database\Connection; use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityStorageControllerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Defines a confirmation form for deletion of a custom menu. * Defines a confirmation form for deletion of a custom menu.
*/ */
class MenuDeleteForm extends EntityConfirmFormBase implements EntityControllerInterface { class MenuDeleteForm extends EntityConfirmFormBase {
/** /**
* The menu link storage controller. * The menu link storage controller.
@ -36,15 +34,12 @@ class MenuDeleteForm extends EntityConfirmFormBase implements EntityControllerIn
/** /**
* Constructs a new MenuDeleteForm. * Constructs a new MenuDeleteForm.
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface
* The module handler service.
* @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage_controller * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage_controller
* The menu link storage controller. * The menu link storage controller.
* @param \Drupal\Core\Database\Connection $connection * @param \Drupal\Core\Database\Connection $connection
* The database connection. * The database connection.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, EntityStorageControllerInterface $storage_controller, Connection $connection) { public function __construct(EntityStorageControllerInterface $storage_controller, Connection $connection) {
parent::__construct($module_handler);
$this->storageController = $storage_controller; $this->storageController = $storage_controller;
$this->connection = $connection; $this->connection = $connection;
} }
@ -52,9 +47,8 @@ class MenuDeleteForm extends EntityConfirmFormBase implements EntityControllerIn
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'),
$container->get('plugin.manager.entity')->getStorageController('menu_link'), $container->get('plugin.manager.entity')->getStorageController('menu_link'),
$container->get('database') $container->get('database')
); );

View File

@ -8,10 +8,8 @@
namespace Drupal\menu; namespace Drupal\menu;
use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Entity\EntityFormController; use Drupal\Core\Entity\EntityFormController;
use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
use Drupal\menu_link\MenuLinkStorageControllerInterface; use Drupal\menu_link\MenuLinkStorageControllerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
@ -19,7 +17,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Base form controller for menu edit forms. * Base form controller for menu edit forms.
*/ */
class MenuFormController extends EntityFormController implements EntityControllerInterface { class MenuFormController extends EntityFormController {
/** /**
* The factory for entity queries. * The factory for entity queries.
@ -45,16 +43,12 @@ class MenuFormController extends EntityFormController implements EntityControlle
/** /**
* Constructs a MenuFormController object. * 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 * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query_factory
* The factory for entity queries. * The factory for entity queries.
* @param \Drupal\menu_link\MenuLinkStorageControllerInterface $menu_link_storage * @param \Drupal\menu_link\MenuLinkStorageControllerInterface $menu_link_storage
* The menu link storage controller. * The menu link storage controller.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, QueryFactory $entity_query_factory, MenuLinkStorageControllerInterface $menu_link_storage) { public function __construct(QueryFactory $entity_query_factory, MenuLinkStorageControllerInterface $menu_link_storage) {
parent::__construct($module_handler);
$this->entityQueryFactory = $entity_query_factory; $this->entityQueryFactory = $entity_query_factory;
$this->menuLinkStorage = $menu_link_storage; $this->menuLinkStorage = $menu_link_storage;
} }
@ -62,9 +56,8 @@ class MenuFormController extends EntityFormController implements EntityControlle
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'),
$container->get('entity.query'), $container->get('entity.query'),
$container->get('plugin.manager.entity')->getStorageController('menu_link') $container->get('plugin.manager.entity')->getStorageController('menu_link')
); );

View File

@ -7,10 +7,8 @@
namespace Drupal\menu_link; namespace Drupal\menu_link;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Entity\EntityFormController; use Drupal\Core\Entity\EntityFormController;
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Path\AliasManagerInterface; use Drupal\Core\Path\AliasManagerInterface;
use Drupal\Core\Routing\UrlGenerator; use Drupal\Core\Routing\UrlGenerator;
use Drupal\menu_link\MenuLinkStorageControllerInterface; use Drupal\menu_link\MenuLinkStorageControllerInterface;
@ -19,7 +17,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Form controller for the node edit forms. * Form controller for the node edit forms.
*/ */
class MenuLinkFormController extends EntityFormController implements EntityControllerInterface { class MenuLinkFormController extends EntityFormController {
/** /**
* The menu link storage controller. * The menu link storage controller.
@ -45,13 +43,14 @@ class MenuLinkFormController extends EntityFormController implements EntityContr
/** /**
* Constructs a new MenuLinkFormController object. * Constructs a new MenuLinkFormController object.
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface * @param \Drupal\menu_link\MenuLinkStorageControllerInterface $menu_link_storage_controller
* The module handler service. * The menu link storage.
* @param \Drupal\Core\Path\AliasManagerInterface $path_alias_manager * @param \Drupal\Core\Path\AliasManagerInterface $path_alias_manager
* The 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) { public function __construct(MenuLinkStorageControllerInterface $menu_link_storage_controller, AliasManagerInterface $path_alias_manager, UrlGenerator $url_generator) {
parent::__construct($module_handler);
$this->menuLinkStorageController = $menu_link_storage_controller; $this->menuLinkStorageController = $menu_link_storage_controller;
$this->pathAliasManager = $path_alias_manager; $this->pathAliasManager = $path_alias_manager;
$this->urlGenerator = $url_generator; $this->urlGenerator = $url_generator;
@ -60,9 +59,8 @@ class MenuLinkFormController extends EntityFormController implements EntityContr
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info, $operation = NULL) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'),
$container->get('plugin.manager.entity')->getStorageController('menu_link'), $container->get('plugin.manager.entity')->getStorageController('menu_link'),
$container->get('path.alias_manager.cached'), $container->get('path.alias_manager.cached'),
$container->get('url_generator') $container->get('url_generator')

View File

@ -14,7 +14,6 @@ use Drupal\Component\Utility\String;
use Drupal\user\TempStoreFactory; use Drupal\user\TempStoreFactory;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Provides a node deletion confirmation form. * Provides a node deletion confirmation form.
@ -96,7 +95,7 @@ class DeleteMultiple extends ConfirmFormBase implements ControllerInterface {
/** /**
* {@inheritdoc} * {@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()); $this->nodes = $this->tempStoreFactory->get('node_multiple_delete_confirm')->get($GLOBALS['user']->id());
if (empty($this->nodes)) { if (empty($this->nodes)) {
return new RedirectResponse(url($this->getCancelPath(), array('absolute' => TRUE))); return new RedirectResponse(url($this->getCancelPath(), array('absolute' => TRUE)));
@ -108,7 +107,7 @@ class DeleteMultiple extends ConfirmFormBase implements ControllerInterface {
return String::checkPlain($node->label()); return String::checkPlain($node->label());
}, $this->nodes), }, $this->nodes),
); );
return parent::buildForm($form, $form_state, $request); return parent::buildForm($form, $form_state);
} }
/** /**

View File

@ -7,10 +7,8 @@
namespace Drupal\node\Form; namespace Drupal\node\Form;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Entity\EntityNGConfirmFormBase; use Drupal\Core\Entity\EntityNGConfirmFormBase;
use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityStorageControllerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Routing\PathBasedGeneratorInterface; use Drupal\Core\Routing\PathBasedGeneratorInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
@ -18,7 +16,7 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/** /**
* Provides a form for deleting a node. * Provides a form for deleting a node.
*/ */
class NodeDeleteForm extends EntityNGConfirmFormBase implements EntityControllerInterface { class NodeDeleteForm extends EntityNGConfirmFormBase {
/** /**
* The URL generator. * The URL generator.
@ -37,16 +35,12 @@ class NodeDeleteForm extends EntityNGConfirmFormBase implements EntityController
/** /**
* Constructs a NodeDeleteForm object. * Constructs a NodeDeleteForm object.
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler service.
* @param \Drupal\Core\Routing\PathBasedGeneratorInterface $url_generator * @param \Drupal\Core\Routing\PathBasedGeneratorInterface $url_generator
* The URL generator. * The URL generator.
* @param \Drupal\Core\Entity\EntityStorageControllerInterface $node_type_storage * @param \Drupal\Core\Entity\EntityStorageControllerInterface $node_type_storage
* The node type storage. * The node type storage.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, PathBasedGeneratorInterface $url_generator, EntityStorageControllerInterface $node_type_storage) { public function __construct(PathBasedGeneratorInterface $url_generator, EntityStorageControllerInterface $node_type_storage) {
parent::__construct($module_handler);
$this->urlGenerator = $url_generator; $this->urlGenerator = $url_generator;
$this->nodeTypeStorage = $node_type_storage; $this->nodeTypeStorage = $node_type_storage;
} }
@ -54,9 +48,8 @@ class NodeDeleteForm extends EntityNGConfirmFormBase implements EntityController
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'),
$container->get('url_generator'), $container->get('url_generator'),
$container->get('plugin.manager.entity')->getStorageController('node_type') $container->get('plugin.manager.entity')->getStorageController('node_type')
); );

View File

@ -13,7 +13,6 @@ use Drupal\Core\Entity\EntityStorageControllerInterface;
use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\ConfirmFormBase;
use Drupal\node\NodeInterface; use Drupal\node\NodeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Provides a form for reverting a node revision. * Provides a form for reverting a node revision.
@ -107,9 +106,9 @@ class NodeRevisionDeleteForm extends ConfirmFormBase implements ControllerInterf
/** /**
* {@inheritdoc} * {@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); $this->revision = $this->nodeStorage->loadRevision($node_revision);
return parent::buildForm($form, $form_state, $request); return parent::buildForm($form, $form_state);
} }
/** /**

View File

@ -12,7 +12,6 @@ use Drupal\Core\Entity\EntityStorageControllerInterface;
use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\ConfirmFormBase;
use Drupal\node\NodeInterface; use Drupal\node\NodeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Provides a form for reverting a node revision. * Provides a form for reverting a node revision.
@ -90,9 +89,9 @@ class NodeRevisionRevertForm extends ConfirmFormBase implements ControllerInterf
/** /**
* {@inheritdoc} * {@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); $this->revision = $this->nodeStorage->loadRevision($node_revision);
return parent::buildForm($form, $form_state, $request); return parent::buildForm($form, $form_state);
} }
/** /**

View File

@ -8,16 +8,13 @@
namespace Drupal\node\Form; namespace Drupal\node\Form;
use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Database\Connection; use Drupal\Core\Database\Connection;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Provides a form for content type deletion. * Provides a form for content type deletion.
*/ */
class NodeTypeDeleteConfirm extends EntityConfirmFormBase implements EntityControllerInterface { class NodeTypeDeleteConfirm extends EntityConfirmFormBase {
/** /**
* The database connection. * The database connection.
@ -29,22 +26,18 @@ class NodeTypeDeleteConfirm extends EntityConfirmFormBase implements EntityContr
/** /**
* Constructs a new NodeTypeDeleteConfirm object. * Constructs a new NodeTypeDeleteConfirm object.
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface
* The module handler service.
* @param \Drupal\Core\Database\Connection $database * @param \Drupal\Core\Database\Connection $database
* The database connection. * The database connection.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, Connection $database) { public function __construct(Connection $database) {
parent::__construct($module_handler);
$this->database = $database; $this->database = $database;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'),
$container->get('database') $container->get('database')
); );
} }
@ -73,7 +66,7 @@ class NodeTypeDeleteConfirm extends EntityConfirmFormBase implements EntityContr
/** /**
* {@inheritdoc} * {@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(); $num_nodes = $this->database->query("SELECT COUNT(*) FROM {node} WHERE type = :type", array(':type' => $this->entity->id()))->fetchField();
if ($num_nodes) { if ($num_nodes) {
drupal_set_title($this->getQuestion(), PASS_THROUGH); drupal_set_title($this->getQuestion(), PASS_THROUGH);
@ -82,7 +75,7 @@ class NodeTypeDeleteConfirm extends EntityConfirmFormBase implements EntityContr
return $form; return $form;
} }
return parent::buildForm($form, $form_state, $request); return parent::buildForm($form, $form_state);
} }
/** /**

View File

@ -8,13 +8,12 @@
namespace Drupal\node; namespace Drupal\node;
use Drupal\Core\Entity\EntityFormController; use Drupal\Core\Entity\EntityFormController;
use Drupal\Core\Entity\EntityControllerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Form controller for node type forms. * Form controller for node type forms.
*/ */
class NodeTypeFormController extends EntityFormController implements EntityControllerInterface { class NodeTypeFormController extends EntityFormController {
/** /**
* {@inheritdoc} * {@inheritdoc}

View File

@ -11,7 +11,6 @@ use Drupal\Core\Controller\ControllerInterface;
use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Path\Path; use Drupal\Core\Path\Path;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Builds the form to delete a path alias. * Builds the form to delete a path alias.
@ -75,10 +74,10 @@ class DeleteForm extends ConfirmFormBase implements ControllerInterface {
/** /**
* Overrides \Drupal\Core\Form\ConfirmFormBase::buildForm(). * 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)); $this->pathAlias = $this->path->load(array('pid' => $pid));
return parent::buildForm($form, $form_state, $request); return parent::buildForm($form, $form_state);
} }
/** /**

View File

@ -9,7 +9,6 @@ namespace Drupal\shortcut\Form;
use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\ConfirmFormBase;
use Drupal\menu_link\Entity\MenuLink; use Drupal\menu_link\Entity\MenuLink;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Builds the shortcut link deletion form. * Builds the shortcut link deletion form.
@ -54,10 +53,10 @@ class LinkDelete extends ConfirmFormBase {
/** /**
* {@inheritdoc} * {@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; $this->menuLink = $menu_link;
return parent::buildForm($form, $form_state, $request); return parent::buildForm($form, $form_state);
} }
/** /**

View File

@ -8,17 +8,14 @@
namespace Drupal\shortcut\Form; namespace Drupal\shortcut\Form;
use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\shortcut\ShortcutSetStorageControllerInterface; use Drupal\shortcut\ShortcutSetStorageControllerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Database\Connection; use Drupal\Core\Database\Connection;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Builds the shortcut set deletion form. * Builds the shortcut set deletion form.
*/ */
class ShortcutSetDeleteForm extends EntityConfirmFormBase implements EntityControllerInterface { class ShortcutSetDeleteForm extends EntityConfirmFormBase {
/** /**
* The database connection. * The database connection.
@ -37,8 +34,7 @@ class ShortcutSetDeleteForm extends EntityConfirmFormBase implements EntityContr
/** /**
* Constructs a ShortcutSetDeleteForm object. * Constructs a ShortcutSetDeleteForm object.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, Connection $database, ShortcutSetStorageControllerInterface $storage_controller) { public function __construct(Connection $database, ShortcutSetStorageControllerInterface $storage_controller) {
parent::__construct($module_handler);
$this->database = $database; $this->database = $database;
$this->storageController = $storage_controller; $this->storageController = $storage_controller;
} }
@ -46,9 +42,8 @@ class ShortcutSetDeleteForm extends EntityConfirmFormBase implements EntityContr
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'),
$container->get('database'), $container->get('database'),
$container->get('plugin.manager.entity')->getStorageController('shortcut_set') $container->get('plugin.manager.entity')->getStorageController('shortcut_set')
); );
@ -78,7 +73,7 @@ class ShortcutSetDeleteForm extends EntityConfirmFormBase implements EntityContr
/** /**
* {@inheritdoc} * {@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 // Find out how many users are directly assigned to this shortcut set, and
// make a message. // make a message.
$number = $this->storageController->countAssignedUsers($this->entity); $number = $this->storageController->countAssignedUsers($this->entity);
@ -99,7 +94,7 @@ class ShortcutSetDeleteForm extends EntityConfirmFormBase implements EntityContr
'#markup' => $info, '#markup' => $info,
); );
return parent::buildForm($form, $form_state, $request); return parent::buildForm($form, $form_state);
} }
/** /**

View File

@ -6,9 +6,10 @@
namespace Drupal\statistics; namespace Drupal\statistics;
use Drupal\Core\Config\Context\ContextInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\system\SystemConfigFormBase; use Drupal\system\SystemConfigFormBase;
use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\Extension\ModuleHandler;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
@ -19,7 +20,7 @@ class StatisticsSettingsForm extends SystemConfigFormBase {
/** /**
* The module handler. * The module handler.
* *
* @var \Drupal\Core\Extension\ModuleHandler * @var \Drupal\Core\Extension\ModuleHandlerInterface
*/ */
protected $moduleHandler; protected $moduleHandler;
@ -28,11 +29,14 @@ class StatisticsSettingsForm extends SystemConfigFormBase {
* *
* @param \Drupal\Core\Config\ConfigFactory $config_factory * @param \Drupal\Core\Config\ConfigFactory $config_factory
* The factory for configuration objects. * The factory for configuration objects.
* @param \Drupal\Core\Extension\ModuleHandler $module_handler * @param \Drupal\Core\Config\Context\ContextInterface $context
* The configuration context to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler. * The module handler.
*/ */
public function __construct(ConfigFactory $config_factory, ModuleHandler $module_handler) { public function __construct(ConfigFactory $config_factory, ContextInterface $context, ModuleHandlerInterface $module_handler) {
$this->configFactory = $config_factory; parent::__construct($config_factory, $context);
$this->moduleHandler = $module_handler; $this->moduleHandler = $module_handler;
} }
@ -42,6 +46,7 @@ class StatisticsSettingsForm extends SystemConfigFormBase {
public static function create(ContainerInterface $container) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('config.factory'), $container->get('config.factory'),
$container->get('config.context.free'),
$container->get('module_handler') $container->get('module_handler')
); );
} }

View File

@ -7,17 +7,14 @@
namespace Drupal\system\Form; namespace Drupal\system\Form;
use Drupal\Core\Controller\ControllerInterface;
use Drupal\Core\Datetime\Date; use Drupal\Core\Datetime\Date;
use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Builds a form to delete a date format. * Builds a form to delete a date format.
*/ */
class DateFormatDeleteForm extends EntityConfirmFormBase implements EntityControllerInterface { class DateFormatDeleteForm extends EntityConfirmFormBase {
/** /**
* The date service. * The date service.
@ -29,23 +26,18 @@ class DateFormatDeleteForm extends EntityConfirmFormBase implements EntityContro
/** /**
* Constructs an DateFormatDeleteForm object. * Constructs an DateFormatDeleteForm object.
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler service.
* @param \Drupal\Core\Datetime\Date $date_service * @param \Drupal\Core\Datetime\Date $date_service
* The date service. * The date service.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, Date $date_service) { public function __construct(Date $date_service) {
parent::__construct($module_handler);
$this->dateService = $date_service; $this->dateService = $date_service;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'),
$container->get('date') $container->get('date')
); );
} }

View File

@ -10,8 +10,6 @@ namespace Drupal\system\Form;
use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\ReplaceCommand; use Drupal\Core\Ajax\ReplaceCommand;
use Drupal\Core\Datetime\Date; use Drupal\Core\Datetime\Date;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Entity\Query\QueryFactory;
@ -20,7 +18,7 @@ use Drupal\Core\Entity\EntityFormController;
/** /**
* Provides a base form controller for date formats. * Provides a base form controller for date formats.
*/ */
abstract class DateFormatFormBase extends EntityFormController implements EntityControllerInterface { abstract class DateFormatFormBase extends EntityFormController {
/** /**
* The date pattern type. * The date pattern type.
@ -46,16 +44,12 @@ abstract class DateFormatFormBase extends EntityFormController implements Entity
/** /**
* Constructs a new date format form. * Constructs a new date format form.
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\Entity\Query\QueryFactory $query_factory * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory
* The entity query factory. * The entity query factory.
* @param \Drupal\Core\Datetime\Date $date_service * @param \Drupal\Core\Datetime\Date $date_service
* The date service. * The date service.
*/ */
function __construct(ModuleHandlerInterface $module_handler, QueryFactory $query_factory, Date $date_service) { public function __construct(QueryFactory $query_factory, Date $date_service) {
parent::__construct($module_handler);
$date = new DrupalDateTime(); $date = new DrupalDateTime();
$this->patternType = $date->canUseIntl() ? DrupalDateTime::INTL : DrupalDateTime::PHP; $this->patternType = $date->canUseIntl() ? DrupalDateTime::INTL : DrupalDateTime::PHP;
@ -66,9 +60,8 @@ abstract class DateFormatFormBase extends EntityFormController implements Entity
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'),
$container->get('entity.query'), $container->get('entity.query'),
$container->get('date') $container->get('date')
); );

View File

@ -11,7 +11,6 @@ use Drupal\Core\Controller\ControllerInterface;
use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\ConfigFactory;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Builds a form for enabling a module. * Builds a form for enabling a module.
@ -34,6 +33,9 @@ class DateFormatLocalizeResetForm extends ConfirmFormBase implements ControllerI
/** /**
* Constructs a DateFormatLocalizeResetForm object. * Constructs a DateFormatLocalizeResetForm object.
*
* @param \Drupal\Core\Config\ConfigFactory $config_factory
* The config factory.
*/ */
public function __construct(ConfigFactory $config_factory) { public function __construct(ConfigFactory $config_factory) {
$this->configFactory = $config_factory; $this->configFactory = $config_factory;
@ -92,10 +94,10 @@ class DateFormatLocalizeResetForm extends ConfirmFormBase implements ControllerI
* The language code. * 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); $this->language = language_load($langcode);
return parent::buildForm($form, $form_state, $request); return parent::buildForm($form, $form_state);
} }
/** /**

View File

@ -11,10 +11,8 @@ use Drupal\Core\Controller\ControllerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface;
use Drupal\Core\StringTranslation\TranslationManager;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Builds a confirmation form for enabling modules with dependencies. * Builds a confirmation form for enabling modules with dependencies.
@ -35,20 +33,6 @@ class ModulesListConfirmForm extends ConfirmFormBase implements ControllerInterf
*/ */
protected $keyValueExpirable; 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. * An associative list of modules to enable or disable.
* *
@ -56,17 +40,6 @@ class ModulesListConfirmForm extends ConfirmFormBase implements ControllerInterf
*/ */
protected $modules = array(); 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. * Constructs a ModulesListConfirmForm object.
* *
@ -74,20 +47,27 @@ class ModulesListConfirmForm extends ConfirmFormBase implements ControllerInterf
* The module handler. * The module handler.
* @param \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface $key_value_expirable * @param \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface $key_value_expirable
* The key value expirable factory. * 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->moduleHandler = $module_handler;
$this->keyValueExpirable = $key_value_expirable; $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} * {@inheritdoc}
*/ */
public function getQuestion() { 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 @@ class ModulesListConfirmForm extends ConfirmFormBase implements ControllerInterf
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getConfirmText() { public function getConfirmText() {
return $this->translationManager->translate('Continue'); return $this->t('Continue');
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getDescription() { 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 @@ class ModulesListConfirmForm extends ConfirmFormBase implements ControllerInterf
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function buildForm(array $form, array &$form_state, Request $request = NULL) { public function buildForm(array $form, array &$form_state) {
$account = $request->attributes->get('_account')->id(); $account = $this->getCurrentUser()->id();
$this->modules = $this->keyValueExpirable->get($account); $this->modules = $this->keyValueExpirable->get($account);
// Redirect to the modules list page if the key value store is empty. // Redirect to the modules list page if the key value store is empty.
@ -130,9 +110,6 @@ class ModulesListConfirmForm extends ConfirmFormBase implements ControllerInterf
return new RedirectResponse(url($this->getCancelPath(), array('absolute' => TRUE))); return new RedirectResponse(url($this->getCancelPath(), array('absolute' => TRUE)));
} }
// Store the request for use in the submit handler.
$this->request = $request;
$items = array(); $items = array();
// Display a list of required modules that have to be installed as well but // Display a list of required modules that have to be installed as well but
// were not manually selected. // were not manually selected.
@ -155,7 +132,7 @@ class ModulesListConfirmForm extends ConfirmFormBase implements ControllerInterf
'#items' => $items, '#items' => $items,
); );
return parent::buildForm($form, $form_state, $this->request); return parent::buildForm($form, $form_state);
} }
/** /**
@ -163,7 +140,7 @@ class ModulesListConfirmForm extends ConfirmFormBase implements ControllerInterf
*/ */
public function submitForm(array &$form, array &$form_state) { public function submitForm(array &$form, array &$form_state) {
// Remove the key value store entry. // Remove the key value store entry.
$account = $this->request->attributes->get('_account')->id(); $account = $this->getCurrentUser()->id();
$this->keyValueExpirable->delete($account); $this->keyValueExpirable->delete($account);
// Gets list of modules prior to install process. // Gets list of modules prior to install process.
@ -181,7 +158,7 @@ class ModulesListConfirmForm extends ConfirmFormBase implements ControllerInterf
// message if there are changes. // message if there are changes.
if ($before != $this->moduleHandler->getModuleList()) { if ($before != $this->moduleHandler->getModuleList()) {
drupal_flush_all_caches(); 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(); $form_state['redirect'] = $this->getCancelPath();

View File

@ -7,15 +7,11 @@
namespace Drupal\system\Form; namespace Drupal\system\Form;
use Drupal\Core\Controller\ControllerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\KeyValueStore\KeyValueExpirableFactory;
use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface;
use Drupal\Core\StringTranslation\TranslationManager;
use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\Unicode;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Provides module enable/disable interface. * Provides module enable/disable interface.
@ -25,7 +21,7 @@ use Symfony\Component\HttpFoundation\Request;
* requires. See drupal_parse_info_file() for info on module.info.yml * requires. See drupal_parse_info_file() for info on module.info.yml
* descriptors. * descriptors.
*/ */
class ModulesListForm implements FormInterface, ControllerInterface { class ModulesListForm extends FormBase {
/** /**
* The module handler service. * The module handler service.
@ -41,28 +37,13 @@ class ModulesListForm implements FormInterface, ControllerInterface {
*/ */
protected $keyValueExpirable; protected $keyValueExpirable;
/**
* The translation manager service.
*
* @var \Drupal\Core\StringTranslation\TranslationManager
*/
protected $translationManager;
/**
* The request object.
*
* @var \Symfony\Component\HttpFoundation\Request
*/
protected $request;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function create(ContainerInterface $container) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'), $container->get('module_handler'),
$container->get('keyvalue.expirable')->get('module_list'), $container->get('keyvalue.expirable')->get('module_list')
$container->get('string_translation')
); );
} }
@ -73,13 +54,10 @@ class ModulesListForm implements FormInterface, ControllerInterface {
* The module handler. * The module handler.
* @param \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface $key_value_expirable * @param \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface $key_value_expirable
* The key value expirable factory. * 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->moduleHandler = $module_handler;
$this->keyValueExpirable = $key_value_expirable; $this->keyValueExpirable = $key_value_expirable;
$this->translationManager = $translation_manager;
} }
/** /**
@ -92,16 +70,13 @@ class ModulesListForm implements FormInterface, ControllerInterface {
/** /**
* {@inheritdoc} * {@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'; require_once DRUPAL_ROOT . '/core/includes/install.inc';
$distribution = check_plain(drupal_install_profile_distribution_name()); $distribution = check_plain(drupal_install_profile_distribution_name());
// Include system.admin.inc so we can use the sort callbacks. // Include system.admin.inc so we can use the sort callbacks.
$this->moduleHandler->loadInclude('system', 'inc', 'system.admin'); $this->moduleHandler->loadInclude('system', 'inc', 'system.admin');
// Store the request for use in the submit handler.
$this->request = $request;
$form['filters'] = array( $form['filters'] = array(
'#type' => 'container', '#type' => 'container',
'#attributes' => array( '#attributes' => array(
@ -111,14 +86,14 @@ class ModulesListForm implements FormInterface, ControllerInterface {
$form['filters']['text'] = array( $form['filters']['text'] = array(
'#type' => 'search', '#type' => 'search',
'#title' => $this->translationManager->translate('Search'), '#title' => $this->t('Search'),
'#size' => 30, '#size' => 30,
'#placeholder' => $this->translationManager->translate('Enter module name'), '#placeholder' => $this->t('Enter module name'),
'#attributes' => array( '#attributes' => array(
'class' => array('table-filter-text'), 'class' => array('table-filter-text'),
'data-table' => '#system-modules', 'data-table' => '#system-modules',
'autocomplete' => 'off', '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 +114,12 @@ class ModulesListForm implements FormInterface, ControllerInterface {
foreach (element_children($form['modules']) as $package) { foreach (element_children($form['modules']) as $package) {
$form['modules'][$package] += array( $form['modules'][$package] += array(
'#type' => 'details', '#type' => 'details',
'#title' => $this->translationManager->translate($package), '#title' => $this->t($package),
'#theme' => 'system_modules_details', '#theme' => 'system_modules_details',
'#header' => array( '#header' => array(
array('data' => '<span class="visually-hidden">' . $this->translationManager->translate('Enabled') . '</span>', 'class' => array('checkbox')), array('data' => '<span class="visually-hidden">' . $this->t('Enabled') . '</span>', 'class' => array('checkbox')),
array('data' => $this->translationManager->translate('Name'), 'class' => array('name')), array('data' => $this->t('Name'), 'class' => array('name')),
array('data' => $this->translationManager->translate('Description'), 'class' => array('description', RESPONSIVE_PRIORITY_LOW)), array('data' => $this->t('Description'), 'class' => array('description', RESPONSIVE_PRIORITY_LOW)),
), ),
'#attributes' => array('class' => array('package-listing')), '#attributes' => array('class' => array('package-listing')),
// Ensure that the "Core" package comes first. // Ensure that the "Core" package comes first.
@ -159,7 +134,7 @@ class ModulesListForm implements FormInterface, ControllerInterface {
$form['actions'] = array('#type' => 'actions'); $form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array( $form['actions']['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => $this->translationManager->translate('Save configuration'), '#value' => $this->t('Save configuration'),
); );
return $form; return $form;
@ -184,7 +159,7 @@ class ModulesListForm implements FormInterface, ControllerInterface {
$row['#required_by'] = array(); $row['#required_by'] = array();
$row['name']['#markup'] = $module->info['name']; $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']; $row['version']['#markup'] = $module->info['version'];
// Add links for each module. // Add links for each module.
@ -197,9 +172,9 @@ class ModulesListForm implements FormInterface, ControllerInterface {
if ($this->moduleHandler->invoke($module->name, 'help', array("admin/help#$module->name", $help))) { if ($this->moduleHandler->invoke($module->name, 'help', array("admin/help#$module->name", $help))) {
$row['links']['help'] = array( $row['links']['help'] = array(
'#type' => 'link', '#type' => 'link',
'#title' => $this->translationManager->translate('Help'), '#title' => $this->t('Help'),
'#href' => "admin/help/$module->name", '#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 +184,9 @@ class ModulesListForm implements FormInterface, ControllerInterface {
if ($module->status && user_access('administer permissions') && in_array($module->name, $this->moduleHandler->getImplementations('permission'))) { if ($module->status && user_access('administer permissions') && in_array($module->name, $this->moduleHandler->getImplementations('permission'))) {
$row['links']['permissions'] = array( $row['links']['permissions'] = array(
'#type' => 'link', '#type' => 'link',
'#title' => $this->translationManager->translate('Permissions'), '#title' => $this->t('Permissions'),
'#href' => 'admin/people/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 +196,7 @@ class ModulesListForm implements FormInterface, ControllerInterface {
if (($configure = menu_get_item($module->info['configure'])) && $configure['access']) { if (($configure = menu_get_item($module->info['configure'])) && $configure['access']) {
$row['links']['configure'] = array( $row['links']['configure'] = array(
'#type' => 'link', '#type' => 'link',
'#title' => $this->translationManager->translate('Configure'), '#title' => $this->t('Configure'),
'#href' => $configure['href'], '#href' => $configure['href'],
'#options' => array('attributes' => array('class' => array('module-link', 'module-link-configure'), 'title' => $configure['description'])), '#options' => array('attributes' => array('class' => array('module-link', 'module-link-configure'), 'title' => $configure['description'])),
); );
@ -231,7 +206,7 @@ class ModulesListForm implements FormInterface, ControllerInterface {
// Present a checkbox for installing and indicating the status of a module. // Present a checkbox for installing and indicating the status of a module.
$row['enable'] = array( $row['enable'] = array(
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => $this->translationManager->translate('Enable'), '#title' => $this->t('Enable'),
'#default_value' => (bool) $module->status, '#default_value' => (bool) $module->status,
); );
@ -249,7 +224,7 @@ class ModulesListForm implements FormInterface, ControllerInterface {
// Check the core compatibility. // Check the core compatibility.
if ($module->info['core'] != DRUPAL_CORE_COMPATIBILITY) { if ($module->info['core'] != DRUPAL_CORE_COMPATIBILITY) {
$compatible = FALSE; $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, '!core_version' => DRUPAL_CORE_COMPATIBILITY,
)); ));
} }
@ -258,7 +233,7 @@ class ModulesListForm implements FormInterface, ControllerInterface {
if (version_compare(phpversion(), $module->info['php']) < 0) { if (version_compare(phpversion(), $module->info['php']) < 0) {
$compatible = FALSE; $compatible = FALSE;
$required = $module->info['php'] . (substr_count($module->info['php'], '.') < 2 ? '.*' : ''); $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_required' => $required,
'!php_version' => phpversion(), '!php_version' => phpversion(),
)); ));
@ -276,7 +251,7 @@ class ModulesListForm implements FormInterface, ControllerInterface {
// If this module requires other modules, add them to the array. // If this module requires other modules, add them to the array.
foreach ($module->requires as $dependency => $version) { foreach ($module->requires as $dependency => $version) {
if (!isset($modules[$dependency])) { if (!isset($modules[$dependency])) {
$row['#requires'][$dependency] = $this->translationManager->translate('@module (<span class="admin-missing">missing</span>)', array('@module' => Unicode::ucfirst($dependency))); $row['#requires'][$dependency] = $this->t('@module (<span class="admin-missing">missing</span>)', array('@module' => Unicode::ucfirst($dependency)));
$row['enable']['#disabled'] = TRUE; $row['enable']['#disabled'] = TRUE;
} }
// Only display visible modules. // Only display visible modules.
@ -285,7 +260,7 @@ class ModulesListForm implements FormInterface, ControllerInterface {
// Disable the module's checkbox if it is incompatible with the // Disable the module's checkbox if it is incompatible with the
// dependency's version. // dependency's version.
if ($incompatible_version = drupal_check_incompatibility($version, str_replace(DRUPAL_CORE_COMPATIBILITY . '-', '', $modules[$dependency]->info['version']))) { if ($incompatible_version = drupal_check_incompatibility($version, str_replace(DRUPAL_CORE_COMPATIBILITY . '-', '', $modules[$dependency]->info['version']))) {
$row['#requires'][$dependency] = $this->translationManager->translate('@module (<span class="admin-missing">incompatible with</span> version @version)', array( $row['#requires'][$dependency] = $this->t('@module (<span class="admin-missing">incompatible with</span> version @version)', array(
'@module' => $name . $incompatible_version, '@module' => $name . $incompatible_version,
'@version' => $modules[$dependency]->info['version'], '@version' => $modules[$dependency]->info['version'],
)); ));
@ -294,16 +269,16 @@ class ModulesListForm implements FormInterface, ControllerInterface {
// Disable the checkbox if the dependency is incompatible with this // Disable the checkbox if the dependency is incompatible with this
// version of Drupal core. // version of Drupal core.
elseif ($modules[$dependency]->info['core'] != DRUPAL_CORE_COMPATIBILITY) { elseif ($modules[$dependency]->info['core'] != DRUPAL_CORE_COMPATIBILITY) {
$row['#requires'][$dependency] = $this->translationManager->translate('@module (<span class="admin-missing">incompatible with</span> this version of Drupal core)', array( $row['#requires'][$dependency] = $this->t('@module (<span class="admin-missing">incompatible with</span> this version of Drupal core)', array(
'@module' => $name, '@module' => $name,
)); ));
$row['enable']['#disabled'] = TRUE; $row['enable']['#disabled'] = TRUE;
} }
elseif ($modules[$dependency]->status) { elseif ($modules[$dependency]->status) {
$row['#requires'][$dependency] = $this->translationManager->translate('@module', array('@module' => $name)); $row['#requires'][$dependency] = $this->t('@module', array('@module' => $name));
} }
else { else {
$row['#requires'][$dependency] = $this->translationManager->translate('@module (<span class="admin-disabled">disabled</span>)', array('@module' => $name)); $row['#requires'][$dependency] = $this->t('@module (<span class="admin-disabled">disabled</span>)', array('@module' => $name));
} }
} }
} }
@ -313,11 +288,11 @@ class ModulesListForm implements FormInterface, ControllerInterface {
foreach ($module->required_by as $dependent => $version) { foreach ($module->required_by as $dependent => $version) {
if (isset($modules[$dependent]) && empty($modules[$dependent]->info['hidden'])) { if (isset($modules[$dependent]) && empty($modules[$dependent]->info['hidden'])) {
if ($modules[$dependent]->status == 1 && $module->status == 1) { 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; $row['enable']['#disabled'] = TRUE;
} }
else { else {
$row['#required_by'][$dependent] = $this->translationManager->translate('@module (<span class="admin-disabled">disabled</span>)', array('@module' => $modules[$dependent]->info['name'])); $row['#required_by'][$dependent] = $this->t('@module (<span class="admin-disabled">disabled</span>)', array('@module' => $modules[$dependent]->info['name']));
} }
} }
} }
@ -409,12 +384,6 @@ class ModulesListForm implements FormInterface, ControllerInterface {
return $modules; return $modules;
} }
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, array &$form_state) {
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -426,7 +395,7 @@ class ModulesListForm implements FormInterface, ControllerInterface {
// dependencies that are not enabled yet, redirect to the confirmation form. // dependencies that are not enabled yet, redirect to the confirmation form.
if (!empty($modules['dependencies']) || !empty($modules['missing'])) { if (!empty($modules['dependencies']) || !empty($modules['missing'])) {
// Write the list of changed module states into a key value store. // 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); $this->keyValueExpirable->setWithExpire($account, $modules, 60);
// Redirect to the confirmation form. // Redirect to the confirmation form.

View File

@ -8,12 +8,9 @@
namespace Drupal\system\Form; namespace Drupal\system\Form;
use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\StringTranslation\TranslationManager;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Controller\ControllerInterface; use Drupal\Core\Controller\ControllerInterface;
use Drupal\Core\KeyValueStore\KeyValueExpirableFactory;
use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
@ -36,20 +33,6 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase implements ControllerI
*/ */
protected $keyValueExpirable; 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. * An array of modules to uninstall.
* *
@ -57,17 +40,6 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase implements ControllerI
*/ */
protected $modules = array(); 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. * Constructs a ModulesUninstallConfirmForm object.
* *
@ -75,27 +47,34 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase implements ControllerI
* The module handler. * The module handler.
* @param \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface $key_value_expirable * @param \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface $key_value_expirable
* The key value expirable factory. * 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->moduleHandler = $module_handler;
$this->keyValueExpirable = $key_value_expirable; $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} * {@inheritdoc}
*/ */
public function getQuestion() { public function getQuestion() {
return $this->translationManager->translate('Confirm uninstall'); return $this->t('Confirm uninstall');
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getConfirmText() { public function getConfirmText() {
return $this->translationManager->translate('Uninstall'); return $this->t('Uninstall');
} }
/** /**
@ -109,7 +88,7 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase implements ControllerI
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getDescription() { 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 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase implements ControllerI
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function buildForm(array $form, array &$form_state, Request $request = NULL) { public function buildForm(array $form, array &$form_state) {
// Store the request for use in the submit handler.
$this->request = $request;
// Retrieve the list of modules from the key value store. // 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); $this->modules = $this->keyValueExpirable->get($account);
// Prevent this page from showing when the module list is empty. // Prevent this page from showing when the module list is empty.
@ -136,7 +112,7 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase implements ControllerI
} }
$data = system_rebuild_module_data(); $data = system_rebuild_module_data();
$form['text']['#markup'] = '<p>' . $this->translationManager->translate('The following modules will be completely uninstalled from your site, and <em>all data from these modules will be lost</em>!') . '</p>'; $form['text']['#markup'] = '<p>' . $this->t('The following modules will be completely uninstalled from your site, and <em>all data from these modules will be lost</em>!') . '</p>';
$form['modules'] = array( $form['modules'] = array(
'#theme' => 'item_list', '#theme' => 'item_list',
'#items' => array_map(function ($module) use ($data) { '#items' => array_map(function ($module) use ($data) {
@ -144,7 +120,7 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase implements ControllerI
}, $this->modules), }, $this->modules),
); );
return parent::buildForm($form, $form_state, $request); return parent::buildForm($form, $form_state);
} }
/** /**
@ -152,13 +128,13 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase implements ControllerI
*/ */
public function submitForm(array &$form, array &$form_state) { public function submitForm(array &$form, array &$form_state) {
// Clear the key value store entry. // Clear the key value store entry.
$account = $this->request->attributes->get('_account')->id(); $account = $this->getCurrentUser()->id();
$this->keyValueExpirable->delete($account); $this->keyValueExpirable->delete($account);
// Uninstall the modules. // Uninstall the modules.
$this->moduleHandler->uninstall($this->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'; $form_state['redirect'] = 'admin/modules/uninstall';
} }

View File

@ -7,19 +7,15 @@
namespace Drupal\system\Form; 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 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. * Provides a form for uninstalling modules.
*/ */
class ModulesUninstallForm implements FormInterface, ControllerInterface { class ModulesUninstallForm extends FormBase {
/** /**
* The module handler service. * The module handler service.
@ -35,28 +31,13 @@ class ModulesUninstallForm implements FormInterface, ControllerInterface {
*/ */
protected $keyValueExpirable; protected $keyValueExpirable;
/**
* The translation manager service.
*
* @var \Drupal\Core\StringTranslation\TranslationManager
*/
protected $translationManager;
/**
* The request object.
*
* @var \Symfony\Component\HttpFoundation\Request
*/
protected $request;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function create(ContainerInterface $container) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'), $container->get('module_handler'),
$container->get('keyvalue.expirable')->get('modules_uninstall'), $container->get('keyvalue.expirable')->get('modules_uninstall')
$container->get('string_translation')
); );
} }
@ -67,13 +48,10 @@ class ModulesUninstallForm implements FormInterface, ControllerInterface {
* The module handler. * The module handler.
* @param \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface $key_value_expirable * @param \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface $key_value_expirable
* The key value expirable factory. * 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->moduleHandler = $module_handler;
$this->keyValueExpirable = $key_value_expirable; $this->keyValueExpirable = $key_value_expirable;
$this->translationManager = $translation_manager;
} }
/** /**
@ -86,10 +64,7 @@ class ModulesUninstallForm implements FormInterface, ControllerInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function buildForm(array $form, array &$form_state, Request $request = NULL) { public function buildForm(array $form, array &$form_state) {
// Store the request for use in the submit handler.
$this->request = $request;
// Make sure the install API is available. // Make sure the install API is available.
include_once DRUPAL_ROOT . '/core/includes/install.inc'; include_once DRUPAL_ROOT . '/core/includes/install.inc';
@ -118,11 +93,11 @@ class ModulesUninstallForm implements FormInterface, ControllerInterface {
$name = $module->info['name'] ?: $module->name; $name = $module->info['name'] ?: $module->name;
$form['modules'][$module->name]['#module_name'] = $name; $form['modules'][$module->name]['#module_name'] = $name;
$form['modules'][$module->name]['name']['#markup'] = $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( $form['uninstall'][$module->name] = array(
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => $this->translationManager->translate('Uninstall @module module', array('@module' => $name)), '#title' => $this->t('Uninstall @module module', array('@module' => $name)),
'#title_display' => 'invisible', '#title_display' => 'invisible',
); );
@ -141,7 +116,7 @@ class ModulesUninstallForm implements FormInterface, ControllerInterface {
$form['actions'] = array('#type' => 'actions'); $form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array( $form['actions']['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => $this->translationManager->translate('Uninstall'), '#value' => $this->t('Uninstall'),
); );
return $form; return $form;
@ -153,7 +128,7 @@ class ModulesUninstallForm implements FormInterface, ControllerInterface {
public function validateForm(array &$form, array &$form_state) { public function validateForm(array &$form, array &$form_state) {
// Form submitted, but no modules selected. // Form submitted, but no modules selected.
if (!array_filter($form_state['values']['uninstall'])) { 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'; $form_state['redirect'] = 'admin/modules/uninstall';
} }
} }
@ -165,7 +140,7 @@ class ModulesUninstallForm implements FormInterface, ControllerInterface {
// Save all the values in an expirable key value store. // Save all the values in an expirable key value store.
$modules = $form_state['values']['uninstall']; $modules = $form_state['values']['uninstall'];
$uninstall = array_keys(array_filter($modules)); $uninstall = array_keys(array_filter($modules));
$account = $this->request->attributes->get('_account')->id(); $account = $this->getCurrentUser()->id();
$this->keyValueExpirable->setWithExpire($account, $uninstall, 60); $this->keyValueExpirable->setWithExpire($account, $uninstall, 60);
// Redirect to the confirm form. // Redirect to the confirm form.

View File

@ -35,7 +35,7 @@ class ThemeSettingsForm extends SystemConfigFormBase {
* The factory for configuration objects. * The factory for configuration objects.
* @param \Drupal\Core\Config\Context\ContextInterface $context * @param \Drupal\Core\Config\Context\ContextInterface $context
* The configuration context to use. * The configuration context to use.
* @param Drupal\Core\Extension\ModuleHandlerInterface * @param \Drupal\Core\Extension\ModuleHandlerInterface
* The module handler instance to use. * The module handler instance to use.
*/ */
public function __construct(ConfigFactory $config_factory, ContextInterface $context, ModuleHandlerInterface $module_handler) { public function __construct(ConfigFactory $config_factory, ContextInterface $context, ModuleHandlerInterface $module_handler) {

View File

@ -7,16 +7,15 @@
namespace Drupal\system; namespace Drupal\system;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Controller\ControllerInterface;
use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\Config\Context\ContextInterface; use Drupal\Core\Config\Context\ContextInterface;
use Drupal\Core\Form\FormBase;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Base class for implementing system configuration forms. * Base class for implementing system configuration forms.
*/ */
abstract class SystemConfigFormBase implements FormInterface, ControllerInterface { abstract class SystemConfigFormBase extends FormBase {
/** /**
* Stores the configuration factory. * Stores the configuration factory.
@ -55,7 +54,7 @@ abstract class SystemConfigFormBase implements FormInterface, ControllerInterfac
$form['actions']['#type'] = 'actions'; $form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array( $form['actions']['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Save configuration'), '#value' => $this->t('Save configuration'),
'#button_type' => 'primary', '#button_type' => 'primary',
); );
@ -65,17 +64,11 @@ abstract class SystemConfigFormBase implements FormInterface, ControllerInterfac
return $form; return $form;
} }
/**
* Implements \Drupal\Core\Form\FormInterface::validateForm().
*/
public function validateForm(array &$form, array &$form_state) {
}
/** /**
* Implements \Drupal\Core\Form\FormInterface::submitForm(). * Implements \Drupal\Core\Form\FormInterface::submitForm().
*/ */
public function submitForm(array &$form, array &$form_state) { 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.'));
} }
} }

View File

@ -8,7 +8,6 @@
namespace Drupal\form_test; namespace Drupal\form_test;
use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\ConfirmFormBase;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Provides a test confirmation form. * Provides a test confirmation form.
@ -60,10 +59,10 @@ class ConfirmFormTestForm extends ConfirmFormBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function buildForm(array $form, array &$form_state, Request $request = NULL) { public function buildForm(array $form, array &$form_state) {
$form['element'] = array('#markup' => '<p>The ConfirmFormTestForm::buildForm() method was used for this form.</p>'); $form['element'] = array('#markup' => '<p>The ConfirmFormTestForm::buildForm() method was used for this form.</p>');
return parent::buildForm($form, $form_state, $request); return parent::buildForm($form, $form_state);
} }
/** /**

View File

@ -8,16 +8,14 @@
namespace Drupal\taxonomy\Form; namespace Drupal\taxonomy\Form;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\taxonomy\VocabularyStorageControllerInterface; use Drupal\taxonomy\VocabularyStorageControllerInterface;
use Drupal\Core\Entity\EntityNGConfirmFormBase; use Drupal\Core\Entity\EntityNGConfirmFormBase;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
/** /**
* Provides a deletion confirmation form for taxonomy term. * Provides a deletion confirmation form for taxonomy term.
*/ */
class TermDeleteForm extends EntityNGConfirmFormBase implements EntityControllerInterface { class TermDeleteForm extends EntityNGConfirmFormBase {
/** /**
* The taxonomy vocabulary storage controller. * The taxonomy vocabulary storage controller.
@ -29,20 +27,18 @@ class TermDeleteForm extends EntityNGConfirmFormBase implements EntityController
/** /**
* Constructs a new TermDelete object. * Constructs a new TermDelete object.
* *
* @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage_controller * @param \Drupal\taxonomy\VocabularyStorageControllerInterface $storage_controller
* The Entity manager. * The Entity manager.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, VocabularyStorageControllerInterface $storage_controller) { public function __construct(VocabularyStorageControllerInterface $storage_controller) {
parent::__construct($module_handler);
$this->vocabularyStorageController = $storage_controller; $this->vocabularyStorageController = $storage_controller;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'),
$container->get('plugin.manager.entity')->getStorageController('taxonomy_vocabulary') $container->get('plugin.manager.entity')->getStorageController('taxonomy_vocabulary')
); );
} }

View File

@ -9,15 +9,12 @@ namespace Drupal\taxonomy\Form;
use Drupal\Core\Database\Connection; use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Provides confirmation form for resetting a vocabulary to alphabetical order. * Provides confirmation form for resetting a vocabulary to alphabetical order.
*/ */
class VocabularyResetForm extends EntityConfirmFormBase implements EntityControllerInterface { class VocabularyResetForm extends EntityConfirmFormBase {
/** /**
* The database connection object. * The database connection object.
@ -29,18 +26,15 @@ class VocabularyResetForm extends EntityConfirmFormBase implements EntityControl
/** /**
* Constructs a new VocabularyResetForm object. * Constructs a new VocabularyResetForm object.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, Connection $connection) { public function __construct(Connection $connection) {
parent::__construct($module_handler);
$this->connection = $connection; $this->connection = $connection;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'),
$container->get('database') $container->get('database')
); );
} }

View File

@ -205,4 +205,5 @@ class TermFormController extends EntityFormControllerNG {
} }
$form_state['redirect'] = array('taxonomy/term/' . $this->entity->id() . '/delete', array('query' => $destination)); $form_state['redirect'] = array('taxonomy/term/' . $this->entity->id() . '/delete', array('query' => $destination));
} }
} }

View File

@ -8,16 +8,14 @@
namespace Drupal\views_ui\Form; namespace Drupal\views_ui\Form;
use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Entity\EntityManager; use Drupal\Core\Entity\EntityManager;
use Drupal\user\TempStoreFactory; use Drupal\user\TempStoreFactory;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Builds the form to break the lock of an edited view. * Builds the form to break the lock of an edited view.
*/ */
class BreakLockForm extends EntityConfirmFormBase implements EntityControllerInterface { class BreakLockForm extends EntityConfirmFormBase {
/** /**
* Stores the Entity manager. * Stores the Entity manager.
@ -49,7 +47,7 @@ class BreakLockForm extends EntityConfirmFormBase implements EntityControllerInt
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('plugin.manager.entity'), $container->get('plugin.manager.entity'),
$container->get('user.tempstore') $container->get('user.tempstore')
@ -100,12 +98,12 @@ class BreakLockForm extends EntityConfirmFormBase implements EntityControllerInt
/** /**
* {@inheritdoc} * {@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())) { 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())); $form['message']['#markup'] = t('There is no lock on view %name to break.', array('%name' => $this->entity->id()));
return $form; return $form;
} }
return parent::buildForm($form, $form_state, $request); return parent::buildForm($form, $form_state);
} }
/** /**

View File

@ -7,8 +7,6 @@
namespace Drupal\views_ui; 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\WizardPluginBase;
use Drupal\views\Plugin\views\wizard\WizardException; use Drupal\views\Plugin\views\wizard\WizardException;
use Drupal\views\Plugin\ViewsPluginManager; use Drupal\views\Plugin\ViewsPluginManager;
@ -17,7 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Form controller for the Views edit form. * Form controller for the Views edit form.
*/ */
class ViewAddFormController extends ViewFormControllerBase implements EntityControllerInterface { class ViewAddFormController extends ViewFormControllerBase {
/** /**
* The wizard plugin manager. * The wizard plugin manager.
@ -29,23 +27,18 @@ class ViewAddFormController extends ViewFormControllerBase implements EntityCont
/** /**
* Constructs a new ViewEditFormController object. * Constructs a new ViewEditFormController object.
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface
* The module handler service.
* @param \Drupal\views\Plugin\ViewsPluginManager $wizard_manager * @param \Drupal\views\Plugin\ViewsPluginManager $wizard_manager
* The wizard plugin manager. * The wizard plugin manager.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, ViewsPluginManager $wizard_manager) { public function __construct(ViewsPluginManager $wizard_manager) {
parent::__construct($module_handler);
$this->wizardManager = $wizard_manager; $this->wizardManager = $wizard_manager;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'),
$container->get('plugin.manager.views.wizard') $container->get('plugin.manager.views.wizard')
); );
} }

View File

@ -10,10 +10,7 @@ namespace Drupal\views_ui;
use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\HtmlCommand; use Drupal\Core\Ajax\HtmlCommand;
use Drupal\Core\Ajax\ReplaceCommand; use Drupal\Core\Ajax\ReplaceCommand;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\NestedArray;
use Drupal\views\ViewExecutable;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\user\TempStoreFactory; use Drupal\user\TempStoreFactory;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
@ -21,7 +18,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Form controller for the Views edit form. * Form controller for the Views edit form.
*/ */
class ViewEditFormController extends ViewFormControllerBase implements EntityControllerInterface { class ViewEditFormController extends ViewFormControllerBase {
/** /**
* The views temp store. * The views temp store.
@ -40,16 +37,12 @@ class ViewEditFormController extends ViewFormControllerBase implements EntityCon
/** /**
* Constructs a new ViewEditFormController object. * Constructs a new ViewEditFormController object.
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface
* The module handler service.
* @param \Drupal\user\TempStoreFactory $temp_store_factory * @param \Drupal\user\TempStoreFactory $temp_store_factory
* The factory for the temp store object. * The factory for the temp store object.
* @param \Symfony\Component\HttpFoundation\Request $request * @param \Symfony\Component\HttpFoundation\Request $request
* The request object. * The request object.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, TempStoreFactory $temp_store_factory, Request $request) { public function __construct(TempStoreFactory $temp_store_factory, Request $request) {
parent::__construct($module_handler);
$this->tempStore = $temp_store_factory->get('views'); $this->tempStore = $temp_store_factory->get('views');
$this->request = $request; $this->request = $request;
} }
@ -57,9 +50,8 @@ class ViewEditFormController extends ViewFormControllerBase implements EntityCon
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info, $operation = NULL) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'),
$container->get('user.tempstore'), $container->get('user.tempstore'),
$container->get('request') $container->get('request')
); );

View File

@ -7,15 +7,13 @@
namespace Drupal\views_ui; namespace Drupal\views_ui;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\user\TempStoreFactory; use Drupal\user\TempStoreFactory;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Form controller for the Views preview form. * Form controller for the Views preview form.
*/ */
class ViewPreviewFormController extends ViewFormControllerBase implements EntityControllerInterface { class ViewPreviewFormController extends ViewFormControllerBase {
/** /**
* The views temp store. * The views temp store.
@ -27,23 +25,18 @@ class ViewPreviewFormController extends ViewFormControllerBase implements Entity
/** /**
* Constructs a new ViewPreviewFormController object. * Constructs a new ViewPreviewFormController object.
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface
* The module handler service.
* @param \Drupal\user\TempStoreFactory $temp_store_factory * @param \Drupal\user\TempStoreFactory $temp_store_factory
* The factory for the temp store object. * The factory for the temp store object.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, TempStoreFactory $temp_store_factory) { public function __construct(TempStoreFactory $temp_store_factory) {
parent::__construct($module_handler);
$this->tempStore = $temp_store_factory->get('views'); $this->tempStore = $temp_store_factory->get('views');
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'),
$container->get('user.tempstore') $container->get('user.tempstore')
); );
} }