diff --git a/core/modules/contact/lib/Drupal/contact/Controller/ContactPageController.php b/core/modules/contact/lib/Drupal/contact/Controller/ContactPageController.php index 8864714..d553119 100644 --- a/core/modules/contact/lib/Drupal/contact/Controller/ContactPageController.php +++ b/core/modules/contact/lib/Drupal/contact/Controller/ContactPageController.php @@ -11,8 +11,9 @@ use Drupal\Core\Controller\ControllerInterface; use Drupal\Core\Entity\EntityManager; use Drupal\Core\Flood\FloodInterface; -use Drupal\Core\Routing\PathBasedGeneratorInterface; +use Drupal\Core\Routing\UrlGeneratorInterface; use Drupal\Core\Session\AccountInterface; +use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\StringTranslation\Translator\TranslatorInterface; use Drupal\contact\Plugin\Core\Entity\Category; use Drupal\user\UserInterface; @@ -47,9 +48,16 @@ class ContactPageController implements ControllerInterface { protected $entityManager; /** + * Contact Storage Controller. + * + * @var \Drupal\Core\Entity\EntityStorageControllerInterface; + */ + protected $contactStorage; + + /** * The URL generator. * - * @var \Drupal\Core\Routing\PathBasedGeneratorInterface + * @var \Drupal\Core\Routing\UrlGeneratorInterface */ protected $urlGenerator; @@ -69,15 +77,16 @@ class ContactPageController implements ControllerInterface { * Configuration Factory. * @param \Drupal\Core\Entity\EntityManager $entity_manager * Entity Manager. - * @param \Drupal\Core\Routing\PathBasedGeneratorInterface $url_generator + * @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator * The URL generator. * @param \Drupal\Core\StringTranslation\Translator\TranslatorInterface $translator * The translator service. */ - public function __construct(FloodInterface $flood, ConfigFactory $config_factory, EntityManager $entity_manager, PathBasedGeneratorInterface $url_generator, TranslatorInterface $translator) { + public function __construct(FloodInterface $flood, ConfigFactory $config_factory, EntityManager $entity_manager, UrlGeneratorInterface $url_generator, TranslatorInterface $translator) { $this->flood = $flood; $this->contactSettings = $config_factory->get('contact.settings'); $this->entityManager = $entity_manager; + $this->contactStorage = $this->entityManager->getStorageController('contact_category'); $this->urlGenerator = $url_generator; $this->translator = $translator; } @@ -119,9 +128,7 @@ public function contactSitePage(AccountInterface $_account, Category $contact_ca // Use the default category if no category has been passed. if (empty($contact_category)) { $default_category = $this->contactSettings->get('default_category'); - $contact_category = $this->entityManager - ->getStorageController('contact_category') - ->load($default_category); + $contact_category = $this->contactStorage->load($default_category); // If there are no categories, do not display the form. if (empty($contact_category)) { if ($_account->hasPermission('administer contact forms')) { @@ -135,9 +142,7 @@ public function contactSitePage(AccountInterface $_account, Category $contact_ca } } - $message = $this->entityManager - ->getStorageController('contact_message') - ->create(array( + $message = $this->contactStorage->create(array( 'category' => $contact_category->id(), )); @@ -163,9 +168,7 @@ public function contactPersonalPage(UserInterface $user, AccountInterface $_acco drupal_set_title(); - $message = $this->entityManager - ->getStorageController('contact_message') - ->create(array( + $message = $this->contactStorage->create(array( 'category' => 'personal', 'recipient' => $user->id(), ));