Yaffs site version 1.1
[yaffs-website] / vendor / drupal / console-core / src / Command / Shared / ContainerAwareCommandTrait.php
1 <?php
2
3 /**
4  * @file
5  * Contains Drupal\Console\Core\Command\Shared\ContainerAwareCommandTrait.
6  */
7
8 namespace Drupal\Console\Core\Command\Shared;
9
10 /**
11  * Class CommandTrait
12  *
13  * @package Drupal\Console\Core\Command
14  */
15 trait ContainerAwareCommandTrait
16 {
17     use CommandTrait;
18
19     protected $container;
20
21     /**
22      * @param mixed $container
23      */
24     public function setContainer($container)
25     {
26         $this->container = $container;
27     }
28
29     /**
30      * @param $key
31      * @return null|object
32      */
33     public function has($key)
34     {
35         if (!$key) {
36             return null;
37         }
38
39         return $this->container->has($key);
40     }
41
42     /**
43      * @param $key
44      * @return null|object
45      */
46     public function get($key)
47     {
48         if (!$key) {
49             return null;
50         }
51
52         if ($this->has($key)) {
53             return $this->container->get($key);
54         }
55
56         return null;
57     }
58 }