@param ActionRequest $request
@param Action        $exportable

@return array
973263
public function handle(ActionRequest $request, Action $exportable): array
    {
        $response = Excel::download(
            $exportable,
            $this->getFilename(),
            $this->getWriterType()
        );

        if (!$response instanceof BinaryFileResponse || $response->isInvalid()) {
            return \is_callable($this->onFailure)
                ? ($this->onFailure)($request, $response)
                : Action::danger(__('Resource could not be exported.'));
        }

        return \is_callable($this->onSuccess)
            ? ($this->onSuccess)($request, $response)
            : Action::download(
                $this->getDownloadUrl($response),
                $this->getFilename()
            );
    }
799731
private function getModelIds(EnvironmentInterface $environment, Action $action, $submitAction)
    {
        $valueKey = \in_array($submitAction, ['edit', 'override']) ? 'properties' : 'models';
        $modelIds = (array) $environment->getInputProvider()->getValue($valueKey);

        if (!empty($modelIds)) {
            $modelIds = \array_map(
                function ($modelId) {
                    return ModelId::fromSerialized($modelId);
                },
                $modelIds
            );

            $event = new PrepareMultipleModelsActionEvent($environment, $action, $modelIds, $submitAction);
            $environment->getEventDispatcher()->dispatch($event::NAME, $event);

            $modelIds = $event->getModelIds();
        }

        return $modelIds;
    }
1335949
public function renderAction(Request $request)
    {
        $data = (array) json_decode($request->getContent(), true);
        $menu = null;

        if (isset($data['data'])) {
            $menu = $this->getMenuFactory()->fromArray($data['data']);
        }

        return [
            'menu'    => $menu,
            'options' => isset($data['options']) ? $data['options'] : [],
        ];
    }
1358381
public function exportAction(Request $request)
    {
        $this->admin->checkAccess('export');

        $format = $request->get('format');

        // NEXT_MAJOR: remove the check
        if (!$this->has('sonata.admin.admin_exporter')) {
            @trigger_error(
                'Not registering the exporter bundle is deprecated since version 3.14.'
                .' You must register it to be able to use the export action in 4.0.',
                E_USER_DEPRECATED
            );
            $allowedExportFormats = (array) $this->admin->getExportFormats();

            $class = (string) $this->admin->getClass();
            $filename = sprintf(
                'export_%s_%s.%s',
                strtolower((string) substr($class, strripos($class, '\\') + 1)),
                date('Y_m_d_H_i_s', strtotime('now')),
                $format
            );
            $exporter = $this->get('sonata.admin.exporter');
        } else {
            $adminExporter = $this->get('sonata.admin.admin_exporter');
            $allowedExportFormats = $adminExporter->getAvailableFormats($this->admin);
            $filename = $adminExporter->getExportFilename($this->admin, $format);
            $exporter = $this->get('sonata.exporter.exporter');
        }

        if (!\in_array($format, $allowedExportFormats, true)) {
            throw new \RuntimeException(
                sprintf(
                    'Export in format `%s` is not allowed for class: `%s`. Allowed formats are: `%s`',
                    $format,
                    $this->admin->getClass(),
                    implode(', ', $allowedExportFormats)
                )
            );
        }

        return $exporter->getResponse(
            $format,
            $filename,
            $this->admin->getDataSourceIterator()
        );
    }
1309221
public function getViewParameters(
        Action $action,
        Request $request,
        FamilyInterface $family,
        FormInterface $form = null,
        $data = null,
        array $listRouteParameters = []
    ): array {
        $listRouteParameters['familyCode'] = $family->getCode();
        $parameters = $this->baseTemplatingHelper->getViewParameters(
            $action,
            $request,
            $form,
            $data,
            $listRouteParameters
        );
        $parameters['family'] = $family;

        return $parameters;
    }
1094058
public function exportAction(Request $request)
    {
        $id = $request->query->get('workspace');
        $file = $this->container->get('claroline.manager.agenda_manager')->export($id);

        $response = new StreamedResponse();

        $response->setCallBack(
          function () use ($file) {
              readfile($file);
          }
        );

        $workspace = $this->om->getRepository(Workspace::class)->find($id);
        $name = $workspace ? $workspace->getName() : 'desktop';
        $response->headers->set('Content-Transfer-Encoding', 'octet-stream');
        $response->headers->set('Content-Type', 'application/force-download');
        $response->headers->set('Content-Disposition', 'attachment; filename='.$name.'.ics');
        $response->headers->set('Content-Type', ' text/calendar');
        $response->headers->set('Connection', 'close');

        return $response;
    }
1136202
protected function getData(Request $request)
    {
        return [
            'style' => $request->get('style'),
            'type' => $request->get('type', $this->container->getParameter('sulu_media.collection.type.default')),
            'parent' => $request->get('parent'),
            'locale' => $this->getRequestParameter($request, 'locale', true),
            'title' => $request->get('title'),
            'description' => $request->get('description'),
            'changer' => $request->get('changer'),
            'creator' => $request->get('creator'),
            'changed' => $request->get('changed'),
            'created' => $request->get('created'),
        ];
    }
243217
public function getExtraParams(Request $request)
    {
        $params = array();
        foreach ($this->widgets as $widget) {
            $params = array_merge($params, $widget->getExtraParams($request));
        }

        return $params;
    }
1270734
public function ajaxAction(Request $request)
    {
        $options = [];
        if ($context = $request->request->get('context')) {
            $options = $this->container->getParameter('troopers_alertify.contexts.'.$context);
        }

        foreach ($request->request->all() as $name => $option) {
            $options[$name] = $option;
        }

        if ($request->get('main_type')) {
            $this->get('session')->getFlashBag()->add($request->get('main_type'), $options);
        }

        return [];
    }
917402
public function exportAction(Request $request, FamilyInterface $family)
    {
        $this->setFamily($family);

        $exportConfig = $this->getExportConfig($request);
        $defaultFormOptions = $this->getDefaultFormOptions($request, 'export');
        $attr = $defaultFormOptions['attr'] ?? [];
        $attr['data-target-element'] = null; // Deep merge hell
        $form = $this->getForm(
            $request,
            $exportConfig,
            [
                'family' => $family,
                'attr' => $attr,
            ]
        );

        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            return $this->generateExport($form->getData());
        }

        return $this->renderAction($this->getViewParameters($request, $form));
    }
853443
public function addExportAction()
    {
        $options = array(
            'class'  => 'model-export',
            'target' => null,
            'title'  => $this->_('Export the current data set'),
        );

        return $this->addActionButton($this->_('Export'), $this->get('privilege') . '.export', 'export', $options);
    }
991113
public function getExport()
    {
        $form = FormBuilder::create($this->export_form, [
            'model' => $this->model
        ]);

        $form_content = view('expendable::admin.form.components.formgenerator.export', [
            'form' => $form
        ]);
        $content      = view('expendable::admin.form.state.form', [

        ]);

        $this->layoutManager->add([
            'form'=>$form_content,
            'content'=>$content,
        ]);

        return $this->layoutManager->render();
    }
184060
public function isExportFileAction($resource, $action)
    {
        return isset($this->exportFileActions[$resource]) && in_array($action, $this->exportFileActions[$resource]);
    }
1265195
public function getViewParameters(
        Action $action,
        Request $request,
        FormInterface $form = null,
        $data = null,
        array $listRouteParameters = []
    ): array {
        $baseParameters = $this->baseTemplatingHelper->getViewParameters($action, $form, $data, $listRouteParameters);
        $parameters = [
            'isAjax' => $request->isXmlHttpRequest(),
            'target' => $request->get('target'),
            'success' => $request->get('success'),
            'isModal' => $request->isXmlHttpRequest() && $request->get('modal'),
        ];

        return array_merge($baseParameters, $parameters);
    }
1269116
private static function cached($actionContext) {
        $httpContext = $actionContext->getHttpContext();
        $request = $httpContext->getRequest();

        // TODO: support POST
        if ($request->isPost()) {
            return false;
        }

        $cacheSettings = InternalHelper::getStaticPropertyValue('\\PhpMvc\\OutputCache', 'settings');
        $actionName = $actionContext->getActionName();

        if (!isset($cacheSettings[$actionName])) {
            $cacheSettings[$actionName] = array();
        }

        if (!isset($cacheSettings['.'])) {
            $cacheSettings['.'] = array();
        }

        if (empty($cacheSettings[$actionName]) && empty($cacheSettings['.'])) {
            return false;
        }

        // location
        if (!empty($cacheSettings[$actionName]['location'])) {
            $location = intval($cacheSettings[$actionName]['location']);
        }
        elseif (!empty($cacheSettings['.']['location'])) {
            $location = intval($cacheSettings['.']['location']);
        }
        else {
            $location = OutputCacheLocation::ANY;
        }

        if (array_search($location, array(OutputCacheLocation::ANY, OutputCacheLocation::SERVER, OutputCacheLocation::SERVER_AND_CLIENT)) === false) {
            return false;
        }

        // vary by parameters
        $params = self::getCacheParams($actionContext, $cacheSettings, 'varyByParam', array_merge($request->get(), $actionContext->getArguments()));

        // vary by headers
        $headers = self::getCacheParams($actionContext, $cacheSettings, 'varyByHeader', $request->headers());

        // vary by custom handlers
        $custom = self::getCacheParams($actionContext, $cacheSettings, 'varyByCustom');

        // check cache
        $response = $httpContext->getResponse();
        $cache = $httpContext->getCache();

        $cacheKey = 'output_' . $request->path() . '_params=' . implode('&', $params) . '_http=' . implode('&', $headers) . '_custom=' . implode('&', $custom);

        if (($cachedResponse = $cache->get($cacheKey)) !== null) {
            $response->setHeaders($cachedResponse['headers']);
            $response->setCookies($cachedResponse['cookies']);
            $response->setStatusCode($cachedResponse['statusCode']);
            $response->setStatusDescription($cachedResponse['statusDescription']);
            $response->writeFile($cachedResponse['files']);
            $response->write($cachedResponse['output']);
            $response->end();
            return true;
        }

        InternalHelper::setPropertyValue($actionContext, 'cacheKey', $cacheKey);

        return false;
    }
68962
public function layoutAction(Request $request)
    {
        $row = $this->findRowByRequest($request);

        $data = $request->request->get('data', []);

        try {
            $this->getEditor()->getLayoutAdapter()->updateRowLayout($row, $data);
        } catch (EditorExceptionInterface $e) {
            return $this->handleException($e);
        }

        $this->validate($row);
        $this->persist($row);

        $data = [
            'rows' => [$this->getViewBuilder()->buildRow($row)],
        ];

        return $this->buildResponse($data, self::SERIALIZE_LAYOUT);
    }
415081
public function getAvailableActions($format)
    {
        $availables = [];

        foreach (array_filter($this->actions, function ($action) use ($format) {
            return $action->supports($format);
        }) as $action) {
            $schema = $action->getAction();
            $availables[$schema[0]][$schema[1]] = $this->explainAction($this->getActionName($action), $format);
        }

        return $availables;
    }