From b105fc516cc8b6162a9d2d780a245c6a0b703985 Mon Sep 17 00:00:00 2001 From: Martynas Sudintas Date: Mon, 3 Nov 2014 14:07:18 +0200 Subject: [PATCH] removed category list --- Resources/config/services.yml | 6 --- Service/CategoryList.php | 88 ----------------------------------- 2 files changed, 94 deletions(-) delete mode 100644 Service/CategoryList.php diff --git a/Resources/config/services.yml b/Resources/config/services.yml index cfbf172..5764503 100755 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -3,7 +3,6 @@ parameters: ongr_content.twig.category_extension.class: ONGR\ContentBundle\Twig\CategoryExtension ongr_content.content_service.class: ONGR\ContentBundle\Service\ContentService ongr_content.category_service.class: ONGR\ContentBundle\Service\CategoryService - ongr_content.category_list.class: ONGR\ContentBundle\Service\CategoryList ongr_content.product_per_page: 10 @@ -27,11 +26,6 @@ services: calls: - [setLogger, [@?logger]] - ongr_content.category_list: - class: %ongr_content.category_list.class% - calls: - - [setProductsPerPage, [%ongr_content.product_per_page%]] - ongr_content.category_service: class: %ongr_content.category_service.class% diff --git a/Service/CategoryList.php b/Service/CategoryList.php deleted file mode 100644 index 0e61ad0..0000000 --- a/Service/CategoryList.php +++ /dev/null @@ -1,88 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace ONGR\ContentBundle\Service; - -use ONGR\ElasticsearchBundle\Document\DocumentInterface; -use ONGR\ElasticsearchBundle\DSL\Query\TermQuery; -use ONGR\ElasticsearchBundle\DSL\Search; -use ONGR\ElasticsearchBundle\ORM\Repository; -use Symfony\Component\HttpFoundation\Request; - -/** - * Collects categories and products data. - */ -class CategoryList -{ - /** - * @var Repository - */ - protected $repository; - - /** - * @var int - */ - protected $productsPerPage; - - /** - * @param Request $request - * @param DocumentInterface $document - * - * @return array - */ - public function getCategoryData(Request $request, $document) - { - $page = max((int)$request->query->get('page'), 1); - $sort = $request->query->get('sort'); - $reverse = (bool)$request->query->get('desc'); - - $search = new Search(); - $search->addQuery(new TermQuery('categories', $document->id), 'must'); - - $urlParameters = [ - 'document' => $document, - 'sort' => $sort, - 'page' => $page, - ]; - - if ($reverse) { - $urlParameters['desc'] = 1; - } - - return [ - 'category' => $document, - 'page' => $page, - 'urlParameters' => $urlParameters, - 'urlRoute' => $request->get('_route'), - 'pager' => null, - 'products' => [], - 'count' => 0, - 'js' => $request->isXmlHttpRequest(), - 'selectedCategory' => $document->id, - ]; - } - - /** - * @param string $repositoryName - */ - public function setRepository($repositoryName) - { - $this->repository = $this->manager->getRepository($repositoryName); - } - - /** - * @param int $productsPerPage - */ - public function setProductsPerPage($productsPerPage) - { - $this->productsPerPage = $productsPerPage; - } -}