Load JS or CSS assets.

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

@return \Symfony\Component\HttpFoundation\Response
502499
public function combineLoaderAction(Request $request)
    {
        $files = array_keys($request->query->all());

        $version = $this->get('assets.packages')->getVersion('/');

        try {
            $type = $this->loader->getCombinedFilesContentType($files, $version);
            $content = $this->loader->combineFilesContent($files, $version);
        } catch (NotFoundException $e) {
            throw new NotFoundHttpException($e->getMessage());
        } catch (InvalidArgumentValue $e) {
            throw new BadRequestHttpException($e->getMessage());
        }

        $headers = ['Content-Type' => $type];
        if ($this->comboCacheTtl && $version != '') {
            $headers['Cache-Control'] = "public, s-maxage=$this->comboCacheTtl";
        }

        return new Response(
            $content,
            Response::HTTP_OK,
            $headers
        );
    }
1169006
public function render($request)
    {
        $contents = [
            'error' => 'access_denied',
            'message' => $this->message,
        ];

        if ($this->hint) {
            $contents['hint'] = $this->hint;
        }

        // Return a properly formatted error according
        // to RFC 6749, Section 5.2. <goo.gl/EeUqjz>
        return new JsonResponse($contents, 401, [
            'WWW-Authenticate' => 'Bearer realm="OAuth"',
        ]);
    }
911720
public function createThemeAction(Request $request)
    {
        $form = $this->formFactory->create(new ThemeType());
        $form->handleRequest($request);

        if ($form->isValid()) {
            $this->manager->createCustomTheme(
                $form['name']->getData(),
                $form['stylesheet']->getData()
            );

            return new RedirectResponse($this->router->generate('claro_admin_theme_list'));
        }

        return ['form' => $form];
    }
1372726
public function load(Request $request)
    {
        $connector = new ElFinderConnector($this->bridge);

        if ($this->config['corsSupport']) {
            return $connector->execute($request->query->all());
        } else {
            $connector->run($request->query->all());
        }
    }
28706
protected function _loadAssets()
    {
        $this->_View->Html->css('System./font-panel/fontpanel.css', ['block' => true]);
        $this->_View->Html->script('System./font-panel/fontpanel.js', ['block' => true]);
        $this->_View->Html->script('System./font-panel/font-panel-init.js', ['block' => true]);
    }
488416
public function search(Request $request)
    {
        $images = $this->imageRepository->search($request->term);

        if($request->ajax()) return response()->json([
            'images' => view('laramanager::browser.images', compact('images'))->render()
        ]);

        return view('laramanager::images.index', compact('images'));
    }
281913
public function run(Request $request) {
		$prefs = $this->getServiceContainer()->getPreferenceLoader()->getSystemPreferences();
		$translator = $this->getServiceContainer()->getTranslator();
		$reg = $this->getServiceContainer()->getExtensionRegistry();
		$settings = $reg->getExtensions(AccountModule::EXT_SETTINGS);
		$section = $this->getParam('section');
		$routes = [];

		// build settings routes
		foreach ($settings as $ext) {
			$routes[$translator->trans($ext['slug'])] = $ext;
		}
			
		if (!isset($routes[$section])) {
			$url = $prefs->getAccountUrl() . $translator->trans('slug.settings');
			throw new ResourceNotFoundException(sprintf('No route found for %s/%s', $url, $section));
		}
			
		$ext = $routes[$section];
		$kernel = $this->getServiceContainer()->getKernel();
		$module = $this->getServiceContainer()->getModuleManager()->load($ext['module']);
		$action = $module->loadAction($ext['action'], 'html');
		$response = $kernel->handle($action, $request);
		
		if ($response instanceof RedirectResponse) {
			return $response;
		}
		
		return $this->responder->run($request, new Blank([
			'settings' => $settings, 
			'section' => $response->getContent()
		]));
	}
133011
public function modalAction(Request $request)
    {
        if (!$request->isXmlHttpRequest()) {
            throw new NotFoundHttpException();
        }

        $config = $this->buildConfig($request);

        $browser = $this->renderView('EkynaMediaBundle:Manager:render.html.twig', array('config' => $config));

        $modal = new Modal();
        $modal->setTitle('ekyna_media.browser.title.' . $config['mode']);
        $modal->setContent($browser);

        if ($config['mode'] == 'multiple_selection') {
            $modal->setButtons(array(
                array(
                    'id'       => 'submit',
                    'label'    => 'ekyna_core.button.validate',
                    'icon'     => 'glyphicon glyphicon-ok',
                    'cssClass' => 'btn-success',
                    'autospin' => true,
                ),
                array(
                    'id'       => 'close',
                    'label'    => 'ekyna_core.button.close',
                    'icon'     => 'glyphicon glyphicon-remove',
                    'cssClass' => 'btn-default',
                ),
            ));
        }

        return $this->get('ekyna_core.modal')->render($modal);
    }
1096477
public function imageAction(Request $request)
    {
        $response = $this->getCacheTimeKeeper()->getResponse();
        // response was not modified for this request
        if ($response->isNotModified($request)) {
            return $response;
        }

        return $this->render('AnimeDbAppBundle:Form:image.html.twig', [
            'form' => $this->createForm(new UploadImage())->createView(),
            'change' => (bool) $request->get('change', false),
        ], $response);
    }
1340999
public function indexAction(Request $request)
    {
        // Special case, not correctly setup yet. Do so now.
        if (!$this->isInstalled()) {
            return new RedirectResponse($request->getUri() . 'install.html');
        }

        return new Response(
            str_replace(
                'var TENSIDEApi=window.location.href.split(\'#\')[0];',
                'var TENSIDEApi=\'' . $request->getSchemeAndHttpHost() . $request->getBaseUrl() . '/\';',
                file_get_contents($this->getAssetsDir() . '/index.html')
            ),
            200,
            [
                'Content-Type' => 'text/html; charset=UTF-8'
            ]
        );
    }
1323651
public function render(Request $request)
    {
        /** @var \Railken\Amethyst\Managers\FileGeneratorManager */
        $manager = $this->manager;

        $dbm = new DataBuilderManager();

        /** @var \Railken\Amethyst\Models\DataBuilder */
        $data_builder = $dbm->getRepository()->findOneById(intval($request->input('data_builder_id')));

        if ($data_builder == null) {
            return $this->error([['message' => 'invalid data_builder_id']]);
        }

        $data = (array) $request->input('data', null);

        $result = $dbm->build($data_builder, $data);

        if (!$result->ok()) {
            return $this->error(['errors' => $result->getSimpleErrors()]);
        }

        $data = array_merge($data, $result->getResource());

        $result = $manager->render(
            $data_builder,
            strval($request->input('filetype')),
            [
                'body'     => strval($request->input('body')),
                'filename' => strval($request->input('filename')),
            ],
            $data
        );

        if (!$result->ok()) {
            return $this->error(['errors' => $result->getSimpleErrors()]);
        }

        $resource = $result->getResource();

        return $this->success(['resource' => [
            'body'     => base64_encode($resource['body']),
            'filename' => base64_encode($resource['filename']),
        ]]);
    }
439596
public function updateVisibilityAction(Request $request): Response
    {
        $form = $this->formFactory->updateVisibilityLocation();
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $data = $form->getData();

            /** @var \eZ\Publish\API\Repository\Values\Content\Location $location */
            $location = $data->getLocation();
            $hidden = $data->getHidden();

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

                if ($hidden) {
                    $this->locationService->hideLocation($location);
                    $message = $this->translator->trans(
                        /** @Desc("Location '%name%' hidden.") */
                        'location.update_success.success.hidden',
                        ['%name%' => $contentInfo->name],
                        'location'
                    );
                } else {
                    $this->locationService->unhideLocation($location);
                    $message = $this->translator->trans(
                        /** @Desc("Location '%name%' unhidden.") */
                        'location.update_success.success.unhidden',
                        ['%name%' => $contentInfo->name],
                        'location'
                    );
                }
            } catch (APIRepositoryUnauthorizedException $e) {
                return new JsonResponse(['errors' => [$e->getMessage()]], Response::HTTP_UNAUTHORIZED);
            }
        } else {
            $errors = [];
            foreach ($form->getErrors(true, true) as $formError) {
                $errors[] = $formError->getMessage();
            }

            return new JsonResponse(['errors' => $errors], Response::HTTP_UNPROCESSABLE_ENTITY);
        }

        return new JsonResponse(['message' => $message]);
    }
780909
public function frameworkImportAction(Request $request)
    {
        $this->checkToolAccess();

        $data = $this->decodeRequest($request);
        $fileData = isset($data['file']) ? $data['file'] : null;
        $this->manager->importFramework($fileData);

        return new JsonResponse();
    }
77885
public function openAction(Request $request)
    {
        if (null === $this->baseDir) {
            throw new NotFoundHttpException('The base dir should be set.');
        }

        if ($this->profiler) {
            $this->profiler->disable();
        }

        $file = $request->query->get('file');
        $line = $request->query->get('line');

        $filename = $this->baseDir.\DIRECTORY_SEPARATOR.$file;

        if (preg_match("'(^|[/\\\\])\.'", $file) || !is_readable($filename)) {
            throw new NotFoundHttpException(sprintf('The file "%s" cannot be opened.', $file));
        }

        return new Response($this->twig->render('@WebProfiler/Profiler/open.html.twig', [
            'filename' => $filename,
            'file' => $file,
            'line' => $line,
         ]), 200, ['Content-Type' => 'text/html']);
    }
887646
public function serveTheme($request)
    {
        $file = $this->getParams()->getThemesPath() . $request;

        if (file_exists($file)) {
            return new RawPage($file);
        }

        throw new NotFoundException;
    }
616714
public function index($request) {
        $application = $request->get('application');
        $path = $request->get('path');

        if (empty($application) || empty($path)) {
            return new Response(
                "Not a valid asset",
                404
            );
        }

        if (strpos('..', $path) === 0) {
            return new Response(
                "Only assets will be served",
                404
            );
        }

        if ($application !== 'Towel') {
            $asset_path = APP_ROOT_DIR . '/Application/' . $application . '/Views/assets/' . $path;
        } else {
            $asset_path = APP_FW_DIR. '/Views/assets/' . $path;
        }

        if (!file_exists($asset_path)) {
            return new Response(
                "Asset does not exists",
                404
            );
        }

        $asset_type = mime_content_type($asset_path);
        $asset_content = file_get_contents($asset_path);
        $asset_info = pathinfo($asset_path);

        if (!empty($asset_info['extension']) && in_array($asset_info['extension'], self::$validExtensions)) {
            $response = new Response(
                $asset_content,
                200,
                ['Content-Type' => self::$extensionTypeMapping[$asset_info['extension']]]
            );

            //To cache in the client side.
            $maxAge = 0;
            if (!empty($this->appConfig['assets']['max-age'])) {
                $maxAge = $this->appConfig['assets']['max-age'];
            }
            $response->headers->addCacheControlDirective('max-age', $maxAge);

            if (!empty($this->appConfig['assets']['public']) && $this->appConfig['assets']['public'] == true) {
                $response->headers->addCacheControlDirective('public', true);
            }

            return $response;
        }

        return new Response(
            "Not a valid extension",
            404
        );
    }
680998
public function resolveRequest(Request $request)
    {
        $format = $request->attributes->get(
            'format',
            $request->attributes->get('_format', 'html')
        );
        
        switch ($format) {
            case 'html':
            case 'page':
                return new DefaultHtmlRenderer();
                break;
            case 'api':
            case 'json':
                return new JsonApiRenderer();
                break;
            default:
                throw new InvalidConfigurationException(sprintf("Unsupported response format %s", $format));
        }
    }