Отправляет созданную страницу пользователю

@param Eresus_CMS_Request $request

@return Eresus_HTTP_Response
12227
public function render(Eresus_CMS_Request $request)
    {
        Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '()');
        return $this->renderUI($request);
    }
1209502
public function toResponse($request)
	{
		return new JsonResponse([
			'data' => $this->transformData($request),
			'meta' => [
				'pagination' => [
					'total' => $this->paginator->total(),
					'per_page' => $this->paginator->perPage(),
					'current_page' => $this->paginator->currentPage(),
					'total_pages' => $this->paginator->lastPage()
				]
			]
		]);
	}
461132
public function fetchAction(Request $request)
    {
        $reference = strtoupper($request->query->get('reference', null));
        $remote = (bool)$request->query->get('remote', 1);

        if (0 < strlen($reference) && $remote) {
            $remoteEndPoints = $this->container->getParameter('ekyna_setting.helper_remotes');
            foreach ($remoteEndPoints as $remoteEndPoint) {
                // remote=0 prevent infinite loop/recursion
                $url = $remoteEndPoint . '?reference=' . $reference . '&remote=0';
                $headers = $request->headers->all();
                if (null !== $response = $this->getRemoteResponse($url, $headers)) {
                    return $response;
                }
            }
        }

        $ttl = 7 * 24 * 3600;
        $response = new Response();
        $response
            ->setPublic()
            ->headers->add(['Content-Type' => 'application/xml; charset=utf-8'])
        ;

        if (0 < strlen($reference)) {
            $repository = $this->getDoctrine()->getRepository('EkynaSettingBundle:Helper');
            if (null !== $helper = $repository->findOneBy(['reference' => $reference])) {
                $response->setLastModified($helper->getUpdatedAt());
                if ($response->isNotModified($request)) {
                    return $response;
                }
                $response->setContent($this->renderView('EkynaSettingBundle:Helper:show.xml.twig', [
                    'helper' => $helper,
                ]));
                return $this->configureSharedCache($response, [$helper->getEntityTag()], $ttl);
            }
        }

        $expires = new \DateTime();
        $expires->modify('+7 days');
        return $response
            ->setMaxAge($ttl)
            ->setExpires($expires)
            ->setContent($this->renderView('EkynaSettingBundle:Helper:show.xml.twig'))
        ;
    }
875365
public function handle(Request $request)
    {
        try {
            $restRequest = new RestRequest($this->config, $request->getMethod(), $request->getUri(), $request->getContent());
            $restResponse = $this->adapter->processRequest($restRequest);
        } catch (\Exception $e) {
            if (true === $this->debugEnabled()) {
                throw $e;
            }
            $restResponse = $this->adapter->handleException($e);
        }
        return new Response($restResponse->getContent(), $restResponse->getStatus(), $restResponse->getHeaders());
    }
1049502
public function handle($request)
    {
        // смотрим метод, к которому пытаются обратиться
        $namespace = $request->server->namespace;
        $method = $request->call->method;

        if (!empty($request->call->endpoint) && !empty($request->call->action)) {
            $namespace = $request->server->namespace . studly_case($request->call->endpoint) . '\\';
            $controllerName = $request->call->action;
        } elseif (!empty($request->call->endpoint)) {
            $controllerName = $request->call->endpoint;
        } else {
            $methodCall = $request->call->method;

            // парсим имя метода
            $methodArray = explode('_', $methodCall);

            // если имя вызываемого метода без разделителя - значит ищем его в базовом классе
            if (\count($methodArray) === 1) {
                $controllerName = $request->server->controller;
                $method = $methodCall;
            } else {
                $controllerName = $methodArray[0];
                unset($methodArray[0]);
                $method = camel_case(implode('_', $methodArray));
            }

        }

        $controllerName = $namespace . studly_case($controllerName . $request->server->postfix);

        // если нет такого контроллера или метода
        if (!class_exists($controllerName)) {
            throw new JsonRpcException(JsonRpcException::CODE_METHOD_NOT_FOUND);
        }

        $controller = app($controllerName);

        if (!\is_callable([$controller, $method])) {
            throw new JsonRpcException(JsonRpcException::CODE_METHOD_NOT_FOUND);
        }

        $request->controller = $controller;
        $request->method = $method;
        $request->params = !empty($request->call->params) ? array_values((array)$request->call->params) : [];

        return true;
    }
430583
public function handle($request)
    {
        $entity = $this->repository()->findById($request->getId());
        $this->authorize($request, $entity);

        $item = $this->getProperty($entity, $this->field());
        $this->related()->getEntityManager()->remove($item);
        $this->setProperty($entity, $this->field(), null);

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

        return $this->response()->noContent();
    }
1352875
public function adminRender(Eresus_CMS_Request $request)
    {
        if (!method_exists($this->getModule(), 'adminRender'))
        {
            throw new LogicException(sprintf(_('Метод "%s" не найден в классе "%s".'),
                'adminRender', get_class($this->getModule())));
        }
        try
        {
            $html = $this->getModule()->adminRender($request);
        }
        catch (Eresus_CMS_Exception_NotFound $e)
        {
            throw $e;
        }
        catch (Exception $e)
        {
            throw new RuntimeException(
                sprintf(_('В модуле %s произошла ошибка: %s'), $this->getModuleName(),
                    $e->getMessage()), 0, $e);
        }
        return $html;
    }
1307970
public function removeAction(Request $request): Response
    {
        $form = $this->formFactory->removeLocation(
            new ContentLocationRemoveData()
        );
        $form->handleRequest($request);

        /** @var \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo */
        $contentInfo = $form->getData()->getContentInfo();

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (ContentLocationRemoveData $data) {
                $contentInfo = $data->getContentInfo();

                foreach ($data->getLocations() as $locationId => $selected) {
                    $location = $this->locationService->loadLocation($locationId);
                    $this->locationService->deleteLocation($location);

                    $this->notificationHandler->success(
                        $this->translator->trans(
                            /** @Desc("Location '%name%' removed.") */
                            'location.delete.success',
                            ['%name%' => $location->getContentInfo()->name],
                            'location'
                        )
                    );
                }

                return new RedirectResponse($this->generateUrl('_ezpublishLocation', [
                    'locationId' => $contentInfo->mainLocationId,
                    '_fragment' => LocationsTab::URI_FRAGMENT,
                ]));
            });

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

        return $this->redirect($this->generateUrl('_ezpublishLocation', [
            'locationId' => $contentInfo->mainLocationId,
            '_fragment' => LocationsTab::URI_FRAGMENT,
        ]));
    }
1245190
public function viewAction(Request $request): Response
    {
        $configuration = $this->requestConfigurationFactory->create($this->metadata, $request);

        $this->isGrantedOr403($configuration, ResourceActions::SHOW);

        /** @var DefinedTranslationInterface|TemplateAwareInterface|ResourceInterface $resource */
        $resource = $this->findOr404($configuration);

        $this->eventDispatcher->dispatch(ResourceActions::SHOW, $configuration, $resource);

        $view = View::create($resource);

        if ($configuration->isHtmlRequest()) {
            $template = $resource->getTemplate();

            if ($template) {
                $tpl = $resource->getTemplateName();
                $options = $template->getOptions();
            } else {
                $tpl = $configuration->getTemplate(ResourceActions::SHOW.'.html');
                $options = [];
            }

            $this->addTranslations($resource);

            $view
                ->setTemplate($tpl)
                ->setTemplateVar($this->metadata->getName())
                ->setData(
                    [
                        'configuration' => $configuration,
                        'metadata' => $this->metadata,
                        'resource' => $resource,
                        'tpl' => ['options' => $options],
                        $this->metadata->getName() => $resource,
                    ]
                );
        }

        return $this->viewHandler->handle($configuration, $view);
    }
800963
private function executeRequest(string $request): Response
    {
        $response = $this->transport->executeRequest($this->config['endpoint_uri'], $request);

        return new Response($response);
    }
88475
public function run(HttpRequest $request = null): Response
    {
        if ($request === null) {
            $request = HttpRequest::fromGlobals();
        }

        $this->httpRequest = $request;

        $context = new Context($request->getUri()->getPath(), $request);

        $response = $this->getHttpRouter()->route($context);

        if (!$response instanceof HttpResponse) {
            $response = new HttpResponse($response);
        }

        $this->flushResponse($request, $response);

        $this->httpRequest = null;

        return $response;
    }
659244
public function indexAction(Request $request)
    {

        /** @var \Networking\InitCmsBundle\Lib\PhpCacheInterface $phpCache */
        $phpCache = $this->get('networking_init_cms.lib.php_cache');

        /** @var PageSnapshotInterface $page */
        $page = $request->get('_content');

        $template = $request->get('_template');
        if ($template instanceof \Sensio\Bundle\FrameworkExtraBundle\Configuration\Template) {
            $template = $template->getTemplate();
        }
        $user = $this->getUser();

        if ($phpCache->isCacheable($request, $user) && $page instanceof PageSnapshotInterface) {
            if (!$this->isSnapshotActive($page)) {
                throw new NotFoundHttpException();
            }

            if ($this->getSnapshotVisibility($page) != PageInterface::VISIBILITY_PUBLIC) {
                if (false === $this->get('security.authorization_checker')->isGranted('ROLE_USER')) {
                    throw new AccessDeniedException();
                }
            }

            $updatedAt = $phpCache->get(sprintf('page_%s_created_at', $page->getId()));
            $cacheKey = $request->getLocale().$request->getPathInfo();

            if ($updatedAt != $page->getSnapshotDate()) {
                $phpCache->delete($cacheKey);
            }

            $response = $phpCache->get($request->getLocale().$request->getPathInfo());

            if (!$response || !$response instanceof Response) {
                $params = $this->getPageParameters($request);

                if ($params instanceof RedirectResponse) {
                    return $params;
                }
                $html = $this->renderView(
                    $template,
                    $params
                );
                $response = new Response($html);

                $phpCache->set($cacheKey, $response);
                $phpCache->set(sprintf('page_%s_created_at', $page->getId()), $page->getSnapshotDate());
            } else {
                $phpCache->touch($cacheKey);
                $phpCache->touch(sprintf('page_%s_created_at', $page->getId()));
            }
        } else {
            $params = $this->getPageParameters($request);

            if ($params instanceof RedirectResponse) {
                return $params;
            }
            $html = $this->renderView(
                $template,
                $params
            );
            $response = new Response($html);
        }

        if ($this->getPageHelper()->isAllowLocaleCookie() && !$this->getPageHelper()->isSingleLanguage()) {
            $response->headers->setCookie(new Cookie('_locale', $request->getLocale()));
        }

        return $response;
    }
654434
public function toResponse($request)
    {
        return tap(response()->json(
            $this->wrap(
                $this->resource->resolve($request),
                array_merge_recursive(
                    $this->paginationInformation($request),
                    $this->resource->with($request),
                    $this->resource->additional
                )
            ),
            $this->calculateStatus()
        ), function ($response) use ($request) {
            $response->original = $this->resource->resource->pluck('resource');

            $this->resource->withResponse($request, $response);
        });
    }
486400
public function getHtml(Eresus_CMS_Request $request, TClientUI $page)
    {
        $tmpl = new Eresus_Template();
        $tmpl->setSource($page->content);
        $html = $tmpl->compile();
        $response = new Eresus_HTTP_Redirect($html);
        return $response;
    }
1110684
public function adminRender(Eresus_CMS_Request $request)
    {
        $this->linkAdminResources();
        $html = parent::adminRender($request);
        return $html;
    }
475050
public function uploadAction(Request $request)
	{
		$postRequest = $request->request;
		$files = $request->files;

		if (!$files->has('file') || !$files->get('file') instanceof UploadedFile || !$files->get('file')->isValid()) {
			$message = 'Error uploading the file';

			throw new CmsException(null, $message);
		}

		$file = $files->get('file');
		/* @var $file UploadedFile */

		$em = $this->container->getDoctrine()->getManager();

		$em->beginTransaction();

		$repository = $em->getRepository(FileAbstraction::CN());
		/* @var $repository FileNestedSetRepository */

		$repository->getNestedSetRepository()->lock();

		// Permission check
		$uploadPermissionCheckFolder = null;

		if ($postRequest->get('folder')) {
			$uploadPermissionCheckFolder = $this->getFolder('folder');
		} else {
			$uploadPermissionCheckFolder = new SlashFolder();
		}

		$this->checkActionPermission($uploadPermissionCheckFolder, FileAbstraction::PERMISSION_UPLOAD_NAME);

		try {
			// getting the folder to upload in
			$folder = null;
			if ($postRequest->get('folder')) {
				$folder = $this->getFolder('folder');
			}

			// Will return the top folder created/found from folderPath string
			$firstSubFolder = null;

			// Create/get folder by path provided
			$folderPath = $postRequest->get('folderPath', '');

			$folderPath = trim(str_replace('\\', '/', $folderPath), '/');

			if ( ! empty($folderPath)) {
				$folderPathParts = explode('/', $folderPath);
				foreach ($folderPathParts as $part) {

					$folderFound = false;
					$children = null;

					if ($folder instanceof Folder) {
						$children = $folder->getChildren();
					} elseif (is_null($folder)) {
						$children = $repository->getRootNodes();
					} else {
						throw new \LogicException("Not supported folder type: " . gettype($folder) . ', class: ' . get_class($folder));
					}

					foreach ($children as $child) {
						if ($child instanceof Folder) {
							$_name = $child->getTitle();
							if (strcasecmp($_name, $part) === 0) {
								$folderFound = $child;
								break;
							}
						}
					}

					if ($folderFound) {
						$folder = $folderFound;
					} else {
						$folder = $this->createFolder($part, $folder);
					}

					if (empty($firstSubFolder)) {
						$firstSubFolder = $folder;
					}
				}
			}

			// checking for replace action
			if ($postRequest->has('file_id')) {
				$fileToReplace = $this->getFile('file_id');
				$this->getFileStorage()->replaceFile($fileToReplace, $file);

				// close transaction and unlock the nested set
				$em->commit();
				$repository->getNestedSetRepository()->unlock();

				return new SupraJsonResponse($this->imageAndFileOutput($fileToReplace));
			}

			$fileEntity = null;

			if ($this->getFileStorage()->isSupportedImageFormat($file->getPathname())) {
				$fileEntity = new Image();
			} else {
				$fileEntity = new File();
			}
			$em->persist($fileEntity);

			$fileEntity->setFileName($file->getClientOriginalName());
			$fileEntity->setSize($file->getSize());
			$fileEntity->setMimeType($file->getMimeType());

			// additional jobs for images
			if ($fileEntity instanceof Image) {
				// store original size
				$imageProcessor = $this->getFileStorage()->getImageResizer();
				$imageInfo = $imageProcessor->getImageInfo($file->getPathname());
				$fileEntity->setWidth($imageInfo->getWidth());
				$fileEntity->setHeight($imageInfo->getHeight());
			}

			if ( ! empty($folder)) {
				// get parent folder private/public status
				$publicStatus = $folder->isPublic();
				$fileEntity->setPublic($publicStatus);

				// Flush before nested set UPDATE
				$em->flush();

				$folder->addChild($fileEntity);
			}

			// when "force" set to true, then we need to ignore duplicate
			// filename exception, so postfix will be added to filename
			if ($fileEntity instanceof File) {
				if ($postRequest->has('force') && $postRequest->filter('force', null, false, FILTER_VALIDATE_BOOLEAN)) {
					try {
						$this->getFileStorage()->validateFileUpload($fileEntity, $file['tmp_name']);
					} catch (DuplicateFileNameException $e) {

						$siblings = $fileEntity->getSiblings();

						$existingNames = array();
						foreach($siblings as $siblingEntity) {
							if ( ! $siblingEntity->equals($fileEntity)) {
								$existingNames[] = $siblingEntity->getFileName();
							}
						}

						$extension = $fileEntity->getExtension();
						$fileNamePart = $fileEntity->getFileNameWithoutExtension();

						$possibleName = null;
						// assume that 1000 iterations is enough, to create unique name
						// if not, well... duplicate file name exception will be thrown
						for ($i = 1; $i < 1000; $i++) {
							$possibleName = sprintf(self::DUPLICATE_NAME_PATTERN, $fileNamePart, $i, $extension);

							if ( ! in_array($possibleName, $existingNames)) {
								$fileEntity->setFileName($possibleName);
								break;
							}
						}
					}
				}
			}

			// when it is not enough available memory to complete Image resize/crop
			// file will be uploaded as simple File entity
			if ($fileEntity instanceof Image) {
				try {
					$this->getFileStorage()->validateFileUpload($fileEntity, $file->getPathname());
				} catch (InsufficientSystemResources $e) {

					// Removing image
					$em->remove($fileEntity);
					$em->flush();

					$fileEntity = new File();

					$em->persist($fileEntity);

					$fileEntity->setFileName($file->getClientOriginalName());
					$fileEntity->setSize($file->getSize());
					$fileEntity->setMimeType($file->getType());

					if ( ! is_null($folder)) {
						$publicStatus = $folder->isPublic();
						$fileEntity->setPublic($publicStatus);

						// Flush before nested set UPDATE
						$em->flush();

						$folder->addChild($fileEntity);
					}

					$message = "Amount of memory required for image [{$file['name']}] resizing exceeds available, it will be uploaded as a document";

					$responseWarning = $message;
				}
			}

			$em->flush();

			// trying to upload file
			$this->getFileStorage()->storeFileData($fileEntity, $file->getPathname());
		} catch (\Exception $e) {

			try {
				// close transaction and unlock the nested set
				$em->flush();
				$em->rollback();
				$repository->getNestedSetRepository()->unlock();
			} catch (\Exception $e) {
				$this->container->getLogger()->error("Failure on rollback/unlock: ".$e->__toString());
			}

			throw new CmsException(null, $e->getMessage(), $e);
		}

		// close transaction and unlock the nested set
		$em->commit();
		$repository->getNestedSetRepository()->unlock();

		// generating output
		$output = $this->imageAndFileOutput($fileEntity);

		if ( ! empty($firstSubFolder)) {
			$firstSubFolderOutput = $this->entityToArray($firstSubFolder);
			$output['folder'] = $firstSubFolderOutput;
		}

		$response = new SupraJsonResponse();

		$response->setData($output);

		if (isset($responseWarning)) {
			$response->setWarningMessage($responseWarning);
		}

		return $response;
	}
342103
public function indexAction(Request $request)
    {
        $manager = $this->get('compo_faq.manager.faq');

        $page = $request->get('page', 1);

        $pager = $manager->getPager([], $page);
        $totalPages = $pager->getPageCount();

        $seoPage = $this->get('sonata.seo.page');
        $seoPage->setContext('faq_list');
        $seoPage->addVar('page', $page);
        $seoPage->addVar('total_pages', $pager->getPageCount());

        if (1 !== $page) {
            $seoPage->setLinkCanonical($manager->getFaqIndexPermalink(['page' => $page], 0));
            $metas = $seoPage->getMetas();
            $metas['name']['robots'] = 'noindex, follow';
            $seoPage->setMetas($metas);
        } else {
            $seoPage->setLinkCanonical($manager->getFaqIndexPermalink([], 0));
        }

        if ($totalPages > 1 && $page < $totalPages) {
            $seoPage->setLinkNext($manager->getFaqIndexPermalink(['page' => $page + 1], 0));
        }

        if ($totalPages > 1 && $page > 1) {
            $seoPage->setLinkPrev($manager->getFaqIndexPermalink(['page' => $page - 1], 0));
        }

        $seoPage->build();

        return $this->render(
            'CompoFaqBundle:Faq:index.html.twig',
            [
                'pager' => $pager,
            ]
        );
    }