IndexAction::getType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Pim\Bundle\CustomEntityBundle\Action;
4
5
use Symfony\Component\HttpFoundation\Request;
6
use Symfony\Component\OptionsResolver\OptionsResolver;
7
8
/**
9
 * @author    Antoine Guigan <[email protected]>
10
 * @copyright 2013 Akeneo SAS (http://www.akeneo.com)
11
 * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
12
 */
13
class IndexAction extends AbstractViewableAction implements IndexActionInterface
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function doExecute(Request $request)
19
    {
20
        $vars = [];
21
        if ($this->configuration->hasAction('create')) {
22
            $vars['createUrl'] = $this->getActionUrl($this->options['quick_create_action_type']);
23
            $vars['quickCreate'] = $this->options['quick_create'];
24
        }
25
26
        return $this->renderResponse($vars);
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function getType()
33
    {
34
        return 'index';
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function getMassActions()
41
    {
42
        return $this->options['mass_actions'];
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function getRowActions()
49
    {
50
        return $this->options['row_actions'];
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    protected function setDefaultOptions(OptionsResolver $resolver)
57
    {
58
        parent::setDefaultOptions($resolver);
59
60
        $resolver->setDefaults(
61
            [
62
                'route'                    => 'pim_customentity_index',
63
                'quick_create'             => false,
64
                'quick_create_action_type' => 'create',
65
                'template'                 => 'PimCustomEntityBundle:CustomEntity:index.html.twig',
66
                'row_actions'              => ['edit', 'delete'],
67
                'mass_actions'             => []
68
            ]
69
        );
70
    }
71
}
72