Pull merge.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / service / path-processor.twig
1 <?php
2
3 namespace Drupal\{{ machine_name }}\PathProcessor;
4
5 use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
6 use Drupal\Core\PathProcessor\OutboundPathProcessorInterface;
7 use Drupal\Core\Render\BubbleableMetadata;
8 use Symfony\Component\HttpFoundation\Request;
9
10 /**
11  * Path processor to replace 'node' with 'content' in URLs.
12  */
13 class {{ class }} implements InboundPathProcessorInterface, OutboundPathProcessorInterface {
14
15   /**
16    * {@inheritdoc}
17    */
18   public function processInbound($path, Request $request) {
19     return preg_replace('#^/content/#', '/node/', $path);
20   }
21
22   /**
23    * {@inheritdoc}
24    */
25   public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
26     return preg_replace('#^/node/#', '/content/', $path);
27   }
28
29 }