Создание объекта.

@param  ItemsServiceContract  $resourceService
@param  SaveItemRequestContract  $request

@return SaveResponseContract

@throws BindingResolutionException
508242
public function store(
        ItemsServiceContract $resourceService,
        SaveItemRequestContract $request
    ): SaveResponseContract {
        return $this->save($resourceService, $request);
    }
1141050
public function getItemOperationAttribute(?string $operationName, string $key, $defaultValue = null, bool $resourceFallback = false)
    {
        return $this->findOperationAttribute($this->itemOperations, $operationName, $key, $defaultValue, $resourceFallback);
    }
799375
public function handle($request)
    {
        $entity = $this->repository()->findById($request->getId());
        $this->authorize($request, $entity);

        foreach ($request->getData() as $raw) {
            $item = $this->getRelatedEntity($raw);
            $this->addRelationItem($entity, $this->field(), $item);
        }

        $this->repository()->getEntityManager()->flush($entity);

        return (
            new RelatedCollectionAction(
                $this->repository(),
                $this->mappedBy(),
                $this->related(),
                $this->transformer()
            )
        )->dispatch($request)->setStatusCode(RestResponse::HTTP_CREATED);
    }
898391
private function save(Request $request, FormInterface $form, CrudConfigurator $crudConfigurator)
    {
        $translator = $this->get('translator');
        $translationDomain = $this->getParameter('symfonyid.admin.translation_domain');

        $form->handleRequest($request);
        if (!$form->isValid()) {
            return $this->handleView(new View(array(
                'status' => false,
                'message' => $translator->trans('message.form_not_valid', array(), $translationDomain),
            )));
        }

        $reflectionModel = new \ReflectionClass($crudConfigurator->getCrud()->getModelClass());
        /** @var \SymfonyId\AdminBundle\Annotation\Driver $driver */
        $driver = $this->get('symfonyid.admin.manager.driver_finder')->findDriverForClass($reflectionModel->getName());
        /** @var \SymfonyId\AdminBundle\Crud\CrudOperationHandler $crudOperationHandler */
        $crudOperationHandler = $this->get('symfonyid.admin.crud.crud_operation_handler');

        $model = $form->getData();
        if (!$crudOperationHandler->save($driver, $model)) {
            return $this->handleView(new View(array(
                'status' => false,
                'message' => $translator->trans($crudOperationHandler->getErrorMessage(), array(), $translationDomain),
            )));
        }

        return $this->createResponse($model);
    }
570409
public function jsonSaveAction(Request $request)
    {
        //@FIXME: This code need to be moved to ContentController somehow.
        $this->save($request);

        $response = new Response(json_encode(['status' => 'ok']));
        $response->headers->set("Content-Type", 'application/json');

        return $response;
    }
1318422
public function edit(
        ItemsServiceContract $resourceService,
        int $id = 0
    ): FormResponseContract {
        $item = $resourceService->getItemById($id);

        return $this->app->make(
            FormResponseContract::class,
            [
                'data' => compact('item'),
            ]
        );
    }
518166
public function saveAction(Request $request)
    {
        $siterootSaver = $this->get('phlexible_siteroot.siteroot_saver');

        $siterootSaver->saveAction($request);

        return new ResultResponse(true, 'Siteroot data saved');
    }
533510
public function store(Request $request)
    {
        // Instantiate a new model item.
        $modelClass = $this->getModelClass();
        $item = new $modelClass;

        // Validate the request.
        $this->validate($request, $item->getValidationRules());

        // Create the new item.
        $itemData = $request->all();
        $item->fill($itemData);
        $item->save();

        $newItem = call_user_func([$this->getModelClass(), 'find'], $item->id)->toArray();
        return $this->generateResponse($this->modelTableName, $newItem);
    }
429011
public function handle($request)
    {
        $entity = $this->repository()->findById($request->getId());

        $this->authorize($request, $entity);

        $resource = new Item($entity, $this->transformer(), $entity->getResourceKey());

        return $this->response()->resource($request, $resource);
    }
722387
public function update_item( $request ) {
		if ( ! empty( $request['post'] ) && in_array( get_post_type( $request['post'] ), array( 'revision', 'attachment' ), true ) ) {
			return new WP_Error( 'rest_invalid_param', __( 'Invalid parent type.' ), array( 'status' => 400 ) );
		}
		$response = parent::update_item( $request );
		if ( is_wp_error( $response ) ) {
			return $response;
		}

		$response = rest_ensure_response( $response );
		$data = $response->get_data();

		if ( isset( $request['alt_text'] ) ) {
			update_post_meta( $data['id'], '_wp_attachment_image_alt', $request['alt_text'] );
		}

		$attachment = $this->get_post( $request['id'] );

		$fields_update = $this->update_additional_fields_for_object( $attachment, $request );
		if ( is_wp_error( $fields_update ) ) {
			return $fields_update;
		}

		$request->set_param( 'context', 'edit' );
		$response = $this->prepare_item_for_response( $attachment, $request );
		$response = rest_ensure_response( $response );

		/* This action is documented in lib/endpoints/class-wp-rest-attachments-controller.php */
		do_action( 'rest_insert_attachment', $data, $request, false );

		return $response;
	}
1064471
public function getSaveRequestMeta(Entity $entity = NULL, $subResource = NULL) {
    $idIsInt = ($type = $this->getIdentifier()->getType()) instanceof IntegerType;
    
    // custom save request
    if ($subResource != NULL) {
      $requestMeta = new RequestMeta(\Psc\Net\HTTP\Request::PUT,
                             $this->constructUrl(array($this->getEntityName(), ($idIsInt ? '%d' : '%s'), $subResource)),
                             array($type)
                            );
      if (isset($entity)) {
        $requestMeta->setInput($entity->getIdentifier());
      }
      
      return $requestMeta;
    
    } else {
      if (!isset($this->saveRequestMeta)) {
        $this->saveRequestMeta = new RequestMeta(\Psc\Net\HTTP\Request::PUT,
                                               $this->constructUrl(array($this->getEntityName(), ($idIsInt ? '%d' : '%s'))),
                                               array($type)
                                              );
      }
      if (isset($entity)) {
        $meta = clone $this->saveRequestMeta;
        return $meta->setInput($entity->getIdentifier());
      }
    
      return $this->saveRequestMeta;
    }
  }
358171
public function updateMenuItemLabelAction(Request $request, MenuItemLabel $menuItemLabel)
    {
        $em = $this->getDoctrine()->getManager();

        if (!$menuItemLabel) {
            throw $this->createNotFoundException('Unable to find MenuItem entity.');
        }

        $editForm = $this->createForm($this->get("amulen.page.form.menuitemlabel"), $menuItemLabel, array(
            'action' => $this->generateUrl('admin_menu_item_label_update', array('id' => $menuItemLabel->getId())),
            'method' => 'PUT',
        ));
        $editForm->add('submit', 'submit', array('label' => 'Update'));
        $editForm->handleRequest($request);

        if ($editForm->isValid()) {

            $em->flush();

            return $this->redirect($this->generateUrl('admin_menu_items', array('id' => $menuItemLabel->getMenuItem()->getMenu()->getId())));
        }

        return array(
            'entity' => $menuItemLabel,
            'form' => $editForm->createView(),
        );
    }
820717
public function saveFields(MetaboxInterface $metabox, Request $request): MetaboxInterface
    {
        $post_id = $request->query('post_id');
        $data = $this->getMetaboxData(collect($request->get('fields')));
        $fields = $metabox->repository()->all();

        /** @var $validator Validator */
        $validator = $this->factory->make(
            $data,
            $this->getMetaboxRules($fields),
            $this->getMetaboxMessages($fields),
            $this->getMetaboxPlaceholders($fields)
        );

        $validatedData = $validator->valid();

        foreach ($fields as $field) {
            /** @var FieldTypeInterface|CanHandleMetabox|BaseType $field */
            $field->setErrorMessageBag($validator->errors());

            if (method_exists($field, 'metaboxSave')) {
                $value = isset($validatedData[$field->getName()]) ? $validatedData[$field->getName()] : null;
                $field->metaboxSave($value, $post_id);
            } else {
                throw new MetaboxException(
                    'Unable to save ['.$field->getName().']. The [metaboxSave] method is missing.'
                );
            }
        }

        return $metabox;
    }
165402
public function relatedPatch(ApiRequest $request, $resourceModel)
    {
        $requestModel = $request->asRequestModel();

        $relationshipModel = $this->getRelationshipModel($resourceModel);

        $this->validate($requestModel, $this->getUpdatingRules());

        return $this->updateRelationshipModel($relationshipModel, $requestModel);
    }
13047
public function store(HCResourceAuthorRequest $request): JsonResponse
    {
        $this->connection->beginTransaction();

        try {
            $resourceAuthor = $this->service->getRepository()->create($request->getRecordData());

            $this->connection->commit();
        } catch (\Throwable $exception) {
            $this->connection->rollBack();

            report($exception);

            return $this->response->error($exception->getMessage());
        }

        event(new HCResourceAuthorCreated($resourceAuthor));

        if ($request->has('hc_new')) {

            $resourceAuthor->label = $resourceAuthor->name;

            return $this->response->success("Created", $resourceAuthor);
        } else {

            return $this->response->success("Created");
        }

    }
576939
public function store(Request $request)
    {
        $this->getFormRequestInstance();

        DB::beginTransaction();
        try {
            $instance = $this->repository->create($request->all());
            $model = $instance[1];
            $number = $model->{$model->getRouteKeyName()};
            $mergedRequest = $this->uploadFiles($request, $model);
            $this->updateOrCreateRelations($mergedRequest, $model);
        } catch (\Exception $e) {
            DB::rollback();

            $message = $this->storeFailedMessage($e->getMessage());
            throw new ResourceControllerException($message);
        }

        DB::commit();

        $message = $this->storeSuccessfulMessage($number);

        if ($request->wantsJson()) {
            $data = [
                $model
            ];

            return $this->validSuccessJsonResponse($message, $data);
        }

        return redirect()->route($this->getRedirectionRoute())
            ->with($this->successFlashMessageKey, $message);
    }
220129
public function update(
        ItemsServiceContract $resourceService,
        SaveItemRequestContract $request,
        int $id = 0
    ): SaveResponseContract {
        return $this->save($resourceService, $request, $id);
    }