diff --git a/core/modules/contact/lib/Drupal/contact/Controller/ContactPageController.php b/core/modules/contact/lib/Drupal/contact/Controller/ContactPageController.php index 4825194..b4fad38 100644 --- a/core/modules/contact/lib/Drupal/contact/Controller/ContactPageController.php +++ b/core/modules/contact/lib/Drupal/contact/Controller/ContactPageController.php @@ -7,14 +7,15 @@ namespace Drupal\contact\Controller; -use Drupal\Core\Session\AccountInterface; -use Drupal\user\UserInterface; -use Drupal\Core\Controller\ControllerInterface; -use Drupal\Core\Flood\FloodInterface; use Drupal\Core\Config\ConfigFactory; +use Drupal\Core\Controller\ControllerInterface; use Drupal\Core\Entity\EntityManager; +use Drupal\Core\Flood\FloodInterface; +use Drupal\Core\Routing\PathBasedGeneratorInterface; +use Drupal\Core\Session\AccountInterface; use Drupal\Core\StringTranslation\Translator\TranslatorInterface; use Drupal\contact\Plugin\Core\Entity\Category; +use Drupal\user\UserInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -46,6 +47,13 @@ class ContactPageController implements ControllerInterface { protected $entityManager; /** + * The URL generator. + * + * @var \Drupal\Core\Routing\PathBasedGeneratorInterface + */ + protected $urlGenerator; + + /** * The translator service. * * @var \Drupal\Core\StringTranslation\Translator\TranslatorInterface @@ -61,13 +69,16 @@ class ContactPageController implements ControllerInterface { * Configuration Factory. * @param \Drupal\Core\Entity\EntityManager $entity_manager * Entity Manager. + * @param \Drupal\Core\Routing\PathBasedGeneratorInterface $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, TranslatorInterface $translator) { + public function __construct(FloodInterface $flood, ConfigFactory $config_factory, EntityManager $entity_manager, PathBasedGeneratorInterface $url_generator, TranslatorInterface $translator) { $this->flood = $flood; $this->configFactory = $config_factory; $this->entityManager = $entity_manager; + $this->urlGenerator = $url_generator; $this->translator = $translator; } @@ -79,6 +90,7 @@ public static function create(ContainerInterface $container) { $container->get('flood'), $container->get('config.factory'), $container->get('plugin.manager.entity'), + $container->get('url_generator'), $container->get('string_translation') ); } @@ -113,7 +125,8 @@ public function contactSitePage(AccountInterface $_account, Category $contact_ca // If there are no categories, do not display the form. if (empty($contact_category)) { if ($_account->hasPermission('administer contact forms')) { - drupal_set_message($this->translator->translate('The contact form has not been configured. Add one or more categories to the form.', array('@add' => url('admin/structure/contact/add'))), 'error'); + drupal_set_message($this->translator->translate('The contact form has not been configured. Add one or more categories to the form.', array( + '@add' => $this->urlGenerator->generateFromPath('admin/structure/contact/add'))), 'error'); return array(); } else {