コード例 #1
0
 /**
  * @return void
  */
 public function editExtendAction()
 {
     $form = $this->getLocator()->get('ZlySysmap\\Form\\Extend');
     $params = $this->getRequest()->getMetadata();
     $form->populate($params);
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->post()->toArray())) {
             try {
                 $this->model->saveExtension($form->getValues());
                 return $this->redirect(array())->toRoute('default', array('controller' => 'sysmap-admin', 'action' => 'list'));
             } catch (\Exception $e) {
                 $form->setErrors(array($e->getMessage()));
             }
         }
     } else {
         $hash = $this->getRequest()->getMetadata('hash');
         if (!empty($hash)) {
             $values = $this->model->getNodeByHash($hash);
             if ($values instanceof Model\Mapper\Extend) {
                 $values = $values->toArray();
             }
             if ($values->params instanceof \Zend\Config\Config) {
                 $values->params = $values->params->toArray();
             }
             if (!empty($values)) {
                 $values->sysmap_id = $this->model->getParentByHash($hash)->hash;
                 $form->populate((array) $values);
             }
         }
     }
     return array('editExtensionForm' => $form);
 }
コード例 #2
0
ファイル: Map.php プロジェクト: zendmaniacs/zly-sysmap
 /**
  * Return sysmap element by identifier hash
  * @param string $id
  * @return \Zend\Acl\Resource\GenericResource 
  */
 public function getItemByIdentifier($id)
 {
     $node = $this->model->getNodeByHash($id);
     if (isset($node->_childrens)) {
         unset($node->_childrens);
     }
     return $node;
 }
コード例 #3
0
ファイル: Extend.php プロジェクト: zendmaniacs/zly-sysmap
 protected function _appendParamsSubform($sysmap_id)
 {
     $sysmapItem = $this->model->getNodeByHash($sysmap_id);
     if (empty($sysmapItem->Qualifier)) {
         return false;
     }
     $formClass = trim($sysmapItem->Qualifier);
     if (!empty($formClass)) {
         if (!class_exists($formClass)) {
             throw new \Zend\Form\Exception\UnexpectedValueException('Associated form class does not exists!');
         }
         $paramsForm = new $formClass();
         if (!$paramsForm instanceof \Zend\Form\SubForm) {
             throw new \Zend\Form\Exception\UnexpectedValueException('Associated form class must be instance of \\Zend\\Form\\SubForm!');
         }
         $this->addSubForm($paramsForm, 'params', $this->getElement('submit_extension')->getOrder() - 1);
     }
 }