Completed
Push — master ( 7a9a35...ef55ea )
by Adam
06:26
created

getCurrentProducerCollectionMenuConditions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
/*
3
 * WellCommerce Open-Source E-Commerce Platform
4
 *
5
 * This file is part of the WellCommerce package.
6
 *
7
 * (c) Adam Piotrowski <[email protected]>
8
 *
9
 * For the full copyright and license information,
10
 * please view the LICENSE file that was distributed with this source code.
11
 */
12
13
namespace WellCommerce\Bundle\CatalogBundle\Controller\Box;
14
15
use Symfony\Component\HttpFoundation\Response;
16
use WellCommerce\Bundle\CoreBundle\Controller\Box\AbstractBoxController;
17
use WellCommerce\Component\Layout\Collection\LayoutBoxSettingsCollection;
18
use WellCommerce\Component\DataSet\Conditions\Condition\Eq;
19
use WellCommerce\Component\DataSet\Conditions\ConditionsCollection;
20
21
/**
22
 * Class ProducerCollectionMenuBoxController
23
 *
24
 * @author  Rafał Martonik <[email protected]>
25
 */
26
class ProducerCollectionMenuBoxController extends AbstractBoxController
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function indexAction(LayoutBoxSettingsCollection $boxSettings) : Response
32
    {
33
        $conditions          = $this->getCurrentProducerCollectionMenuConditions();
34
        $producerCollections = $this->get('producer_collection.dataset.front')->getResult('array', ['conditions' => $conditions],
35
            ['pagination' => false]);
36
        
37
        return $this->displayTemplate('index', [
38
            'producerCollections'      => $producerCollections,
39
            'activeProducerCollection' => $this->getProducerCollectionStorage()->getCurrentProducerCollection(),
40
            'producer'                 => $this->getProducerCollectionStorage()->getCurrentProducerCollection()->getProducer(),
41
        ]);
42
    }
43
    
44
    /**
45
     * @return ConditionsCollection
46
     */
47
    protected function getCurrentProducerCollectionMenuConditions() : ConditionsCollection
48
    {
49
        $conditions = new ConditionsCollection();
50
        $conditions->add(new Eq('producerId',
51
            $this->getProducerCollectionStorage()->getCurrentProducerCollection()->getProducer()->getId()));
52
        
53
        return $conditions;
54
    }
55
    
56
}
57