public function afterFind($results, $primary = false) { if ($this->findQueryType == 'count') { //return parent::afterFind($results, $primary); } foreach ($results as &$result) { if (empty($result['Module']['id'])) { $result['ModuleRoute'] = array(); continue; } $result['ModuleRoute'] = $this->ModuleRoute->find('all', array('fields' => array('ModuleRoute.*', 'Route.id', 'Route.url', 'Route.name'), 'conditions' => array('ModuleRoute.module_id' => $result['Module']['id']), 'joins' => array(array('table' => 'core_routes', 'alias' => 'Route', 'type' => 'LEFT', 'conditions' => array('ModuleRoute.route_id = Route.id'))))); $result['ModuleRoute'] = Set::extract('/', $result['ModuleRoute']); } return parent::afterFind($results, $primary); }
public function __construct($id = false, $table = null, $ds = null) { parent::__construct($id, $table, $ds); $this->validate = array('name' => array('validName' => array('rule' => '/[a-z0-9_]{1,50}/', 'message' => __('Please enter a valid name, lowercase letters, numbers and underscores only')), 'isUnique' => array('rule' => 'isUnique', 'message' => __('There is already a position with that name')))); }