GcDevelopment\Controller\DocumentTypeController::deletePropertyAction PHP Méthode

deletePropertyAction() public méthode

Delete property in session
public deletePropertyAction ( ) : Zend\View\Model\JsonModel
Résultat Zend\View\Model\JsonModel
    public function deletePropertyAction()
    {
        if ($this->getRequest()->isPost()) {
            $id = $this->getRequest()->getPost()->get('property');
            $session = $this->getSession();
            foreach ($session['document-type']['tabs'] as $tabId => $tab) {
                if (empty($tab['properties'])) {
                    continue;
                }
                if (array_key_exists($id, $tab['properties'])) {
                    $documentTypeSession = $session['document-type'];
                    unset($documentTypeSession['tabs'][$tabId]['properties'][$id]);
                    $session->offsetSet('document-type', $documentTypeSession);
                    return $this->returnJson(array('success' => true, 'message' => 'This property has been deleted'));
                }
            }
        }
        return $this->returnJson(array('success' => false, 'message' => 'Error'));
    }