Skip to content
This repository
Browse code

remove obsolete controller and init file, refs #3989

  • Loading branch information...
commit f99c8dbbe0f3f276c62dfab402c19d3c65a420a0 1 parent 2591882
Jeremy Bush zombor authored

Showing 2 changed files with 0 additions and 146 deletions. Show diff stats Hide diff stats

  1. +0 139 classes/Controller/Minion.php
  2. +0 7 init.php
139 classes/Controller/Minion.php
... ... @@ -1,139 +0,0 @@
1   -<?php defined('SYSPATH') or die('No direct script access.');
2   -
3   -/**
4   - * Controller for interacting with minion on the cli
5   - *
6   - * @author Matt Button <matthew@sigswitch.com>
7   - */
8   -class Controller_Minion extends Kohana_Controller
9   -{
10   - /**
11   - * The task to be executed
12   - * @var string
13   - */
14   - protected $_task = NULL;
15   -
16   - /**
17   - * Prevent Minion from being run over http
18   - */
19   - public function before()
20   - {
21   - $this->_task = $this->request->param('task');
22   -
23   - $options = CLI::options('help', 'task');
24   -
25   - if (array_key_exists('help', $options))
26   - {
27   - $this->request->action('help');
28   - }
29   -
30   - if ( ! empty($options['task']))
31   - {
32   - $this->_task = $options['task'];
33   - }
34   -
35   - return parent::before();
36   - }
37   -
38   - /**
39   - * Retrieves the current minion task.
40   - *
41   - * @return Minion_Task
42   - */
43   - protected function _retrieve_task()
44   - {
45   - try
46   - {
47   - return Minion_Task::factory($this->_task);
48   - }
49   - catch(Exception $e)
50   - {
51   - echo View::factory('minion/help/error')
52   - ->set('error', 'Task "'.$this->_task.'" does not exist');
53   -
54   - exit(1);
55   - }
56   - }
57   -
58   - /**
59   - * Prints out the help for a specific task
60   - *
61   - */
62   - public function action_help()
63   - {
64   - $tasks = Minion_Util::compile_task_list(Kohana::list_files('classes/task'));
65   - $view = NULL;
66   -
67   - if (empty($this->_task))
68   - {
69   - $view = new View('minion/help/list');
70   -
71   - $view->tasks = $tasks;
72   - }
73   - else
74   - {
75   - $inspector = new ReflectionClass($this->_retrieve_task());
76   -
77   - list($description, $tags) = Minion_Util::parse_doccomment($inspector->getDocComment());
78   -
79   - $view = View::factory('minion/help/task')
80   - ->set('description', $description)
81   - ->set('tags', (array) $tags)
82   - ->set('task', $this->_task);
83   - }
84   -
85   - echo $view;
86   - }
87   -
88   - /**
89   - * Handles the request to execute a task.
90   - *
91   - * Responsible for parsing the tasks to execute & also any config items that
92   - * should be passed to the tasks
93   - */
94   - public function action_execute()
95   - {
96   - if (empty($this->_task))
97   - {
98   - return $this->action_help();
99   - }
100   -
101   - $task = $this->_retrieve_task();
102   -
103   - $defaults = $task->get_config_options();
104   -
105   - if ( ! empty($defaults))
106   - {
107   - if (Arr::is_assoc($defaults))
108   - {
109   - $options = array_keys($defaults);
110   - $options = call_user_func_array(array('CLI', 'options'), $options);
111   - $config = Arr::merge($defaults, $options);
112   - }
113   - else
114   - {
115   - // Old behavior
116   - $config = call_user_func_array(array('CLI', 'options'), $defaults);
117   - }
118   - }
119   - else
120   - {
121   - $config = array();
122   - }
123   -
124   - // Validate $config
125   - $validation = Validation::factory($config);
126   - $validation = $task->build_validation($validation);
127   -
128   - if ( ! $validation->check())
129   - {
130   - echo View::factory('minion/error/validation')
131   - ->set('errors', $validation->errors($task->get_errors_file()));
132   - }
133   - else
134   - {
135   - // Finally, run the task
136   - echo $task->execute($config);
137   - }
138   - }
139   -}
7 init.php
... ... @@ -1,7 +0,0 @@
1   -<?php
2   -
3   -Route::set('minion', 'minion(/<action>)(/<task>)', array('action' => 'help'))
4   - ->defaults(array(
5   - 'controller' => 'Minion',
6   - 'action' => 'execute',
7   - ));

0 comments on commit f99c8db

Please sign in to comment.
Something went wrong with that request. Please try again.