Mercurial > hg > isophonics-drupal-site
comparison core/modules/media/src/Routing/MediaRouteProvider.php @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
17:129ea1e6d783 | 18:af1871eacc83 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\media\Routing; | |
4 | |
5 use Drupal\Core\Config\ConfigFactoryInterface; | |
6 use Drupal\Core\Entity\EntityFieldManagerInterface; | |
7 use Drupal\Core\Entity\EntityTypeInterface; | |
8 use Drupal\Core\Entity\EntityTypeManagerInterface; | |
9 use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider; | |
10 use Symfony\Component\DependencyInjection\ContainerInterface; | |
11 | |
12 /** | |
13 * Provides HTML routes for media pages. | |
14 */ | |
15 class MediaRouteProvider extends AdminHtmlRouteProvider { | |
16 | |
17 /** | |
18 * The media settings config. | |
19 * | |
20 * @var \Drupal\Core\Config\ImmutableConfig | |
21 */ | |
22 protected $config; | |
23 | |
24 /** | |
25 * {@inheritdoc} | |
26 */ | |
27 public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, ConfigFactoryInterface $config_factory) { | |
28 parent::__construct($entity_type_manager, $entity_field_manager); | |
29 $this->config = $config_factory->get('media.settings'); | |
30 } | |
31 | |
32 /** | |
33 * {@inheritdoc} | |
34 */ | |
35 public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { | |
36 return new static( | |
37 $container->get('entity_type.manager'), | |
38 $container->get('entity_field.manager'), | |
39 $container->get('config.factory') | |
40 ); | |
41 } | |
42 | |
43 /** | |
44 * {@inheritdoc} | |
45 */ | |
46 protected function getCanonicalRoute(EntityTypeInterface $entity_type) { | |
47 if ($this->config->get('standalone_url')) { | |
48 return parent::getCanonicalRoute($entity_type); | |
49 } | |
50 else { | |
51 return parent::getEditFormRoute($entity_type); | |
52 } | |
53 } | |
54 | |
55 } |