-
Notifications
You must be signed in to change notification settings - Fork 2
/
AbstractCommand.php
65 lines (51 loc) · 1.39 KB
/
AbstractCommand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace OmekaCli\Command;
use OmekaCli\Context\Context;
use OmekaCli\Omeka;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\OutputInterface;
abstract class AbstractCommand extends Command
{
protected $omeka;
protected $input;
protected $output;
protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = $output;
}
protected function getInput()
{
return $this->input;
}
protected function getOutput()
{
return $this->output;
}
protected function getStderr()
{
if ($this->output instanceof ConsoleOutputInterface) {
return $this->output->getErrorOutput();
}
return $this->output;
}
protected function getContext()
{
return $this->getHelper('context')->getContext();
}
protected function getSandbox(Context $context = null)
{
return $this->getHelper('context')->getSandbox($context);
}
protected function getOmeka()
{
if (!isset($this->omeka)) {
$omeka = new Omeka();
$omeka->setContext($this->getContext());
$this->omeka = $omeka;
}
return $this->omeka;
}
}