Completed
Push — master ( 9de0b1...52e441 )
by Robbie
03:50 queued 01:45
created

SilverStripeLoader::getCommandFactory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace SilverLeague\Console\Framework;
4
5
use SilverLeague\Console\Command\Factory;
6
use SilverStripe\Core\ClassInfo;
7
use SilverStripe\Core\Injector\Injector;
8
9
/**
10
 * The class responsible for loading/instantiating SilverStripe and accessing its class hierarchy, etc
11
 *
12
 * @package silverstripe-console
13
 * @author  Robbie Averill <[email protected]>
14
 */
15
class SilverStripeLoader extends ConsoleBase
16
{
17
    /**
18
     * Return a set of Tasks from SilverStripe
19
     *
20
     * @return array
21
     */
22
    public function getTasks()
23
    {
24
        $commands = [];
25
        $tasks = ClassInfo::subclassesFor('SilverStripe\\Dev\\BuildTask');
26
27
        // Remove the BuildTask itself
28
        array_shift($tasks);
29
30
        foreach ($tasks as $taskClass) {
31
            $task = Injector::inst()->get($taskClass);
32
            $commands[] = $this->getCommandFactory()->getCommandFromTask($task);
33
        }
34
35
        return $commands;
36
    }
37
38
    /**
39
     * Get a new command factory instance to generate the console Command
40
     *
41
     * @return Factory
42
     */
43
    public function getCommandFactory()
44
    {
45
        return new Factory($this->getApplication());
46
    }
47
}
48