Create and append a new row to the container.

@param Request $request

@return Response
336868
public function createRowAction(Request $request)
    {
        $container = $this->findContainer(intval($request->attributes->get('containerId')));

        $target = is_null($container->getCopy()) ? $container : $container->getCopy();

        try {
            $row = $this->getEditor()->createDefaultRow([], $target);
        } catch (EditorExceptionInterface $e) {
            return $this->handleException($e);
        }

        $this->validate($target);
        $this->persist($target);

        $viewBuilder = $this->getViewBuilder();

        $data = [
            'created'    => $viewBuilder->buildRow($row)->getAttributes()->getId(),
            'containers' => [$viewBuilder->buildContainer($container)],
        ];

        return $this->buildResponse($data, self::SERIALIZE_FULL);
    }
839069
public function store(Request $request)
    {
        $query = $this->getQuery();

        try {
            if ($request->input('query')) {
                $filter = new Filter($this->manager->newEntity()->getTable(), $this->queryable);
                $filter->build($query, $request->input('query'));
            }
        } catch (QuerySyntaxException $e) {
            return $this->error(['code' => 'QUERY_SYNTAX_ERROR', 'message' => 'Syntax error']);
        }

        $params = $request->only($this->fillable);

        DB::beginTransaction();

        $result = new Result();

        $query->chunk(100, function ($resources) use ($params, &$result) {
            foreach ($resources as $resource) {
                $result->addErrors($this->getManager()->update($resource, $params)->getErrors());
            }
        });

        if (!$result->ok()) {
            DB::rollBack();

            return $this->response(['errors' => $result->getSimpleErrors()], Response::HTTP_BAD_REQUEST);
        }

        DB::commit();

        return $this->response(null, Response::HTTP_OK);
    }
68962
public function layoutAction(Request $request)
    {
        $row = $this->findRowByRequest($request);

        $data = $request->request->get('data', []);

        try {
            $this->getEditor()->getLayoutAdapter()->updateRowLayout($row, $data);
        } catch (EditorExceptionInterface $e) {
            return $this->handleException($e);
        }

        $this->validate($row);
        $this->persist($row);

        $data = [
            'rows' => [$this->getViewBuilder()->buildRow($row)],
        ];

        return $this->buildResponse($data, self::SERIALIZE_LAYOUT);
    }
62186
public function addStorageAction(Request $request)
    {
        // app already installed
        if ($this->container->getParameter('anime_db.catalog.installed')) {
            return $this->redirect($this->generateUrl('home'));
        }

        $response = $this->getCacheTimeKeeper()->getResponse('AnimeDbCatalogBundle:Storage');
        // response was not modified for this request
        if ($response->isNotModified($request)) {
            return $response;
        }
        // get last storage
        $storage = $this->getRepository()->getLast();
        if (!$storage) {
            $storage = new Storage();
            $storage->setPath(Filesystem::getUserHomeDir());
        }

        $form = $this->createForm(new StorageForm(), $storage)->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($storage);
            $em->flush();
            // redirect to step 3
            return $this->redirect($this->generateUrl('install_what_you_want'));
        }

        return $this->render('AnimeDbCatalogBundle:Install:add_storage.html.twig', [
            'form' => $form->createView(),
            'is_new' => !$storage->getId(),
            'guide' => $this->get('anime_db.api.client')->getSiteUrl(StorageController::GUIDE_LINK),
        ], $response);
    }
484882
public function dispatch(Request $request)
    {
        $oldRequest = $this->container->setInstance($request);

        ob_start();
        $response = $this->filterRequest($request);
        $response->addContent(ob_get_clean());

        if ($oldRequest) {
            $this->container->setInstance($oldRequest);
        }

        return $response;
    }
1317108
public function createAction(Request $request)
    {
        $treeId = $request->get('tree_id');
        $eid = $request->get('eid');
        $layoutareaId = $request->get('layoutarea_id');
        $elementtypeId = $request->get('element_type_id');
        $prevId = $request->get('prev_id', 0);
        $inherit = $request->get('inherit') === 'on' ? true : false;
        $show = $request->get('shown_here') === 'on' ? true : false;
        $masterLanguage = $request->get('masterlanguage', null);

        if (!$masterLanguage) {
            $masterLanguage = $this->container->getParameter('phlexible_cms.languages.default');
        }

        $elementService = $this->get('phlexible_element.element_service');
        $teaserManager = $this->get('phlexible_teaser.teaser_manager');

        $elementSource = $elementService->findElementSource($elementtypeId);
        $userId = $this->getUser()->getId();

        $element = $elementService->createElement($elementSource, $masterLanguage, $userId);

        $stopIds = array();
        if (!$inherit) {
            $stopIds[] = $treeId;
        }

        $hideIds = array();
        if (!$show) {
            $hideIds[] = $treeId;
        }

        $teaser = $teaserManager->createTeaser(
            $treeId,
            $eid,
            $layoutareaId,
            'element',
            $element->getEid(),
            $prevId,
            $stopIds,
            $hideIds,
            $masterLanguage,
            $userId
        );

        return new ResultResponse(true, "Teaser with ID {$teaser->getId()} created.", ['language' => $masterLanguage]);
    }
1173439
public function uploadAction(Request $request)
    {
        $manager = $this->getDoctrine()->getManager();

        $file = $request->files->get('file');

        $new = new File();
        $new->setFile($file);
        $new->setMimeType($file->getMimeType());
        $new->setName($file->getClientOriginalName());
        $new->setSize($file->getClientSize());
        $new->setOwned(false);

        $manager->persist($new);
        $manager->flush();

        return new Response($new->getId(), 200);
    }
926838
public function addAction(Request $request): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('state', 'administrate'));
        $defaultLanguageCode = reset($this->languages);

        $form = $this->formFactory->createObjectStateGroup(
            new ObjectStateGroupCreateData()
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form,
                function (ObjectStateGroupCreateData $data) use ($defaultLanguageCode) {
                    $createStruct = $this->objectStateService->newObjectStateGroupCreateStruct(
                        $data->getIdentifier()
                    );
                    $createStruct->defaultLanguageCode = $defaultLanguageCode;
                    $createStruct->names = [$defaultLanguageCode => $data->getName()];
                    $group = $this->objectStateService->createObjectStateGroup($createStruct);

                    $this->notificationHandler->success(
                        $this->translator->trans(
                            /** @Desc("Object state group '%name%' created.") */
                            'object_state_group.create.success',
                            ['%name%' => $data->getName()],
                            'object_state'
                        )
                    );

                    return $this->redirectToRoute('ezplatform.object_state.group.view', [
                        'objectStateGroupId' => $group->id,
                    ]);
                });

            if ($result instanceof Response) {
                return $result;
            }
        }

        return $this->render('@ezdesign/admin/object_state_group/add.html.twig', [
            'form' => $form->createView(),
        ]);
    }
916355
public function addAction(Request $request)
    {
        $cm = new CronManager();
        $cron = new Cron();
        $this->addFlashFromCronManager($cm);
        $form = $this->createCronForm($cron);

        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $cm->add($cron);
            $this->addFlashFromCronManager($cm);

            return $this->redirect($this->generateUrl('BCCCronManagerBundle_index'));
        }

        return $this->render('@BCCCronManager:Default:index.html.twig', array(
            'crons' => $cm->get(),
            'raw'   => $cm->getRaw(),
            'form'  => $form->createView(),
        ));
    }
234684
public function addAction(Request $request)
    {
        $resource = $this->mapper->create($this->validateRequestParameters($request));

        return new Response('', 201, array('Location' => $this->mapper->generateReadUrl($resource)));
    }
784719
public function createAction(Request $request)
    {
        $this->denyAccessUnlessGranted('ROLE_ADMIN');

        $locale = new Locale();

        $form = $this->createForm(new LocaleType(), $locale);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($locale);
            $em->flush();

            $this->addFlash('success', 'Locale has been created successfully');

            return $this->redirectToRoute('opifer_cms_locale_edit', ['id' => $locale->getId()]);
        }

        return $this->render('OpiferCmsBundle:Backend/Locale:create.html.twig', [
            'locale' => $locale,
            'form' => $form->createView()
        ]);
    }
276609
public function moveDownAction(Request $request)
    {
        $container = $this->findContainerByRequest($request);

        try {
            $sibling = $this->getEditor()->getContainerManager()->moveDown($container);
        } catch (EditorExceptionInterface $e) {
            return $this->handleException($e);
        }

        $content = $container->getContent();

        $this->validate($content);
        $this->persist($content);

        $data = [
            'containers' => [
                $this->getViewBuilder()->buildContainer($container),
                $this->getViewBuilder()->buildContainer($sibling),
            ],
        ];

        return $this->buildResponse($data, self::SERIALIZE_LAYOUT);
    }
102930
public function createAction(Request $request): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('role', 'create'));
        $form = $this->formFactory->createRole();
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (RoleCreateData $data) {
                $roleCreateStruct = $this->roleCreateMapper->reverseMap($data);
                $roleDraft = $this->roleService->createRole($roleCreateStruct);
                $this->roleService->publishRoleDraft($roleDraft);

                $this->notificationHandler->success(
                    $this->translator->trans(
                        /** @Desc("Role '%role%' created.") */
                        'role.create.success',
                        ['%role%' => $roleDraft->identifier],
                        'role'
                    )
                );

                return new RedirectResponse($this->generateUrl('ezplatform.role.view', [
                    'roleId' => $roleDraft->id,
                ]));
            });

            if ($result instanceof Response) {
                return $result;
            }
        }

        return $this->render('@ezdesign/admin/role/add.html.twig', [
            'form' => $form->createView(),
        ]);
    }
4967
public function newAction(Request $request)
    {
        $page = new Page();
        $form = $this->createForm('CoreBundle\Form\PageType', $page, array('translator'=>$this->get('translator')));
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($page);
            $em->flush($page);

            //if come from popup
            if ($request->isXMLHttpRequest()) {         
                return new JsonResponse(array(
                            'id' => $page->getId(), 
                        ));
            }
            $this->get('session')->getFlashBag()->add('success', 'page.created');
            
            return $this->redirectToRoute('core_page_index');
        }

        return array(
            'page' => $page,
            'form' => $form->createView(),
        );
    }
920854
public function createAction(Request $request)
    {
        $entity = new Tag();
        $form = $this->createCreateForm($entity);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($entity);
            $em->flush();

            $nextAction = $form->get('saveAndAdd')->isClicked()
                ? 'admin_tag_new'
                : 'admin_tag';

            return $this->redirectToRoute($nextAction);
        }

        return array(
            'entity' => $entity,
            'form'   => $form->createView(),
        );
    }
650536
public function postAction(Request $request)
    {
        // Get the response object from container
        $response = $this->getResponse();
        $model = $this->getModel();

        $this->restUtils->checkJsonRequest($request, $response, $this->getModel());

        $record = $this->restUtils->validateRequest($request->getContent(), $model);

        // Insert the new record
        $record = $model->insertRecord($record);

        // store id of new record so we dont need to reparse body later when needed
        $request->attributes->set('id', $record->getId());

        // Set status code
        $response->setStatusCode(Response::HTTP_CREATED);

        $response->headers->set(
            'Location',
            $this->getRouter()->generate($this->restUtils->getRouteName($request), array('id' => $record->getId()))
        );

        return $response;
    }
1068499
public function createAction(Request $request)
    {
        $parentId = $request->get('parent_id');
        $name = $request->get('folder_name');

        $volume = $this->get('phlexible_media_manager.volume_manager')->getByFolderId($parentId);
        $parentFolder = $volume->findFolder($parentId);

        try {
            $folder = $volume->createFolder($parentFolder, $name, array(), $this->getUser()->getId());

            return new ResultResponse(true, 'Folder created.', [
                'folder_id' => $folder->getId(),
                'folder_name' => $folder->getName(),
            ]);
        } catch (AlreadyExistsException $e) {
            return new ResultResponse(false, $e->getMessage(), [
                'folder_name' => 'Folder already exists.',
            ]);
        } catch (\Exception $e) {
            return new ResultResponse(false, $e->getMessage());
        }
    }