Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / consolidation / robo / src / Task / Composer / Config.php
1 <?php
2 namespace Robo\Task\Composer;
3
4 /**
5  * Composer Config
6  *
7  * ``` php
8  * <?php
9  * // simple execution
10  * $this->taskComposerConfig()->set('bin-dir', 'bin/')->run();
11  * ?>
12  * ```
13  */
14 class Config extends Base
15 {
16     /**
17      * {@inheritdoc}
18      */
19     protected $action = 'config';
20
21     /**
22      * Set a configuration value
23      * @return $this
24      */
25     public function set($key, $value)
26     {
27         $this->arg($key);
28         $this->arg($value);
29         return $this;
30     }
31
32     /**
33      * Operate on the global repository
34      * @return $this
35      */
36     public function useGlobal($useGlobal = true)
37     {
38         if ($useGlobal) {
39             $this->option('global');
40         }
41         return $this;
42     }
43
44     /**
45      * @return $this
46      */
47     public function repository($id, $uri, $repoType = 'vcs')
48     {
49         $this->arg("repositories.$id");
50         $this->arg($repoType);
51         $this->arg($uri);
52         return $this;
53     }
54
55     /**
56      * @return $this
57      */
58     public function removeRepository($id)
59     {
60         $this->option('unset', "repositories.$id");
61         return $this;
62     }
63
64     /**
65      * @return $this
66      */
67     public function disableRepository($id)
68     {
69         $this->arg("repositories.$id");
70         $this->arg('false');
71         return $this;
72     }
73
74     /**
75      * @return $this
76      */
77     public function enableRepository($id)
78     {
79         $this->arg("repositories.$id");
80         $this->arg('true');
81         return $this;
82     }
83
84     /**
85      * {@inheritdoc}
86      */
87     public function run()
88     {
89         $command = $this->getCommand();
90         $this->printTaskInfo('Configuring composer.json: {command}', ['command' => $command]);
91         return $this->executeCommand($command);
92     }
93 }