diff --git a/core/lib/Drupal/Core/Entity/ContentEntityFormController.php b/core/lib/Drupal/Core/Entity/ContentEntityFormController.php index 0a360c6..f7f2833 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityFormController.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityFormController.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Entity; +use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Language\Language; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -20,30 +21,32 @@ class ContentEntityFormController extends EntityFormController { /** * The entity manager. * - * @var \Drupal\Core\Entity\EntityManager + * @var \Drupal\Core\Entity\EntityManagerInterface */ protected $entityManager; /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static($container->get('entity.manager')); - } - - /** * Constructs a ContentEntityFormController object. * - * @param \Drupal\Core\Entity\EntityManager $entity_manager + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. */ - public function __construct(\Drupal\Core\Entity\EntityManager $entity_manager) { + public function __construct(EntityManagerInterface $entity_manager) { $this->entityManager = $entity_manager; } /** * {@inheritdoc} */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('entity.manager') + ); + } + + /** + * {@inheritdoc} + */ public function form(array $form, array &$form_state) { $entity = $this->entity; // @todo Exploit the Field API to generate the default widgets for the diff --git a/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php b/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php index 0ca5bef..d4761f5 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php @@ -9,7 +9,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Entity\ContentEntityFormController; -use Drupal\Core\Entity\EntityStorageControllerInterface; +use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Language\Language; use Drupal\aggregator\CategoryStorageControllerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -20,13 +20,6 @@ class FeedFormController extends ContentEntityFormController { /** - * The feed storage. - * - * @var \Drupal\Core\Entity\EntityStorageControllerInterface - */ - protected $feedStorageController; - - /** * The category storage controller. * * @var \Drupal\aggregator\CategoryStorageControllerInterface @@ -36,13 +29,13 @@ class FeedFormController extends ContentEntityFormController { /** * Constructs a FeedForm object. * - * @param \Drupal\Core\Entity\EntityStorageControllerInterface $feed_storage - * The feed storage. + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * The entity manager. * @param \Drupal\aggregator\CategoryStorageControllerInterface $category_storage_controller * The category storage controller. */ - public function __construct(EntityStorageControllerInterface $feed_storage, CategoryStorageControllerInterface $category_storage_controller) { - $this->feedStorageController = $feed_storage; + public function __construct(EntityManagerInterface $entity_manager, CategoryStorageControllerInterface $category_storage_controller) { + parent::__construct($entity_manager); $this->categoryStorageController = $category_storage_controller; } @@ -51,7 +44,7 @@ public function __construct(EntityStorageControllerInterface $feed_storage, Cate */ public static function create(ContainerInterface $container) { return new static( - $container->get('plugin.manager.entity')->getStorageController('aggregator_feed'), + $container->get('entity.manager'), $container->get('aggregator.category.storage') ); } @@ -125,7 +118,8 @@ public function form(array $form, array &$form_state) { public function validate(array $form, array &$form_state) { $feed = $this->buildEntity($form, $form_state); // Check for duplicate titles. - $result = $this->feedStorageController->getFeedDuplicates($feed); + $feed_storage_controller = $this->entityManager->getStorageController('aggregator_feed'); + $result = $feed_storage_controller->getFeedDuplicates($feed); foreach ($result as $item) { if (strcasecmp($item->title, $feed->label()) == 0) { form_set_error('title', $this->t('A feed named %feed already exists. Enter a unique title.', array('%feed' => $feed->label()))); diff --git a/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php b/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php index 94d9b8a..61ff1fc 100644 --- a/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php +++ b/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php @@ -8,6 +8,7 @@ namespace Drupal\book\Form; use Drupal\Core\Entity\ContentEntityFormController; +use Drupal\Core\Entity\EntityManagerInterface; use Drupal\book\BookManager; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -32,19 +33,25 @@ class BookOutlineForm extends ContentEntityFormController { /** * Constructs a BookOutlineForm object. + * + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * The entity manager. + * @param \Drupal\book\BookManager $book_manager + * The BookManager service. */ - public function __construct(BookManager $bookManager) { - $this->bookManager = $bookManager; + public function __construct(EntityManagerInterface $entity_manager, BookManager $book_manager) { + parent::__construct($entity_manager); + $this->bookManager = $book_manager; } /** - * This method lets us inject the services this class needs. - * - * Only inject services that are actually needed. Which services - * are needed will vary by the controller. + * {@inheritdoc} */ public static function create(ContainerInterface $container) { - return new static($container->get('book.manager')); + return new static( + $container->get('entity.manager'), + $container->get('book.manager') + ); } /** diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index bfc2a6a..f0c38ad 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -24,13 +24,6 @@ class CommentFormController extends ContentEntityFormController { /** - * The entity manager service. - * - * @var \Drupal\Core\Entity\EntityManagerInterface - */ - protected $entityManager; - - /** * The field info service. * * @var \Drupal\field\FieldInfo @@ -59,7 +52,7 @@ public static function create(ContainerInterface $container) { * The current user. */ public function __construct(EntityManagerInterface $entity_manager, FieldInfo $field_info, AccountInterface $current_user) { - $this->entityManager = $entity_manager; + parent::__construct($entity_manager); $this->fieldInfo = $field_info; $this->currentUser = $current_user; } diff --git a/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php b/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php index 07f3146..60b2036 100644 --- a/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php +++ b/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php @@ -10,6 +10,7 @@ use Drupal\comment\CommentManagerInterface; use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\ContentEntityConfirmFormBase; +use Drupal\Core\Entity\EntityManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -27,10 +28,13 @@ class DeleteForm extends ContentEntityConfirmFormBase { /** * Constructs a DeleteForm object. * + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * The entity manager. * @param \Drupal\comment\CommentManagerInterface $comment_manager * The comment manager service. */ - public function __construct(CommentManagerInterface $comment_manager) { + public function __construct(EntityManagerInterface $entity_manager, CommentManagerInterface $comment_manager) { + parent::__construct($entity_manager); $this->commentManager = $comment_manager; } @@ -39,6 +43,7 @@ public function __construct(CommentManagerInterface $comment_manager) { */ public static function create(ContainerInterface $container) { return new static( + $container->get('entity.manager'), $container->get('comment.manager') ); } diff --git a/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php b/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php index 56bbb51..7b758ef 100644 --- a/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php +++ b/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php @@ -8,11 +8,7 @@ namespace Drupal\forum\Form; use Drupal\Core\Cache\Cache; -use Drupal\Core\Config\ConfigFactory; use Drupal\taxonomy\TermFormController; -use Drupal\taxonomy\TermStorageControllerInterface; -use Drupal\taxonomy\VocabularyStorageControllerInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Base form controller for forum term edit forms. @@ -34,47 +30,6 @@ class ForumFormController extends TermFormController { protected $urlStub = 'forum'; /** - * The forum config. - * - * @var \Drupal\Core\Config\Config - */ - protected $config; - - /** - * Term Storage Controller. - * - * @var \Drupal\taxonomy\TermStorageControllerInterface - */ - protected $termStorage; - - /** - * Constructs a new ForumFormController object. - * - * @param \Drupal\taxonomy\VocabularyStorageControllerInterface $vocab_storage - * The vocabulary storage. - * @param \Drupal\Core\Config\ConfigFactory $config_factory - * The config factory service. - * @param \Drupal\taxonomy\TermStorageControllerInterface $term_storage - * The term storage. - */ - public function __construct(VocabularyStorageControllerInterface $vocab_storage, ConfigFactory $config_factory, TermStorageControllerInterface $term_storage) { - parent::__construct($vocab_storage, $config_factory); - $this->termStorage = $term_storage; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - $entity_manager = $container->get('entity.manager'); - return new static( - $entity_manager->getStorageController('taxonomy_vocabulary'), - $container->get('config.factory'), - $entity_manager->getStorageController('taxonomy_term') - ); - } - - /** * {@inheritdoc} */ public function form(array $form, array &$form_state) { @@ -121,8 +76,9 @@ public function buildEntity(array $form, array &$form_state) { */ public function save(array $form, array &$form_state) { $term = $this->entity; + $term_storage = $this->entityManager->getStorageController('taxonomy_term'); + $status = $term_storage->save($term); - $status = $this->termStorage->save($term); switch ($status) { case SAVED_NEW: drupal_set_message($this->t('Created new @type %term.', array('%term' => $term->label(), '@type' => $this->forumFormType))); diff --git a/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php b/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php index 11eb3f3..51da037 100644 --- a/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php +++ b/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php @@ -9,7 +9,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\ContentEntityConfirmFormBase; -use Drupal\Core\Entity\EntityStorageControllerInterface; +use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Routing\UrlGeneratorInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -26,23 +26,16 @@ class NodeDeleteForm extends ContentEntityConfirmFormBase { protected $urlGenerator; /** - * The node type storage. - * - * @var \Drupal\Core\Entity\EntityStorageControllerInterface - */ - protected $nodeTypeStorage; - - /** * Constructs a NodeDeleteForm object. * + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * The entity manager. * @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator * The URL generator. - * @param \Drupal\Core\Entity\EntityStorageControllerInterface $node_type_storage - * The node type storage. */ - public function __construct(UrlGeneratorInterface $url_generator, EntityStorageControllerInterface $node_type_storage) { + public function __construct(EntityManagerInterface $entity_manager, UrlGeneratorInterface $url_generator) { + parent::__construct($entity_manager); $this->urlGenerator = $url_generator; - $this->nodeTypeStorage = $node_type_storage; } /** @@ -50,8 +43,8 @@ public function __construct(UrlGeneratorInterface $url_generator, EntityStorageC */ public static function create(ContainerInterface $container) { return new static( - $container->get('url_generator'), - $container->get('entity.manager')->getStorageController('node_type') + $container->get('entity.manager'), + $container->get('url_generator') ); } @@ -94,7 +87,8 @@ public function getConfirmText() { public function submit(array $form, array &$form_state) { $this->entity->delete(); watchdog('content', '@type: deleted %title.', array('@type' => $this->entity->bundle(), '%title' => $this->entity->label())); - $node_type = $this->nodeTypeStorage->load($this->entity->bundle())->label(); + $node_type_storage = $this->entityManager->getStorageController('node_type'); + $node_type = $node_type_storage->load($this->entity->bundle())->label(); drupal_set_message(t('@type %title has been deleted.', array('@type' => $node_type, '%title' => $this->entity->label()))); Cache::invalidateTags(array('content' => TRUE)); $form_state['redirect'] = ''; diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php index 18d3a6a..cec3c3c 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php @@ -8,7 +8,7 @@ namespace Drupal\taxonomy\Form; use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\taxonomy\VocabularyStorageControllerInterface; +use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\ContentEntityConfirmFormBase; use Drupal\Core\Cache\Cache; @@ -18,32 +18,6 @@ class TermDeleteForm extends ContentEntityConfirmFormBase { /** - * The taxonomy vocabulary storage controller. - * - * @var \Drupal\taxonomy\VocabularyStorageControllerInterface - */ - protected $vocabularyStorageController; - - /** - * Constructs a new TermDelete object. - * - * @param \Drupal\taxonomy\VocabularyStorageControllerInterface $storage_controller - * The Entity manager. - */ - public function __construct(VocabularyStorageControllerInterface $storage_controller) { - $this->vocabularyStorageController = $storage_controller; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('entity.manager')->getStorageController('taxonomy_vocabulary') - ); - } - - /** * {@inheritdoc} */ public function getFormId() { @@ -85,7 +59,8 @@ public function getConfirmText() { */ public function submit(array $form, array &$form_state) { $this->entity->delete(); - $vocabulary = $this->vocabularyStorageController->load($this->entity->bundle()); + $storage_controller = $this->entityManager->getStorageController('taxonomy_vocabulary'); + $vocabulary = $storage_controller->load($this->entity->bundle()); // @todo Move to storage controller http://drupal.org/node/1988712 taxonomy_check_vocabulary_hierarchy($vocabulary, array('tid' => $this->entity->id())); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php index 8821b09..0dbaf63 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php @@ -10,6 +10,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Entity\ContentEntityFormController; +use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Language\Language; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -19,13 +20,6 @@ class TermFormController extends ContentEntityFormController { /** - * The vocabulary storage. - * - * @var \Drupal\taxonomy\VocabularyStorageControllerInterface - */ - protected $vocabStorage; - - /** * The config factory. * * @var \Drupal\Core\Config\ConfigFactory @@ -35,13 +29,13 @@ class TermFormController extends ContentEntityFormController { /** * Constructs a new TermFormController. * - * @param \Drupal\taxonomy\VocabularyStorageControllerInterface $vocab_storage - * The vocabulary storage. + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * The entity manager. * @param \Drupal\Core\Config\ConfigFactory $config_factory * The config factory. */ - public function __construct(VocabularyStorageControllerInterface $vocab_storage, ConfigFactory $config_factory) { - $this->vocabStorage = $vocab_storage; + public function __construct(EntityManagerInterface $entity_manager, ConfigFactory $config_factory) { + parent::__construct($entity_manager); $this->configFactory = $config_factory; } @@ -50,7 +44,7 @@ public function __construct(VocabularyStorageControllerInterface $vocab_storage, */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager')->getStorageController('taxonomy_vocabulary'), + $container->get('entity.manager'), $container->get('config.factory') ); } @@ -60,7 +54,8 @@ public static function create(ContainerInterface $container) { */ public function form(array $form, array &$form_state) { $term = $this->entity; - $vocabulary = $this->vocabStorage->load($term->bundle()); + $vocab_storage = $this->entityManager->getStorageController('taxonomy_vocabulary'); + $vocabulary = $vocab_storage->load($term->bundle()); $parent = array_keys(taxonomy_term_load_parents($term->id())); $form_state['taxonomy']['parent'] = $parent; diff --git a/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php b/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php index 973c84e..59d6145 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Entity\ContentEntityConfirmFormBase; +use Drupal\Core\Entity\EntityManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -42,8 +43,11 @@ class UserCancelForm extends ContentEntityConfirmFormBase { * * @param \Drupal\Core\Config\ConfigFactory $config_factory * The config factory. + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * The entity manager. */ - public function __construct(ConfigFactory $config_factory) { + public function __construct(EntityManagerInterface $entity_manager, ConfigFactory $config_factory) { + parent::__construct($entity_manager); $this->configFactory = $config_factory; } @@ -52,6 +56,7 @@ public function __construct(ConfigFactory $config_factory) { */ public static function create(ContainerInterface $container) { return new static( + $container->get('entity.manager'), $container->get('config.factory') ); }