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