/** * Tries to replace the parent by the new parent. * * If the logged in user can not perform the operation a new RequestChildEntity object is created. * * @throws \MapasCulturais\Exceptions\PermissionDenied * @throws \MapasCulturais\Exceptions\WorkflowRequestTransport * * @workflow RequestChildEntity */ protected function _saveNested() { if ($this->_newParent !== false) { try { if ($this->_newParent) { $this->_newParent->checkPermission('createChild'); } $this->parent = $this->_newParent; } catch (\MapasCulturais\Exceptions\PermissionDenied $e) { if (!App::i()->isWorkflowEnabled()) { throw $e; } $request = new \MapasCulturais\Entities\RequestChildEntity(); $request->origin = $this; $request->destination = $this->_newParent; $this->_newParent = false; throw new \MapasCulturais\Exceptions\WorkflowRequestTransport($request); } } }