Rework service, change module_method configuration
This commit is contained in:
@@ -31,12 +31,29 @@ class Model_Module_Method extends ORM_OSB {
|
||||
|
||||
protected $status;
|
||||
|
||||
// Temporarily adjust our name
|
||||
// @todo This is temporary until all our method names are colon delimited.
|
||||
protected function _load_values(array $values) {
|
||||
parent::_load_values($values);
|
||||
|
||||
if (substr_count($this->name,'_') == 1 AND ! substr_count($this->name,':'))
|
||||
$this->name = str_replace('_',':',$this->name);
|
||||
elseif (substr_count($this->name,'_') > 1)
|
||||
throw HTTP_Exception::factory(501,'Method :id has double underscore',array(':id'=>$this->id));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function controller_sub() {
|
||||
return substr_count($this->name,'_') ? substr($this->name,($x=strpos($this->name,'_')),strpos($this->name,':')-$x) : '';
|
||||
}
|
||||
|
||||
public function controller() {
|
||||
return Kohana::classname(sprintf('Controller%s_%s',($this->directory() ? '_' : '').$this->directory(),$this->module->name));
|
||||
return Kohana::classname(sprintf('Controller%s_%s',($this->directory() ? '_' : '').$this->directory(),$this->module->name).$this->controller_sub());
|
||||
}
|
||||
|
||||
public function directory() {
|
||||
return substr($this->name,0,strpos($this->name,'_'));
|
||||
return substr($this->name,0,substr_count($this->name,'_') ? strpos($this->name,'_') : strpos($this->name,':'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +68,7 @@ class Model_Module_Method extends ORM_OSB {
|
||||
}
|
||||
|
||||
public function method() {
|
||||
return substr($this->name,strpos($this->name,'_')+1);
|
||||
return substr($this->name,strpos($this->name,':')+1);
|
||||
}
|
||||
|
||||
public function status($status=NULL) {
|
||||
@@ -62,12 +79,12 @@ class Model_Module_Method extends ORM_OSB {
|
||||
}
|
||||
|
||||
public function url() {
|
||||
if (! preg_match('/_/',$this->name))
|
||||
if (! preg_match('/:/',$this->name))
|
||||
return NULL;
|
||||
|
||||
list($type,$action) = preg_split('/_/',$this->name,2);
|
||||
list($type,$action) = preg_split('/:/',$this->name,2);
|
||||
|
||||
return URL::link($type,$this->module->name.'/'.$action);
|
||||
return URL::link($this->directory(),$this->module->name.$this->controller_sub().'/'.$action);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user