1: <?php
2:
3: App::uses('AppModel', 'Model');
4: App::uses('ClassSearcher', 'Base.Lib');
5:
6: 7: 8: 9:
10: class SchedulingConfigurableShellCall extends AppModel {
11:
12: public $actsAs = array(
13: 'Scheduling.CronValidation',
14: );
15:
16: 17: 18: 19: 20:
21: public $displayField = 'shell';
22:
23: 24: 25: 26: 27:
28: public $validate = array(
29: 'scheduling' => array(
30: 'cronScheduling' => array(
31: 'rule' => array('cronScheduling'),
32: 'allowEmpty' => false,
33: ),
34: ),
35: 'shell' => array(
36: 'shellAvailable' => array(
37: 'rule' => array('shellAvailable'),
38: 'allowEmpty',
39: ),
40: ),
41: );
42:
43: public function shells() {
44: if (!isset($this->_shells)) {
45: $this->_shells = array();
46: foreach (ClassSearcher::findClasses('Console/Command') as $class => $path) {
47: if ($class != 'AppShell') {
48: $this->_shells[] = (($dot = strpos($path, '.')) ?
49: substr($path, 0, $dot) . '.' :
50: '') . preg_replace('/_shell$/', '', Inflector::underscore($class));
51: }
52: }
53: sort($this->_shells);
54: }
55: return $this->_shells;
56: }
57:
58: public function shellAvailable($check) {
59: foreach ($check as $value) {
60: if (!in_array($value, $this->shells())) {
61: return false;
62: }
63: }
64: return true;
65: }
66:
67: }
68: