@@ 66-110 (lines=45) @@ | ||
63 | ||
64 | } |
|
65 | ||
66 | private function processTask($io, $action, $package_name, $package_extra) { |
|
67 | ||
68 | foreach ($package_extra as $name => $task) { |
|
69 | ||
70 | try { |
|
71 | ||
72 | if ( !self::validateTask($task) ) throw new InstallerException('Skipping invalid task in '.$package_name); |
|
73 | ||
74 | $name = $task['name']; |
|
75 | ||
76 | $class = $task['class']; |
|
77 | ||
78 | $description = empty($task['description']) ? null : $task['description']; |
|
79 | ||
80 | switch ($action) { |
|
81 | ||
82 | case 'install': |
|
83 | ||
84 | $this->getPackageInstaller()->tasks()->add($package_name, $name, $class, $description); |
|
85 | ||
86 | $io->write(" <info>+</info> enabled task ".$name); |
|
87 | ||
88 | break; |
|
89 | ||
90 | case 'uninstall': |
|
91 | ||
92 | $id = $this->getPackageInstaller()->tasks()->byName($name)->getId(); |
|
93 | ||
94 | $this->getPackageInstaller()->tasks()->delete($id); |
|
95 | ||
96 | $io->write(" <comment>-</comment> disabled task ".$name." (id ".$id.")"); |
|
97 | ||
98 | break; |
|
99 | ||
100 | } |
|
101 | ||
102 | } catch (Exception $e) { |
|
103 | ||
104 | $io->write('<error>Error processing task: '.$e->getMessage().'</error>'); |
|
105 | ||
106 | } |
|
107 | ||
108 | } |
|
109 | ||
110 | } |
|
111 | ||
112 | private static function validateTask($task) { |
|
113 |
@@ 64-106 (lines=43) @@ | ||
61 | ||
62 | } |
|
63 | ||
64 | private function processTask($io, $action, $package_name, $package_extra) { |
|
65 | ||
66 | foreach ($package_extra as $name => $task) { |
|
67 | ||
68 | try { |
|
69 | ||
70 | if ( !self::validateTask($task) ) throw new InstallerException('Skipping invalid task in '.$package_name); |
|
71 | ||
72 | $class = $task['class']; |
|
73 | ||
74 | $description = empty($task['description']) ? null : $task['description']; |
|
75 | ||
76 | switch ($action) { |
|
77 | ||
78 | case 'install': |
|
79 | ||
80 | $this->getPackageInstaller()->tasks()->add($package_name, $name, $class, $description); |
|
81 | ||
82 | $io->write(" <info>+</info> enabled task ".$name); |
|
83 | ||
84 | break; |
|
85 | ||
86 | case 'uninstall': |
|
87 | ||
88 | $id = $this->getPackageInstaller()->tasks()->getByName($name)->getId(); |
|
89 | ||
90 | $this->getPackageInstaller()->tasks()->delete($id); |
|
91 | ||
92 | $io->write(" <comment>-</comment> disabled task ".$name." (id ".$id.")"); |
|
93 | ||
94 | break; |
|
95 | ||
96 | } |
|
97 | ||
98 | } catch (Exception $e) { |
|
99 | ||
100 | $io->write('<error>Error processing task: '.$e->getMessage().'</error>'); |
|
101 | ||
102 | } |
|
103 | ||
104 | } |
|
105 | ||
106 | } |
|
107 | ||
108 | private static function validateTask($task) { |
|
109 |