Version 1
[yaffs-website] / vendor / drupal / console-core / src / Command / Shared / ContainerAwareCommandTrait.php
diff --git a/vendor/drupal/console-core/src/Command/Shared/ContainerAwareCommandTrait.php b/vendor/drupal/console-core/src/Command/Shared/ContainerAwareCommandTrait.php
new file mode 100644 (file)
index 0000000..4945550
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * @file
+ * Contains Drupal\Console\Core\Command\Shared\ContainerAwareCommandTrait.
+ */
+
+namespace Drupal\Console\Core\Command\Shared;
+
+/**
+ * Class CommandTrait
+ * @package Drupal\Console\Core\Command
+ */
+trait ContainerAwareCommandTrait
+{
+    use CommandTrait;
+
+    protected $container;
+
+    /**
+     * @param mixed $container
+     */
+    public function setContainer($container)
+    {
+        $this->container = $container;
+    }
+
+    /**
+     * @param $key
+     * @return null|object
+     */
+    public function has($key)
+    {
+        if (!$key) {
+            return null;
+        }
+
+        return $this->container->has($key);
+    }
+
+    /**
+     * @param $key
+     * @return null|object
+     */
+    public function get($key)
+    {
+        if (!$key) {
+            return null;
+        }
+
+        if ($this->has($key)) {
+            return $this->container->get($key);
+        }
+
+        return null;
+    }
+}