1 | <?php |
||
16 | class RunCommand extends AbstractAssetsCommand implements ContainerAwareInterface |
||
17 | { |
||
18 | /** |
||
19 | * Configure the task name. |
||
20 | */ |
||
21 | protected function configure() |
||
38 | |||
39 | /** |
||
40 | * @param InputInterface $input |
||
41 | * @param OutputInterface $output |
||
42 | * |
||
43 | * @return int|null|void |
||
44 | * |
||
45 | * @throws Exception |
||
46 | */ |
||
47 | protected function execute(InputInterface $input, OutputInterface $output) |
||
48 | { |
||
49 | $this->io = new SymfonyStyle($input, $output); |
||
50 | $this |
||
51 | ->io |
||
52 | ->title('Symfony PHP Assets Manager'); |
||
53 | |||
54 | // load configuration from container or given file path |
||
55 | $configuration = $this->loadConfiguration($input); |
||
56 | |||
57 | // get debug mode |
||
58 | $this->debug = $configuration['debug']; |
||
59 | |||
60 | if ($this->debug) { |
||
61 | $this->io->note('Debug Mode...'); |
||
62 | } |
||
63 | |||
64 | // build tasks to run |
||
65 | $tasks = $this->buildTasks($configuration['tasks']); |
||
66 | |||
67 | // build required filters |
||
68 | $filters = $this->buildFilters($configuration['filters']); |
||
69 | |||
70 | // run task with configured filter |
||
71 | $normalizer = new Normalizer($this->container->getParameter('kernel.root_dir').'/../'); |
||
72 | $locator = new Locator($normalizer); |
||
73 | |||
74 | // create the runner |
||
75 | $runner = new TaskRunner( |
||
76 | $filters, |
||
77 | $locator, |
||
78 | $this->debug |
||
79 | ); |
||
80 | $this->io->text('- Running tasks...'); |
||
81 | |||
82 | // run tasks |
||
83 | foreach ($tasks as $task) { |
||
84 | $this->runManagedTask($runner, $task); |
||
85 | } |
||
86 | |||
87 | // display end message |
||
88 | $this->io->success('Assets build end'); |
||
89 | |||
90 | return 0; |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * @param TaskRunner $runner |
||
95 | * @param Task $task |
||
96 | * @throws Exception |
||
97 | */ |
||
98 | protected function runManagedTask(TaskRunner $runner, Task $task) |
||
137 | } |
||
138 |