public function fetchAllDependency($actionId) { $dbAdapter = $this->getDbAdapter(); $select = $this->getDbSql()->select(['sa' => \System\Model\Action\DependencyMapper::TABLE_NAME]); $select->where(['sa.actionid' => $actionId]); $query = $this->getDbSql()->buildSqlString($select); $rows = $dbAdapter->query($query, $dbAdapter::QUERY_MODE_EXECUTE); $actionIds = []; if ($rows->count()) { foreach ($rows as $row) { $actionIds[$row['dependencyId']] = $row['dependencyId']; } } $result = []; if (count($actionIds)) { $select = $this->getDbSql()->select(['a' => \System\Model\ActionMapper::TABLE_NAME]); $select->join(['sc' => \System\Model\ControllerMapper::TABLE_NAME], 'a.controllerId = sc.id', ['sc.name' => 'name']); $select->join(['sm' => \System\Model\ModuleMapper::TABLE_NAME], 'sc.moduleId = sm.id', ['sm.name' => 'name']); $select->where(['a.id' => $actionIds]); $query = $this->getDbSql()->buildSqlString($select); $rows = $dbAdapter->query($query, $dbAdapter::QUERY_MODE_EXECUTE); if ($rows->count()) { foreach ($rows as $row) { $action = new \System\Model\Action(); $action->exchangeArray((array) $row); $action->addOption('uri', '/' . $row['sm.name'] . '/' . $row['sc.name'] . '/' . $row['name']); $result[] = $action; } } } return $result; }
public function descriptionAction() { $module = new \System\Model\Module(); $moduleMapper = $this->getServiceLocator()->get('\\System\\Model\\ModuleMapper'); $modules = $moduleMapper->fetchAll($module); $actionMapper = $this->getServiceLocator()->get('\\System\\Model\\ActionMapper'); if ($modules) { foreach ($modules as $module) { if ($this->getServiceLocator()->has($module->getName() . 'Navigation')) { $navi = $this->getServiceLocator()->get($module->getName() . 'Navigation'); /*@var $navi \Zend\Navigation\Navigation */ echo '<b>' . $module->getName() . '</b><br/>'; $iterator = new \RecursiveIteratorIterator($navi, \RecursiveIteratorIterator::SELF_FIRST); foreach ($iterator as $page) { if ($page->resource && $page->privilege) { $action = new \System\Model\Action(); $action->addOption('path', '/' . str_replace(':', '/', $page->resource) . '/' . $page->privilege); if ($actionMapper->getByPath($action)) { if (!$action->getDescription()) { $action->setDescription($page->label); $action->setDisplay(\System\Model\Action::DISPLAY_ACTIVE); $actionMapper->save($action); echo $action->getId() . ' - ' . $action->getDescription() . '<br/>'; } } } } } } } die; }