annotate vendor/chi-teck/drupal-code-generator/templates/d8/service/path-processor.twig @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\{{ machine_name }}\PathProcessor;
Chris@0 4
Chris@0 5 use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
Chris@0 6 use Drupal\Core\PathProcessor\OutboundPathProcessorInterface;
Chris@0 7 use Drupal\Core\Render\BubbleableMetadata;
Chris@0 8 use Symfony\Component\HttpFoundation\Request;
Chris@0 9
Chris@0 10 /**
Chris@0 11 * Path processor to replace 'node' with 'content' in URLs.
Chris@0 12 */
Chris@0 13 class {{ class }} implements InboundPathProcessorInterface, OutboundPathProcessorInterface {
Chris@0 14
Chris@0 15 /**
Chris@0 16 * {@inheritdoc}
Chris@0 17 */
Chris@0 18 public function processInbound($path, Request $request) {
Chris@0 19 return preg_replace('#^/content/#', '/node/', $path);
Chris@0 20 }
Chris@0 21
Chris@0 22 /**
Chris@0 23 * {@inheritdoc}
Chris@0 24 */
Chris@0 25 public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
Chris@0 26 return preg_replace('#^/node/#', '/content/', $path);
Chris@0 27 }
Chris@0 28
Chris@0 29 }