Creates and stores a new attribute value.

@param \Symfony\Component\HttpFoundation\Request $request

@return \Symfony\Component\HttpFoundation\Response
513798
public function postAction(Request $request, $attributeId)
    {
        try {
            $attributeValue = $this->getManager()->save(
                $request->request->all(),
                $this->getLocale($request),
                $attributeId
            );
            $view = $this->view($attributeValue, 200);
        } catch (AttributeDependencyNotFoundException $exc) {
            $exception = new EntityNotFoundException($exc->getEntityName(), $exc->getId());
            $view = $this->view($exception->toArray(), 400);
        } catch (MissingAttributeValueException $exc) {
            $exception = new MissingArgumentException(self::$entityName, $exc->getAttribute());
            $view = $this->view($exception->toArray(), 400);
        }

        return $this->handleView($view);
    }
1308451
public function createSessionAction(Request $request)
    {
        /** @var $sessionInput \eZ\Publish\Core\REST\Server\Values\SessionInput */
        $sessionInput = $this->inputDispatcher->parse(
            new Message(
                array('Content-Type' => $request->headers->get('Content-Type')),
                $request->getContent()
            )
        );
        $request->attributes->set('username', $sessionInput->login);
        $request->attributes->set('password', $sessionInput->password);

        try {
            $session = $request->getSession();
            if ($session->isStarted() && $this->hasStoredCsrfToken()) {
                $this->checkCsrfToken($request);
            }

            $token = $this->authenticator->authenticate($request);
            $csrfToken = $this->getCsrfToken();

            return new Values\UserSession(
                $token->getUser()->getAPIUser(),
                $session->getName(),
                $session->getId(),
                $csrfToken,
                !$token->hasAttribute('isFromSession')
            );
        } catch (Exceptions\UserConflictException $e) {
            // Already logged in with another user, this will be converted to HTTP status 409
            return new Values\Conflict();
        } catch (AuthenticationException $e) {
            $this->authenticator->logout($request);
            throw new UnauthorizedException('Invalid login or password', $request->getPathInfo());
        } catch (AccessDeniedException $e) {
            $this->authenticator->logout($request);
            throw new UnauthorizedException($e->getMessage(), $request->getPathInfo());
        }
    }
323734
public function createAction(Request $request)
    {
        $contentEntityClass = $this->configurationManager->getEntityClass('content');
        $content = new $contentEntityClass;

        $form = $this->createForm(ContentCreateType::class, $content, [
            'action' => $this->generateUrl('sherlockode_acb_content_create'),
        ]);

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $this->om->persist($content);
            $this->om->flush();

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

        return $this->render('@SherlockodeAdvancedContent/Content/create_content.html.twig', [
            'form' => $form->createView(),
            'data' => $content,
        ]);
    }
1036159
public function newUserAction(Request $request)
    {
        $adminContext = $this->get('admin.context');
        $config       = $adminContext->getActiveModuleForAction('add', 'admin-users');

        /** @var AdminUser $user */
        $user = new $config['entity']();
        $user->setIsActive(true);

        $form = $this->createFormBuilder($user, [
            'action' => $this->generateUrl('admin.user.new'),
            'attr'   => ['class' => 'form-horizontal']
        ])
            ->add('login', null, ['attr' => ['data-column' => 'text']])
            ->add('password', RepeatedType::class, [
                'type'            => PasswordType::class,
                'invalid_message' => 'The password fields must match.',
                'options'         => ['attr' => ['data-column' => 'text']],
                'required'        => true,
                'first_options'   => ['label' => 'Password'],
                'second_options'  => ['label' => 'Repeat Password'],
            ])
            ->add('rights', null, ['attr' => ['style' => 'width: 400px;', 'data-column' => 'select']])
            ->getForm();

        $form->handleRequest($request);

        if ($form->isValid()) {
            if ($user->getRights()->count()) {
                /** @var PasswordEncoderInterface $encoder */
                $encoder  = $this->get('security.encoder_factory')->getEncoder($user);
                $password = $encoder->encodePassword($user->getPassword(), $user->getSalt());

                $user
                    ->setPassword($password)
                    ->setIsActive(true);

                $m = $this->get('doctrine')->getManager();

                $m->persist($user);
                $m->flush();

                $this->addFlash('success', 'New user has been added!');

                return $this->redirectToRoute('admin.dictionary.default', ['module' => 'admin-users']);
            } else {
                $form->get('rights')->addError(new FormError('Minimum one right need to be added.'));
            }
        }

        $vars = [
            'object'       => $user,
            'moduleConfig' => $this->get('admin.context')->getActiveModuleForAction('create'),
            'form'         => $form->createView(),
        ];

        return $this->render('@YAdmin/Security/new-user.html.twig', $vars);
    }
612172
public function createAction(Request $request)
    {
        if (!$request->isXmlHttpRequest()) {
            throw new NotFoundHttpException();
        }

        $refFolder = $this->findFolderById($request->attributes->get('id'));
        $repo = $this->getFolderRepository();

        $newFolder = $repo->createNew();
        $newFolder->setName('New folder');

        $mode = strtolower($request->request->get('mode'));
        if (!in_array($mode, array('child', 'after'))) {
            $response = new Response(json_encode(array(
                'error'   => true,
                'message' => 'Unexpected creation mode.',
            ), JSON_FORCE_OBJECT));
        } else {
            if ($mode === 'after') {
                $repo->persistAsNextSiblingOf($newFolder, $refFolder);
            } else {
                $repo->persistAsFirstChildOf($newFolder, $refFolder);
            }

            if (true !== $message = $this->validateFolder($newFolder)) {
                $response = new Response(json_encode(array(
                    'error'   => true,
                    'message' => $message,
                ), JSON_FORCE_OBJECT));
            } else {
                $this->getEntityManager()->flush();
                $data = $this->get('jms_serializer')->serialize(
                    $newFolder,
                    'json',
                    SerializationContext::create()->setGroups(array('Manager'))
                );
                $response = new Response(sprintf('{"node":%s}', $data));
            }
        }

        $response->headers->add(array('Content-Type' => 'application/json'));
        return $response;
    }
175216
public function createAction(Request $request): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('class', 'create'));
        $form = $this->formFactory->createContentTypeGroup(
            new ContentTypeGroupCreateData()
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (ContentTypeGroupCreateData $data) {
                $createStruct = $this->contentTypeService->newContentTypeGroupCreateStruct(
                    $data->getIdentifier()
                );
                $group = $this->contentTypeService->createContentTypeGroup($createStruct);

                $this->notificationHandler->success(
                    $this->translator->trans(
                        /** @Desc("Content type group '%name%' created.") */
                        'content_type_group.create.success',
                        ['%name%' => $data->getIdentifier()],
                        'content_type'
                    )
                );

                return new RedirectResponse($this->generateUrl('ezplatform.content_type_group.view', [
                    'contentTypeGroupId' => $group->id,
                ]));
            });

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

        return $this->render('@ezdesign/admin/content_type_group/create.html.twig', [
            'form' => $form->createView(),
        ]);
    }
445428
public function createAction(Request $request)
    {
        $parentId = $request->get('id');
        $siterootId = $request->get('siteroot_id');
        $elementtypeId = $request->get('element_type_id');
        $afterId = $request->get('prev_id');
        $sortMode = $request->get('sort', 'title');
        $sortDir = $request->get('sort_dir', 'asc');
        $navigation = $request->get('navigation') ? true : false;
        $restricted = $request->get('restricted') ? true : false;
        $masterLanguage = $request->get('masterlanguage');

        $elementService = $this->get('phlexible_element.element_service');
        $treeManager = $this->get('phlexible_tree.tree_manager');

        $tree = $treeManager->getBySiteRootId($siterootId);
        $parentNode = $tree->get($parentId);
        $afterNode = $tree->get($afterId);

        $userId = $this->getUser()->getId();

        $elementSource = $elementService->findElementSource($elementtypeId);

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

        $node = $tree->create(
            $parentNode,
            $afterNode,
            'element-'.$elementSource->getType(),
            $element->getEid(),
            [],
            $this->getUser()->getId(),
            $sortMode,
            $sortDir,
            $navigation,
            $restricted
        );

        return new ResultResponse(
            true,
            'Element EID "'.$element->getEid().' ('.$masterLanguage.')" created.',
            [
                'eid' => $element->getEid(),
                'tid' => $node->getId(),
                'master_language' => $masterLanguage,
                'navigation' => $navigation,
                'restricted' => $restricted,
            ]
        );
    }
318265
public function store(Request $request)
	{
		$attributes = request()->validate(NewsCategory::$rules, NewsCategory::$messages);

        $category = $this->createEntry(NewsCategory::class, $attributes);

        return redirect_to_resource();
	}
1094482
public function newAction(Request $request)
    {
        $visit = new Visit();
        $form = $this->createForm('CoreExtraBundle\Form\VisitType', $visit);
        $form->handleRequest($request);

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

            //if come from popup
            if ($request->isXMLHttpRequest()) {         
                return new JsonResponse(array(
                            'id' => $visit->getId(), 
                        ));
            }
            
            /*********************/
            /********Custom ******/
            /*********************/
            //truncate table email token
//            $connection = $em->getConnection();
//            $statement = $connection->prepare("TRUNCATE TABLE email_token");
//            $statement->execute();
            $email = $visit->getActor()->getEmail();
            $emailToken = new EmailToken();
            $emailToken->setEmail($email);
            $token = sha1(uniqid());
            $emailToken->setToken($token);
            $em->persist($emailToken);
            $visit->setEmailToken($emailToken);
            $em->flush();
            $template   = $this->get('twig')->loadTemplate('CoreExtraBundle:Email:email.template.html.twig');
            $body  = $template->renderBlock('body', array(
                'user_name' => $visit->getActor()->getFullName(),
                'place_name' => 'Place name'
            ));
            $body = preg_replace('/(#TOKEN#)/', $token, $body);  
            
            $this->get('core.mailer')->sendFeedback(array($email), $body, 'Place Name');
            $this->get('session')->getFlashBag()->add('success', 'visit.sent');

            $this->get('session')->getFlashBag()->add('success', 'visit.created');
            
            return $this->redirectToRoute('visit_show', array('id' => $visit->getId()));
        }

        return array(
            'visit' => $visit,
            'form' => $form->createView(),
        );
    }
1035867
public function save(\Illuminate\Http\Request $request)
    {
        $name = $this->getName();
        $value = $request->input($name, '');

        if (! empty($value)) {
            $value = explode(',', $value);
        } else {
            $value = [];
        }

        $request->merge([$name => $value]);

        parent::save($request);
    }
837157
public function createAction(Request $request)
    {
        $this->registerBreadcrubms()->addItem($this->get("translator")->trans("Add"));

        $entity = $this->getNewEntity();
        $form = $this->createCreateForm($entity);

        $form->handleRequest($request);

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

            try {
                if ($form->get("saveAndPublish")->isClicked()) {
                    $entity->setPublished(1);
                }
            } catch (OutOfBoundsException $e) {

            }

            $em->persist($entity);

            $em->flush();

            $this->get('session')->getFlashBag()->add('notice', $this->getEntityName() . ' has been created!');

            if ($form->get("saveAndExit")->isClicked()) {
                return $this->redirect($this->generateUrl($this->getRouteName(), $this->getRouteParams()));
            } else {
                try {
                    if ($form->get("addNext")->isClicked()) {
                        return $this->redirect($this->generateUrl($this->getRouteName() . "Add", $this->getRouteParams()));
                    }
                } catch (OutOfBoundsException $e) {

                }
                return $this->redirect($this->generateUrl($this->getRouteName() . "Edit", $this->getRouteParams(['id' => $entity->getId()])));
            }
        }

        return $this->render($this->getListTemplate() . ":edit.html.twig", [
            'entity' => $entity,
            'form' => $form->createView()
        ]);
    }
857102
public function saveAction(Request $request)
    {
        $id = $request->get('id');
        $ids = $request->get('ids');

        $elementtypeService = $this->get('phlexible_elementtype.elementtype_service');
        $elementtype = $elementtypeService->findElementtype($id);

        $elementtypeService->updateViability($elementtype, $ids);

        return new ResultResponse(true);
    }
1209047
public function store(Request $request)
    {
        $this->validate($request, ['thread_id' => ['required'], 'author_id' => ['required'], 'content' => ['required']]);

        $thread = Thread::find($request->input('thread_id'));
        $this->authorize('reply', $thread);

        $post = $this->model()->create($request->only(['thread_id', 'post_id', 'author_id', 'content']));
        $post->load('thread');

        return $this->response($post, $this->trans('created'), 201);
    }
961028
public function newAction(Request $request)
    {
        $user = $this->getUser();
        $repository = $this->get('ekyna_user.address.repository');

        $address = $repository->createNew();
        $address->setUser($user);

        $cancelPath = $this->generateUrl('ekyna_user_address_list');

        /** @var \Symfony\Component\Form\FormInterface $form */
        $form = $this
            ->createForm('ekyna_user_address', $address, [
                '_redirect_enabled' => true,
            ])
            ->add('actions', 'form_actions', [
                'buttons' => [
                    'save' => [
                        'type' => 'submit', 'options' => [
                            'button_class' => 'primary',
                            'label' => 'ekyna_core.button.save',
                            'attr' => [
                                'icon' => 'ok',
                            ],
                        ],
                    ],
                    'cancel' => [
                        'type' => 'button', 'options' => [
                            'label' => 'ekyna_core.button.cancel',
                            'button_class' => 'default',
                            'as_link' => true,
                            'attr' => [
                                'class' => 'form-cancel-btn',
                                'icon' => 'remove',
                                'href' => $cancelPath,
                            ],
                        ],
                    ],
                ],
            ])
        ;

        $form->handleRequest($request);
        if ($form->isValid()) {
            $event = $this->get('ekyna_user.address.operator')->create($address);
            if (!$event->isPropagationStopped()) {
                $this->addFlash('ekyna_user.address.message.create.success', 'success');
                if (null !== $redirectPath = $form->get('_redirect')->getData()) {
                    return $this->redirect($redirectPath);
                }
                return $this->redirect($cancelPath);
            }
            $this->addFlash('ekyna_user.address.message.create.failure', 'danger');
        }

        return $this->render('EkynaUserBundle:Address:new.html.twig', [
            'form' => $form->createView()
        ]);
    }
1185394
public function createAction(Request $request)
    {
        $class = $this->admin->getEntity();
        $data = new $class();

        return $this->editAction($request, $data);
    }
824365
public function store(Request $request)
	{
		$attributes = request()->validate(Settings::$rules, Settings::$messages);

        $setting = $this->createEntry(Settings::class, $attributes);

        log_activity('Setting Created', 'A Setting was successfully created', $setting);

        return redirect_to_resource();
	}
823912
public function createAction(Request $request)
        {
            $oUser = new User();
            $form = $this->createCreateForm($oUser);
            $form->handleRequest($request);

            if ($form->isValid()) {

                $factory  = $this->get('security.encoder_factory');
                $encoder  = $factory->getEncoder($oUser);
                $password = $encoder->encodePassword($oUser->getPassword(), $oUser->getSalt());
                $oUser->setPassword($password);
                $oUser->save();

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

            return $this->render('SlashworksBackendBundle:User:new.html.twig', array(
                'entity' => $oUser,
                'form'   => $form->createView(),
            ));
        }