Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / service / path-processor.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/service/path-processor.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/service/path-processor.twig
new file mode 100644 (file)
index 0000000..8f370db
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+
+namespace Drupal\{{ machine_name }}\PathProcessor;
+
+use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
+use Drupal\Core\PathProcessor\OutboundPathProcessorInterface;
+use Drupal\Core\Render\BubbleableMetadata;
+use Symfony\Component\HttpFoundation\Request;
+
+/**
+ * Path processor to replace 'node' with 'content' in URLs.
+ */
+class {{ class }} implements InboundPathProcessorInterface, OutboundPathProcessorInterface {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function processInbound($path, Request $request) {
+    return preg_replace('#^/content/#', '/node/', $path);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
+    return preg_replace('#^/node/#', '/content/', $path);
+  }
+
+}