More updates to stop using dev or alpha or beta versions.
[yaffs-website] / vendor / consolidation / robo / src / Task / BaseTask.php
1 <?php
2 namespace Robo\Task;
3
4 use Robo\Common\InflectionTrait;
5 use Robo\Contract\InflectionInterface;
6
7 use Robo\Common\TaskIO;
8 use Robo\Contract\TaskInterface;
9 use Robo\Contract\ProgressIndicatorAwareInterface;
10 use Robo\Contract\VerbosityThresholdInterface;
11 use Robo\Common\ProgressIndicatorAwareTrait;
12 use Robo\Contract\ConfigAwareInterface;
13 use Psr\Log\LoggerAwareInterface;
14 use Robo\Contract\OutputAwareInterface;
15
16 abstract class BaseTask implements TaskInterface, LoggerAwareInterface, VerbosityThresholdInterface, ConfigAwareInterface, ProgressIndicatorAwareInterface, InflectionInterface
17 {
18     use TaskIO; // uses LoggerAwareTrait, VerbosityThresholdTrait and ConfigAwareTrait
19     use ProgressIndicatorAwareTrait;
20     use InflectionTrait;
21
22     /**
23      * ConfigAwareInterface uses this to decide where configuration
24      * items come from. Default is this prefix + class name + key,
25      * e.g. `task.Remote.Ssh.remoteDir`.
26      */
27     protected static function configPrefix()
28     {
29         return 'task.';
30     }
31
32     /**
33      * ConfigAwareInterface uses this to decide where configuration
34      * items come from. Default is this prefix + class name + key,
35      * e.g. `task.Ssh.remoteDir`.
36      */
37     protected static function configPostfix()
38     {
39         return '.settings';
40     }
41
42     /**
43      * {@inheritdoc}
44      */
45     public function injectDependencies(InflectionInterface $child)
46     {
47         if ($child instanceof LoggerAwareInterface && $this->logger) {
48             $child->setLogger($this->logger);
49         }
50         if ($child instanceof ProgressIndicatorAwareInterface && $this->progressIndicator) {
51             $child->setProgressIndicator($this->progressIndicator);
52         }
53         if ($child instanceof ConfigAwareInterface && $this->getConfig()) {
54             $child->setConfig($this->getConfig());
55         }
56         if ($child instanceof VerbosityThresholdInterface && $this->outputAdapter()) {
57             $child->setOutputAdapter($this->outputAdapter());
58         }
59     }
60 }