/**
  * @param Request $request
  *
  * @Config\Route("", name="open_orchestra_api_workflow_functions_list")
  * @Config\Method({"GET"})
  *
  * @return FacadeInterface
  */
 public function listAction(Request $request)
 {
     $repository = $this->get('open_orchestra_model.repository.workflow_function');
     $configuration = PaginateFinderConfiguration::generateFromRequest($request);
     $mapping = $this->get('open_orchestra.annotation_search_reader')->extractMapping($this->container->getParameter('open_orchestra_model.document.workflow_function.class'));
     $configuration->setDescriptionEntity($mapping);
     $workflowFunctionCollection = $repository->findForPaginate($configuration);
     $recordsTotal = $repository->count();
     $recordsFiltered = $repository->countWithFilter($configuration);
     $facade = $this->get('open_orchestra_api.transformer_manager')->get('workflow_function_collection')->transform($workflowFunctionCollection);
     $facade->recordsTotal = $recordsTotal;
     $facade->recordsFiltered = $recordsFiltered;
     return $facade;
 }
 /**
  * @param Request                       $request
  * @param PaginationRepositoryInterface $entityRepository
  * @param array                         $mappingEntity
  * @param TransformerInterface          $transformerManager
  * @param array                         $filter
  *
  * @return \OpenOrchestra\BaseApi\Facade\FacadeInterface
  */
 protected function handleRequestDataTable(Request $request, PaginationRepositoryInterface $entityRepository, $mappingEntity, TransformerInterface $transformerManager, array $prefilter = array())
 {
     if ($entityId = $request->get('entityId')) {
         $element = $entityRepository->find($entityId);
         return $transformerManager->transform(array($element));
     }
     $configuration = PaginateFinderConfiguration::generateFromRequest($request);
     foreach ($prefilter as $key => $value) {
         $configuration->addPrefilterSearch($key, $value);
     }
     $configuration->setDescriptionEntity($mappingEntity);
     $collection = $entityRepository->findForPaginate($configuration);
     $recordsTotal = $entityRepository->count($configuration);
     $recordsFiltered = $entityRepository->countWithFilter($configuration);
     return $this->generateFacadeDataTable($transformerManager, $collection, $recordsTotal, $recordsFiltered);
 }
 /**
  * @param Request $request
  *
  * @Config\Route("", name="open_orchestra_api_content_type_list")
  * @Config\Method({"GET"})
  *
  * @return FacadeInterface
  */
 public function listAction(Request $request)
 {
     $repository = $this->get('open_orchestra_model.repository.content_type');
     $transformer = $this->get('open_orchestra_api.transformer_manager')->get('content_type_collection');
     if ($request->get('entityId')) {
         $element = $repository->find($request->get('entityId'));
         return $transformer->transform(array($element));
     }
     $configuration = PaginateFinderConfiguration::generateFromRequest($request);
     $mapping = $this->get('open_orchestra.annotation_search_reader')->extractMapping($this->container->getParameter('open_orchestra_model.document.content_type.class'));
     $configuration->setDescriptionEntity($mapping);
     $contentTypeCollection = $repository->findAllNotDeletedInLastVersionForPaginate($configuration);
     $recordsTotal = $repository->countByContentTypeInLastVersion();
     $recordsFiltered = $repository->countNotDeletedInLastVersionWithSearchFilter($configuration);
     return $this->generateFacadeDataTable($transformer, $contentTypeCollection, $recordsTotal, $recordsFiltered);
 }
 /**
  * @param Request $request
  *
  * @Config\Route("", name="open_orchestra_api_site_list")
  * @Config\Method({"GET"})
  *
  * @return FacadeInterface
  */
 public function listAction(Request $request)
 {
     $repository = $this->get('open_orchestra_model.repository.site');
     $transformer = $this->get('open_orchestra_api.transformer_manager')->get('site_collection');
     if ($entityId = $request->get('entityId')) {
         $element = $repository->find($entityId);
         return $transformer->transform(array($element));
     }
     $configuration = PaginateFinderConfiguration::generateFromRequest($request);
     $configuration->addColumnSearch('deleted', false);
     $mapping = $this->get('open_orchestra.annotation_search_reader')->extractMapping($this->container->getParameter('open_orchestra_model.document.site.class'));
     $configuration->setDescriptionEntity($mapping);
     $siteCollection = $repository->findByDeletedForPaginate(false, $configuration);
     $recordsTotal = $repository->countByDeleted(false);
     $recordsFiltered = $repository->countWithSearchFilterByDeleted(false, $configuration);
     return $this->generateFacadeDataTable($transformer, $siteCollection, $recordsTotal, $recordsFiltered);
 }
 /**
  * @param Request $request
  *
  * @Config\Route("", name="open_orchestra_api_content_list")
  * @Config\Method({"GET"})
  *
  * @Api\Groups({GroupContext::G_HIDE_ROLES})
  *
  * @return FacadeInterface
  */
 public function listAction(Request $request)
 {
     $contentType = $request->get('content_type');
     $siteId = $this->get('open_orchestra_backoffice.context_manager')->getCurrentSiteId();
     $repository = $this->get('open_orchestra_model.repository.content');
     $transformer = $this->get('open_orchestra_api.transformer_manager')->get('content_collection');
     if ($request->get('entityId') && $request->get('language')) {
         $content = $this->showOrCreate($request, $request->get('entityId'));
         return $transformer->transform(array($content), $contentType);
     }
     $configuration = PaginateFinderConfiguration::generateFromRequest($request);
     $mapping = $this->get('open_orchestra.annotation_search_reader')->extractMapping($this->container->getParameter('open_orchestra_model.document.content.class'));
     $mappingAttributes = $this->get('open_orchestra_api.mapping.content_attribute')->getMapping($contentType);
     $mapping = array_merge($mapping, $mappingAttributes);
     $configuration->setDescriptionEntity($mapping);
     $contentCollection = $repository->findPaginatedLastVersionByContentTypeAndSite($contentType, $configuration, $siteId);
     $recordsTotal = $repository->countByContentTypeAndSiteInLastVersion($contentType, $siteId);
     $recordsFiltered = $repository->countByContentTypeInLastVersionWithFilter($contentType, $configuration, $siteId);
     $facade = $transformer->transform($contentCollection, $contentType);
     $facade->recordsTotal = $recordsTotal;
     $facade->recordsFiltered = $recordsFiltered;
     return $facade;
 }
 /**
  * @param Request $request
  * @param String  $siteId
  * @param String  $language
  *
  * @Config\Route("/list/{siteId}/{language}", name="open_orchestra_api_node_list")
  * @Config\Method({"GET"})
  *
  *  @Api\Groups({
  *     OpenOrchestra\ApiBundle\Context\CMSGroupContext::STATUS
  * })
  *
  * @return FacadeInterface
  */
 public function listAction(Request $request, $siteId, $language)
 {
     $mapping = array('updated_at' => 'updatedAt', 'name' => 'name', 'created_by' => 'createdBy', 'status.label' => 'status.labels');
     $configuration = PaginateFinderConfiguration::generateFromRequest($request, $mapping);
     $repository = $this->get('open_orchestra_model.repository.node');
     $collection = $repository->findForPaginate($configuration, $siteId, $language);
     $recordsTotal = $repository->count($siteId, $language);
     $recordsFiltered = $repository->countWithFilter($configuration, $siteId, $language);
     $collectionTransformer = $this->get('open_orchestra_api.transformer_manager')->get('node_collection');
     $facade = $collectionTransformer->transform($collection);
     $facade->recordsTotal = $recordsTotal;
     $facade->recordsFiltered = $recordsFiltered;
     return $facade;
 }
 /**
  * @param array       $mapping
  * @param array|null  $search
  * @param array|null  $order
  * @param int|null    $limit
  * @param int|null    $skip
  *
  * @dataProvider provideConfigurationCreation
  */
 public function testGenerateFromRequest($mapping, $search, $order, $limit, $skip)
 {
     $request = $this->createRequest($search, $order, $limit, $skip);
     $paginateConfiguration = PaginateFinderConfiguration::generateFromRequest($request, $mapping);
     $this->finderPaginateConfigurationTest($paginateConfiguration, $order, $limit, $skip, $search);
 }