fromId() публичный статический Метод

Initiliaze module from id
public static fromId ( array $moduleId ) : Model
$moduleId array Module id
Результат Model
Пример #1
0
 /**
  * Uninstall module
  *
  * @return \Zend\View\Model\ViewModel
  */
 public function uninstallAction()
 {
     $moduleId = $this->getRouteMatch()->getParam('id');
     $modules = $this->getServiceLocator()->get('CustomModules');
     $moduleModel = ModuleModel::fromId($moduleId);
     if (!empty($moduleModel)) {
         $module = $modules->getModule($moduleModel->getName());
         if (ModuleModel::uninstall($module, $moduleModel)) {
             return $this->returnJson(array('success' => true, 'message' => 'Module uninstalled'));
         }
     }
     return $this->returnJson(array('success' => false, 'message' => 'Can\'t uninstall module'));
 }
Пример #2
0
 /**
  * Check user acl
  *
  * @param UserModel $userModel User model
  *
  * @return \Zend\Http\Response|null
  */
 protected function checkAcl(UserModel $userModel)
 {
     if (!empty($this->aclPage) and $userModel->getRole()->getName() !== RoleModel::PROTECTED_NAME) {
         $permission = null;
         $acl = $userModel->getAcl(true);
         if ($this->aclPage['resource'] == 'modules') {
             $moduleId = $this->getRouteMatch()->getParam('m');
             if (empty($moduleId)) {
                 $action = $this->getRouteMatch()->getParam('action');
                 $permission = $action === 'index' ? 'list' : $action;
             } else {
                 $moduleModel = ModuleModel::fromId($moduleId);
                 if (!empty($moduleModel)) {
                     $permission = $moduleModel->getName();
                 }
             }
         } else {
             $permission = empty($this->aclPage['permission']) ? null : $this->aclPage['permission'];
             if ($this->aclPage['permission'] != 'index' and !in_array($this->aclPage['resource'], array('content', 'stats'))) {
                 $action = $this->getRouteMatch()->getParam('action');
                 $permission .= (!empty($permission) ? '/' : '') . ($action === 'index' ? 'list' : $action);
             }
         }
         if (!$acl->isAllowed($userModel->getRole()->getName(), $this->aclPage['resource'], $permission)) {
             return $this->redirect()->toRoute('config/user/forbidden');
         }
     }
 }
Пример #3
0
 /**
  * Test
  *
  * @return void
  */
 public function testFromWrongId()
 {
     $this->assertFalse(Model::fromId('undefined'));
 }