CreateAction::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 CreateAction extends AbstractFormAction
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    protected function getObject(Request $request)
19
    {
20
        return $this->getManager()->create(
21
            $this->configuration->getEntityClass(),
22
            $this->options['create_values'],
23
            $this->options['create_options']
24
        );
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    protected function setDefaultOptions(OptionsResolver $resolver)
31
    {
32
        parent::setDefaultOptions($resolver);
33
34
        $resolver->setDefaults(
35
            [
36
                'route'           => 'pim_customentity_create',
37
                'create_values'   => [],
38
                'create_options'  => [],
39
                'success_message' => sprintf('flash.%s.created', $this->configuration->getName())
40
            ]
41
        );
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function getType()
48
    {
49
        return 'create';
50
    }
51
}
52