Ejemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function getCode()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCode', array());
     return parent::getCode();
 }
Ejemplo n.º 2
0
 public function stateaddAction()
 {
     $this->_checkIfUserIsLoggedIn();
     $em = $this->getEntityManager();
     $form = new StateForm($em);
     $request = $this->getRequest();
     if ($request->isPost()) {
         $state = new State();
         $form->setInputFilter($state->getInputFilter());
         $data = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
         $form->setData($data);
         if ($form->isValid()) {
             $state->exchangeArray($form->getData());
             $this->getEntityManager()->persist($state);
             $this->getEntityManager()->flush();
             $recentid = $state->stateId;
             $filname = $data['statePhoto']['name'];
             $extension = pathinfo($filname, PATHINFO_EXTENSION);
             $stname = str_replace(" ", "-", $data['stname']) . $recentid . "." . $extension;
             $state->setstatePhoto($stname);
             $adapter = new \Zend\File\Transfer\Adapter\Http();
             $adapter->setDestination('public/images/state');
             $adapter->addFilter('Rename', $stname, $filname);
             if ($adapter->receive($filname)) {
                 $this->getEntityManager()->persist($state);
                 $this->getEntityManager()->flush();
                 return $this->redirect()->toRoute('admin/default', array('controller' => 'geography', 'action' => 'state'));
             }
         }
     }
     return new ViewModel(array('form' => $form, 'scc' => $this->flashMessenger()->getCurrentSuccessMessages(), 'err' => $this->flashMessenger()->getCurrentErrorMessages()));
 }