Version 1
[yaffs-website] / web / modules / contrib / paragraphs / src / ParagraphsServiceProvider.php
diff --git a/web/modules/contrib/paragraphs/src/ParagraphsServiceProvider.php b/web/modules/contrib/paragraphs/src/ParagraphsServiceProvider.php
new file mode 100644 (file)
index 0000000..b8ce007
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+
+namespace Drupal\paragraphs;
+
+use Drupal\Core\DependencyInjection\ContainerBuilder;
+use Drupal\Core\DependencyInjection\ServiceProviderBase;
+use Symfony\Component\DependencyInjection\Definition;
+use Symfony\Component\DependencyInjection\Reference;
+
+/**
+ * Service Provider for Paragraphs.
+ */
+class ParagraphsServiceProvider extends ServiceProviderBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function alter(ContainerBuilder $container) {
+    $modules = $container->getParameter('container.modules');
+    // Check for installed Replicate module.
+    if (isset($modules['replicate']) ) {
+      // Add a Replicate field event subscriber.
+      $service_definition = new Definition(
+        'Drupal\paragraphs\EventSubscriber\ReplicateFieldSubscriber',
+        [new Reference('replicate.replicator')]
+      );
+      $service_definition->addTag('event_subscriber');
+      $container->setDefinition('replicate.event_subscriber.paragraphs', $service_definition);
+    }
+  }
+}