Схема
protected bool
hasAction (
string $child, array $args = array() )
Аргументы
Аргумент |
Возможный тип |
Описание |
$child |
string |
— |
$args = array() |
array |
— |
Описание
Позволяет проверить, существует ли контроллер. В переменной $child
передается маршрут к контроллеру.
Пример использования:
// контроллер catalog/controller/account/recurring.php
if(!empty($profile['payment_code']) && $this->hasAction('payment/' . $profile['payment_code'] . '/recurringCancel') == true && $this->config->get($profile['payment_code'] . '_profile_cancel_status')){
$this->data['cancel_link'] = $this->url->link('payment/'.$profile['payment_code'].'/recurringCancel', 'recurring_id='.$this->request->get['recurring_id'], 'SSL');
}else{
$this->data['cancel_link'] = '';
}
Исходный код
$action = new Action($child, $args);
if (file_exists($action->getFile())) {
require_once($action->getFile());
$class = $action->getClass();
$controller = new $class($this->registry);
if(method_exists($controller, $action->getMethod())){
return true;
}else{
return false;
}
} else {
return false;
}