src/Component/Frontend/StructureModal/StructureModal.php
public function successMain(Form $form) : void
    {
        if ($this->presenter->isAjax() && $this->presenter->user->isAllowed(StructureAuthorizator::RES_STRUCTURE_MODAL))
        {
            $recipeSlug = $this->getRecipeSlug();
            $structure = $this->getStructure();
            $values = $form->getValues();

            $createdAt = new DateTime($values->createdAt);
            $parent = ($values->parent > 0) ? $this->structureRepository->findOneById($values->parent) : NULL;

            $this->structureManager->getConnection()->beginTransaction();

            try
            {
                $structure = $this->structureManager->save(
                    $structure,
                    $recipeSlug,
                    $this->user,
                    $parent,
                    $createdAt
                );

                $diffCategories = $this->structureInCategoryManager->makeDiff($structure, $values->categories);
                $this->structureManager->saveCategories($structure, $diffCategories);

                $this->structureManager->getConnection()->commit();

                $parents = $this->getParentsExceptSubParents();

                $form->getComponent('parent')->setItems($parents);
                $form->getComponent('updatedAt')->setValue($structure->getUpdatedAt()->format(self::FORMAT_DATETIME));

                $this->presenter->notificationAjax(
                    'Nastavení aktualizováno',
                    'Další nastavení bylo aktualizováno.',
                    'success',
                    FALSE
                );

                $this->onSaveMain();
            }
            catch (\Exception $exception)
            {
                $this->structureManager->getConnection()->rollBack();
                throw $exception;
            }
        }
    }
public function successMain(Form $form) : void
    {
        if ($this->presenter->isAjax() && $this->presenter->user->isAllowed(StructureAuthorizator::RES_STRUCTURE_MODAL))
        {
            $recipeSlug = $this->getRecipeSlug();
            $structure = $this->getStructure();
            $values = $form->getValues();

            $createdAt = new DateTime($values->createdAt);
            $parent = ($values->parent > 0) ? $this->structureRepository->findOneById($values->parent) : NULL;

            $this->structureManager->getConnection()->beginTransaction();

            try
            {
                $structure = $this->structureManager->save(
                    $structure,
                    $recipeSlug,
                    $this->user,
                    $parent,
                    $createdAt
                );

                $diffCategories = $this->structureInCategoryManager->makeDiff($structure, $values->categories);
                $this->structureManager->saveCategories($structure, $diffCategories);

                $this->structureManager->getConnection()->commit();

                $parents = $this->getParentsExceptSubParents();

                $form->getComponent('parent')->setItems($parents);
                $form->getComponent('updatedAt')->setValue($structure->getUpdatedAt()->format(self::FORMAT_DATETIME));

                $this->presenter->notificationAjax(
                    'Nastavení aktualizováno',
                    'Další nastavení bylo aktualizováno.',
                    'success',
                    FALSE
                );

                $this->onSaveMain();
            }
            catch (\Exception $exception)
            {
                $this->structureManager->getConnection()->rollBack();
                throw $exception;
            }
        }
    }
public function successMain ( Form $ form ) : void { if ( $ this -> presenter -> isAjax ( ) && $ this -> presenter -> user -> isAllowed ( StructureAuthorizator :: RES_STRUCTURE_MODAL ) ) { $ recipeSlug = $ this -> getRecipeSlug ( ) ; $ structure = $ this -> getStructure ( ) ; $ values = $ form -> getValues ( ) ; $ createdAt = new DateTime ( $ values -> createdAt ) ; $ parent = ( $ values -> parent > 0 ) ? $ this -> structureRepository -> findOneById ( $ values -> parent ) : NULL ; $ this -> structureManager -> getConnection ( ) -> beginTransaction ( ) ; try { $ structure = $ this -> structureManager -> save ( $ structure , $ recipeSlug , $ this -> user , $ parent , $ createdAt ) ; $ diffCategories = $ this -> structureInCategoryManager -> makeDiff ( $ structure , $ values -> categories ) ; $ this -> structureManager -> saveCategories ( $ structure , $ diffCategories ) ; $ this -> structureManager -> getConnection ( ) -> commit ( ) ; $ parents = $ this -> getParentsExceptSubParents ( ) ; $ form -> getComponent ( 'parent' ) -> setItems ( $ parents ) ; $ form -> getComponent ( 'updatedAt' ) -> setValue ( $ structure -> getUpdatedAt ( ) -> format ( self :: FORMAT_DATETIME ) ) ; $ this -> presenter -> notificationAjax ( 'Nastavení aktualizováno', 'Další nastavení bylo aktualizováno.', 'success' , FALSE ) ; $ this -> onSaveMain ( ) ; } catch ( \ Exception $ exception ) { $ this -> structureManager -> getConnection ( ) -> rollBack ( ) ; throw $ exception ; } } }
Success - main form
@param Form $form
@throws \Exception
Success - main form