Attaches a new resource.

@param Request $request
@param  int    $contentTypeId

@return \Symfony\Component\HttpFoundation\Response
500839
public function attach(Request $request, $contentTypeId)
    {
        try {
            $this->content->attach($contentTypeId, $request->input('fieldable_id'), $request->only('show_in_table'));
        } catch (Exception $e) {
            return $this->handleException($e, trans('soda::errors.attach', ['object' => trans('soda::terminology.field')]));
        }

        return redirect()->route('soda.content-types.edit', [$contentTypeId, 'tab' => 'fields'])->with('success', trans('soda::messages.attached', ['object' => trans('soda::terminology.field')]));
    }
392286
public function addAttachment(string $file, string $content = null, string $contentType = null): self
	{
		$this->message->addAttachment($file, $content, $contentType);
		return $this;
	}
258629
public function changeRecordListing(Request $request, $contenttype, $contentid)
    {
        // We have to handle three cases here:
        // - $contenttype and $contentid given: get changelog entries for *one* content item
        // - only $contenttype given: get changelog entries for all items of that type
        // - neither given: get all changelog entries

        $page = $request->get('page');
        $pagination = $this->getPagination($page);
        $queryOptions = $this->getQueryOptions($pagination);

        if (empty($contenttype)) {
            // Case 1: No content type given, show from *all* items. This is easy:
            $data = [
                'title'   => Trans::__('logs.change-log.contenttypes.all'),
                'entries' => $this->changeLogRepository()->getChangeLog($queryOptions),
                'count'   => $this->changeLogRepository()->count(),
                'content' => null,
            ];
        } else {
            $contenttype = $this->getContentType($contenttype);
            $data = $this->manager()->getListingData($contenttype, $contentid, $queryOptions);
        }

        $context = [
            'contenttype' => $contenttype,
            'entry'       => null,
            'entries'     => $data['entries'],
            'content'     => $data['content'],
            'title'       => $data['title'],
            'currentpage' => $pagination['page'],
            'pagecount'   => $pagination['limit'] ? ceil($data['count'] / $pagination['limit']) : null,
        ];

        return $this->render('@bolt/changelog/changelog_record_all.twig', $context);
    }
685440
public function setContentType(string $contentType, string $contentCharset = null): self
    {
        $this->contentType = $contentType;

        if ($contentCharset !== null) {
            $this->setContentCharset($contentCharset);
        }

        return $this;
    }
1223519
public function loadContentType($contentTypeId)
    {
        $contentType = $this->contentTypeService->loadContentType($contentTypeId, Language::ALL);

        return new Values\RestContentType(
            $contentType,
            $contentType->getFieldDefinitions()
        );
    }
268716
public function deleteAction(Request $request, ContentTypeGroup $group): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('class', 'delete'));
        $form = $this->formFactory->deleteContentTypeGroup(
            new ContentTypeGroupDeleteData($group)
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (ContentTypeGroupDeleteData $data) {
                $group = $data->getContentTypeGroup();
                $this->contentTypeService->deleteContentTypeGroup($group);

                $this->notificationHandler->success(
                    $this->translator->trans(
                        /** @Desc("Content type group '%name%' deleted.") */
                        'content_type_group.delete.success',
                        ['%name%' => $group->identifier],
                        'content_type'
                    )
                );
            });

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

        return $this->redirect($this->generateUrl('ezplatform.content_type_group.list'));
    }
779302
public function editAction(Request $request, ContentTypePage $page)
    {
        $form = $this->createEditForm($page);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $channel = $this->getSelectedChannel();

            $this->getDocumentManager()->flush();

            $this->get('integrated_page.services.route_cache')->clear();

            $this->get('braincrafted_bootstrap.flash')->success('Page updated');

            return $this->redirectToRoute('integrated_page_content_type_page_index', ['channel' => $channel->getId()]);
        }

        return [
            'page' => $page,
            'form' => $form->createView(),
        ];
    }
1047824
public function listContentTypesForGroup($contentTypeGroupId, Request $request)
    {
        $contentTypes = $this->contentTypeService->loadContentTypes(
            $this->contentTypeService->loadContentTypeGroup($contentTypeGroupId, Language::ALL),
            Language::ALL
        );

        if ($this->getMediaType($request) === 'application/vnd.ez.api.contenttypelist') {
            return new Values\ContentTypeList($contentTypes, $request->getPathInfo());
        }

        return new Values\ContentTypeInfoList($contentTypes, $request->getPathInfo());
    }
1127470
public function initAction(Request $request, $templateType, $contentType, $contentId = null)
    {
        $templateDomain = $this->container->get('synapse.template.domain');

        $template = empty($contentId)
            ? $templateDomain->createGlobal(
                $contentType,
                $templateType
            )
            : $templateDomain->createLocal(
                $this->container->get('synapse.content.resolver')->resolveContentId($contentType, $contentId),
                $templateType
            )
        ;

        return new RedirectResponse(empty($contentId)
            ? $this->container->get('router')->generate('synapse_admin_template_edition', array(
                'id' => $template->getId(),
            ))
            : $request->server->get('HTTP_REFERER')
        );
    }
792161
public function updateContentMetadata($contentId, Request $request)
    {
        $updateStruct = $this->inputDispatcher->parse(
            new Message(
                array('Content-Type' => $request->headers->get('Content-Type')),
                $request->getContent()
            )
        );

        $contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);

        // update section
        if ($updateStruct->sectionId !== null) {
            $section = $this->repository->getSectionService()->loadSection($updateStruct->sectionId);
            $this->repository->getSectionService()->assignSection($contentInfo, $section);
            $updateStruct->sectionId = null;
        }

        // @todo Consider refactoring! ContentService::updateContentMetadata throws the same exception
        // in case the updateStruct is empty and if remoteId already exists. Since REST version of update struct
        // includes section ID in addition to other fields, we cannot throw exception if only sectionId property
        // is set, so we must skip updating content in that case instead of allowing propagation of the exception.
        foreach ($updateStruct as $propertyName => $propertyValue) {
            if ($propertyName !== 'sectionId' && $propertyValue !== null) {
                // update content
                $this->repository->getContentService()->updateContentMetadata($contentInfo, $updateStruct);
                $contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);
                break;
            }
        }

        try {
            $locationInfo = $this->repository->getLocationService()->loadLocation($contentInfo->mainLocationId);
        } catch (NotFoundException $e) {
            $locationInfo = null;
        }

        return new Values\RestContent(
            $contentInfo,
            $locationInfo
        );
    }
478559
public function store(Request $request, $contentId, $blockTypeId)
    {
        try {
            list($content, $blockType, $block) = array_values($this->contentBlocks->save($request, $contentId, $blockTypeId));
        } catch (Exception $e) {
            return $this->handleException($e, trans('soda::errors.create', ['object' => trans('soda::terminology.block')]));
        }

        return redirect()->route('soda.content.edit', [$contentId, 'tab' => $this->getTab($blockType)])->with('success', trans('soda::messages.created', ['object' => trans('soda::terminology.block')]));
    }
875712
public function renderForContentAction($contentId, Request $request)
    {
        return new Response(
            $this->commentsRenderer->renderForContent(
                $this->contentService->loadContentInfo($contentId),
                $request
            )
        );
    }
1151819
public function show(Request $request, $contentId)
    {
        $contentFolder = $this->content->findById($contentId);

        if (! $contentFolder) {
            return $this->handleError(trans('soda::errors.not-found', ['object' => trans('soda::terminology.content')]));
        } elseif (! $contentFolder->is_folder) {
            return redirect()->route('soda.content.edit', $contentFolder->getKey())->withInput();
        }

        $content = $this->content->listFolder($request, $contentFolder);

        if (! $request->has('search')) {
            $contentTypes = $this->content->getCreatableContentTypes($contentFolder->id);
            $shortcuts = $this->content->getShortcuts($contentFolder);
            $isMovable = $content->where('is_movable', true)->count() ? true : false;

            if ($contentFolder->real_depth > 0) {
                $this->buildBreadcrumbTree($contentFolder);
                app('soda.interface')->setHeading($contentFolder->name);
            }
        } else {
            $this->buildBreadcrumbTree($contentFolder, true);
            app('soda.interface')->setHeading('Search');
        }

        return soda_cms_view('data.content.index', compact('contentFolder', 'content', 'contentTypes', 'shortcuts', 'isMovable'));
    }
428511
public function loadContentTypeByIdentifier(Request $request)
    {
        return $this->contentTypeService->loadContentTypeByIdentifier(
            $request->query->get('identifier'),
            Language::ALL
        );
    }
652661
protected function createContentTypeForm(Request $request, $option, ContentTypeInterface $contentType)
    {
        $method = "POST";
        if ("PATCH" === $request->getMethod()) {
            $option["validation_groups"] = false;
            $method = "PATCH";
        }
        $option["method"] = $method;

        return $this->createForm('oo_content_type', $contentType, $option);
    }
935197
public function updateContentTypeDraft($contentTypeId, Request $request)
    {
        $contentTypeDraft = $this->contentTypeService->loadContentTypeDraft($contentTypeId);
        $contentTypeUpdateStruct = $this->inputDispatcher->parse(
            new Message(
                array(
                    'Content-Type' => $request->headers->get('Content-Type'),
                ),
                $request->getContent()
            )
        );

        try {
            $this->contentTypeService->updateContentTypeDraft(
                $contentTypeDraft,
                $contentTypeUpdateStruct
            );
        } catch (InvalidArgumentException $e) {
            throw new ForbiddenException($e->getMessage());
        }

        return new Values\RestContentType(
            // Reload the content type draft to get the updated values
            $this->contentTypeService->loadContentTypeDraft(
                $contentTypeDraft->id
            )
        );
    }
771629
public function attachImagesToWidget(Request $request): AttachImagesToWidgetResponseContract
    {
        $widgetID = (int) $request->get('widgetID');
        $widgetType = $request->get('material_type');

        $this->services['widgets']->attachImagesToWidget($widgetID, $widgetType);

        return app()->makeWith('InetStudio\Widgets\Contracts\Http\Responses\Back\GalleryWidgets\AttachImagesToWidgetResponseContract', [
            'result' => [
                'success' => true,
            ],
        ]);
    }