Lists the medias by folder.

@param Request $request

@return Response
431283
public function listMediaAction(Request $request)
    {
        if (!$request->isXmlHttpRequest()) {
            throw new NotFoundHttpException();
        }

        $folder = $this->findFolderById($request->attributes->get('id'));

        $medias = $this
            ->get('ekyna_media.browser')
            ->setFolder($folder)
            ->findMedias((array)$request->query->get('types'));

        $data = array('medias' => $medias);

        $response = new Response($this->get('jms_serializer')->serialize(
            $data,
            'json',
            SerializationContext::create()->setGroups(array('Manager'))
        ));

        $response->headers->add(array('Content-Type' => 'application/json'));
        return $response;
    }
1041104
public function sort(Request $request)
    {
        collect($request->get('files'))
            ->each(function ($sort, $id) {
                $attachment = Attachment::find($id);
                $attachment->sort = $sort;
                $attachment->save();
            });

        return response(200);
    }
242182
public function indexAction(Request $request)
    {
        $paginator = $this->get('opifer.content.content_manager')
            ->getPaginatedByRequest($request);

        $contents = $paginator->getCurrentPageResults();

        $contents = $this->get('jms_serializer')->serialize(iterator_to_array($contents), 'json', SerializationContext::create()->setGroups(['list'])->enableMaxDepthChecks());

        $data = [
            'results'       => json_decode($contents, true),
            'total_results' => $paginator->getNbResults()
        ];

        return new JsonResponse($data);
    }
1252556
public function mediaAction(Request $request)
    {
        $fileId = $request->get('file_id');
        $fileVersion = $request->get('file_version');
        $templateKey = $request->get('template_key');

        $cacheManager = $this->get('phlexible_media_cache.cache_manager');
        $storageManager = $this->get('phlexible_media_cache.storage_manager');
        $templateManager = $this->get('phlexible_media_template.template_manager');
        $mediaTypeManager = $this->get('phlexible_media_type.media_type_manager');
        $delegateService = $this->get('phlexible_media_cache.image_delegate.service');
        $volumeManager = $this->get('phlexible_media_manager.volume_manager');

        try {
            $cacheItem = $cacheManager->findByTemplateAndFile($templateKey, $fileId, $fileVersion);
        } catch (\Exception $e) {
            $cacheItem = null;
        }

        $template = $templateManager->find($templateKey);

        if ($cacheItem) {
            if ($cacheItem->getCacheStatus() === CacheItem::STATUS_WAITING) {
                $cacheItem = $this->doCache($fileId, $fileVersion, $template, $cacheItem);
            } elseif ($cacheItem->getCacheStatus() === CacheItem::STATUS_MISSING) {
                $cacheItem = $this->doCache($fileId, $fileVersion, $template, $cacheItem);
            }

            if ($cacheItem && $cacheItem->getCacheStatus() === CacheItem::STATUS_OK) {
                $storageKey = $template->getStorage();
                $storage = $storageManager->get($storageKey);
                $filePath = $storage->getLocalPath($cacheItem);

                if (!file_exists($filePath)) {
                    $filePath = null;
                    $cacheItem = $this->doCache($fileId, $fileVersion, $template, $cacheItem);

                    if ($cacheItem && $cacheItem->getCacheStatus() === CacheItem::STATUS_OK) {
                        $storageKey = $template->getStorage();
                        $storage = $storageManager->get($storageKey);
                        $filePath = $storage->getLocalPath($cacheItem);
                    }
                }
            }

            if ($cacheItem) {
                $mimeType = $cacheItem->getMimeType();
            }
        } else {
            $cacheItem = $this->doCache($fileId, $fileVersion, $template);

            if ($cacheItem) {
                if ($cacheItem->getCacheStatus() === CacheItem::STATUS_OK) {
                    $storageKey = $template->getStorage();
                    $storage = $storageManager->get($storageKey);
                    $filePath = $storage->getLocalPath($cacheItem);
                }
                $mimeType = $cacheItem->getMimeType();
            }
        }

        if (empty($filePath)) {
            if (!$template instanceof ImageTemplate) {
                return new Response('Not found', 404);
            }

            $file = $volumeManager->getByFileId($fileId)->findFile($fileId);
            $mediaType = $mediaTypeManager->find(strtolower($file->getMediaType()));
            $filePath = $delegateService->getClean($template, $mediaType, true);
            $mimeType = 'image/gif';
        }

        $response = new BinaryFileResponse($filePath, 200, array('Content-Type' => $mimeType));

        return $response;
    }
303306
public function listAction(Request $request): Response
    {
        $currentPage = $request->query->getInt(self::PAGINATION_PARAM_NAME, 1);

        $contentDraftsDataset = $this->datasetFactory->contentDrafts();
        $contentDraftsDataset->load();

        $pagination = new Pagerfanta(
            new ArrayAdapter($contentDraftsDataset->getContentDrafts())
        );
        $pagination->setMaxPerPage($this->defaultPaginationLimit);
        $pagination->setCurrentPage(min($currentPage, $pagination->getNbPages()));

        $removeContentDraftForm = $this->formFactory->removeContentDraft(
            $this->createContentRemoveData($pagination)
        );

        return $this->render('@ezdesign/admin/content_draft/list.html.twig', [
            'pager' => $pagination,
            'form_remove' => $removeContentDraftForm->createView(),
        ]);
    }
1193222
public function listAction(Request $request)
    {
        return new JsonResponse(
            $this->finder->search(
                'UJM\ExoBundle\Entity\Item\Item',
                $request->query->all(),
                [Transfer::INCLUDE_SOLUTIONS, Transfer::INCLUDE_ADMIN_META]
            )
        );
    }
987930
public function listAction(Request $request)
    {
        $this->denyAccessUnlessGranted(ContributionActionInterface::READ, ContentTypeInterface::ENTITY_TYPE);
        $mapping = array(
            'name' => 'names',
            'content_type_id' => 'contentTypeId',
            'linked_to_site' => 'linkedToSite'
        );
        $configuration = PaginateFinderConfiguration::generateFromRequest($request, $mapping);
        $repository = $this->get('open_orchestra_model.repository.content_type');

        $collection = $repository->findAllNotDeletedInLastVersionForPaginate($configuration);
        $recordsTotal = $repository->countByContentTypeInLastVersion();
        $recordsFiltered = $repository->countNotDeletedInLastVersionWithSearchFilter($configuration);
        $facade = $this->get('open_orchestra_api.transformer_manager')->transform('content_type_collection', $collection);
        $facade->recordsTotal = $recordsTotal;
        $facade->recordsFiltered = $recordsFiltered;

        return $facade;
    }
137539
public function index(Request $request)
	{
		$request = $this->getRequest();

		return $this->response()
			->collection($this->getModel()->search($request->input('q', ''))->limit(100)->get())
			->view($this->getView('index'), [
				'entities' => $this->getModel()->getRepository()->all()->get()
			]);
	}
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'));
    }
52956
public function localPathFoldersAction(Request $request)
    {
        $form = $this->createForm(new ChoiceLocalPath());
        $form->handleRequest($request);
        $path = $form->get('path')->getData() ?: Filesystem::getUserHomeDir();

        if (($root = $request->get('root')) && strpos($path, $root) !== 0) {
            $path = $root;
        }

        /* @var $response JsonResponse */
        $response = $this->getCacheTimeKeeper()
            ->getResponse([(new \DateTime())->setTimestamp(filemtime($path))], -1, new JsonResponse());
        // response was not modified for this request
        if ($response->isNotModified($request)) {
            return $response;
        }

        return $response->setData([
            'path' => $path,
            'folders' => Filesystem::scandir($path, Filesystem::DIRECTORY),
        ]);
    }
1155117
public function metaAction(Request $request)
    {
        $folderId = $request->get('folder_id');

        $folder = $this->get('phlexible_media_manager.volume_manager')->getByFolderId($folderId)->findFolder($folderId);

        $folderMetaSetResolver = $this->get('phlexible_media_manager.folder_meta_set_resolver');
        $folderMetaDataManager = $this->get('phlexible_media_manager.folder_meta_data_manager');
        $optionResolver = $this->get('phlexible_meta_set.option_resolver');

        $meta = [];

        foreach ($folderMetaSetResolver->resolve($folder) as $metaSet) {
            $metaData = $folderMetaDataManager->findByMetaSetAndFolder($metaSet, $folder);

            $fieldDatas = [];

            foreach ($metaSet->getFields() as $field) {
                $options = $optionResolver->resolve($field);

                $fieldData = [
                    'key' => $field->getName(),
                    'type' => $field->getType(),
                    'options' => $options,
                    'readonly' => $field->isReadonly(),
                    'required' => $field->isRequired(),
                    'synchronized' => $field->isSynchronized(),
                ];

                if ($metaData) {
                    foreach ($metaData->getLanguages() as $language) {
                        $fieldData["value_$language"] = $metaData->get($field->getName(), $language);
                    }
                }

                $fieldDatas[] = $fieldData;
            }

            $meta[] = [
                'set_id' => $metaSet->getId(),
                'title' => $metaSet->getName(),
                'fields' => $fieldDatas,
            ];
        }

        return new JsonResponse(['meta' => $meta]);
    }
792820
public function index(Request $request)
    {
        $roles = Role::browse([
            'order'     => [ Input::get('sort', 'id') => Input::get('direction', 'desc') ],
            'limit'     => ($limit = (int)Input::get('limit', 25)),
            'offset'    => (Input::get('page', 1) - 1) * $limit,
            'filters'   => $request->all()
        ]);

        return response()->json(arrayView('phpsoft.users::role/browse', [
            'roles' => $roles,
        ]), 200);
    }
1068499
public function createAction(Request $request)
    {
        $parentId = $request->get('parent_id');
        $name = $request->get('folder_name');

        $volume = $this->get('phlexible_media_manager.volume_manager')->getByFolderId($parentId);
        $parentFolder = $volume->findFolder($parentId);

        try {
            $folder = $volume->createFolder($parentFolder, $name, array(), $this->getUser()->getId());

            return new ResultResponse(true, 'Folder created.', [
                'folder_id' => $folder->getId(),
                'folder_name' => $folder->getName(),
            ]);
        } catch (AlreadyExistsException $e) {
            return new ResultResponse(false, $e->getMessage(), [
                'folder_name' => 'Folder already exists.',
            ]);
        } catch (\Exception $e) {
            return new ResultResponse(false, $e->getMessage());
        }
    }
218633
public function listAction(Request $request)
    {
        $this->checkAccess('LIST', null);
        $resources = $this->getResourceManager()->findAll();
        $view = $this->view($resources, \FOS\RestBundle\Util\Codes::HTTP_OK);
        return $this->handleView($view);
    }
782925
public function listAction(Request $request = null)
    {
        $this->admin->checkAccess('list');

        if ($listMode = $request->get('_list_mode')) {
            $this->admin->setListMode($listMode);
        }

        $datagrid = $this->admin->getDatagrid();
        $datagrid->setValue('context', null, $this->admin->getPersistentParameter('context'));

        $formView = $datagrid->getForm()->createView();

        // set the theme for the current Admin Form
        $this->setFormTheme($formView, $this->admin->getFilterTheme());

        return $this->render($this->admin->getTemplate('list'), [
            'action' => 'list',
            'form' => $formView,
            'datagrid' => $datagrid,
            'csrf_token' => $this->getCsrfToken('sonata.batch'),
        ]);
    }
416921
public function listActionCustom(Request $request = null)
    {
        $this->admin->checkAccess('list');

        $preResponse = $this->preList($request);
        if (null !== $preResponse) {
            return $preResponse;
        }

        if ($listMode = $request->get('_list_mode')) {
            $this->admin->setListMode($listMode);
        }

        $datagrid = $this->admin->getDatagrid();
        $formView = $datagrid->getForm()->createView();

        return $this->renderWithExtraParams($this->admin->getTemplate('list'), [
            'action' => 'list',
            'form' => $formView,
            'batch_action_forms' => $this->getBatchActionFormViews(),

            'datagrid' => $datagrid,
            'csrf_token' => $this->getCsrfToken('sonata.batch'),
            'export_formats' => $this->admin->getExportFormats(),
        ], null);
    }
155948
public function bulkMoveAction(Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        $mediaRepo = $em->getRepository('KunstmaanMediaBundle:Media');
        $form = $this->createForm(BulkMoveMediaType::class);

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            /** @var Folder $folder */
            $folder = $form->getData()['folder'];
            $mediaIds = explode(',', $form->getData()['media']);

            $mediaRepo->createQueryBuilder('m')
                ->update()
                ->set('m.folder', $folder->getId())
                ->where('m.id in (:mediaIds)')
                ->setParameter('mediaIds', $mediaIds)
                ->getQuery()
                ->execute();

            $this->addFlash(FlashTypes::SUCCESS, $this->get('translator')->trans('media.folder.bulk_move.success.text'));

            return new JsonResponse(
                [
                    'Success' => 'The media is moved',
                ]
            );
        }

        return $this->render(
            '@KunstmaanMedia/Folder/bulk-move-modal_form.html.twig',
            [
                'form' => $form->createView(),
            ]
        );
    }