InlineEditController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 10
Bugs 1 Features 3
Metric Value
wmc 2
c 10
b 1
f 3
lcom 0
cbo 0
dl 0
loc 33
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateAttributeValueAction() 0 19 2
1
<?php
2
3
namespace  DefaultValue\Bundle\AkeneoInlineEditBundle\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6
use Symfony\Component\HttpFoundation\JsonResponse;
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Component\HttpFoundation\RedirectResponse;
9
use Symfony\Component\HttpFoundation\Response;
10
use Oro\Bundle\SecurityBundle\Annotation\AclAncestor;
11
12
class InlineEditController extends Controller
13
{
14
    /**
15
     * Apply attribute value for given locale and scope(channel) after grid inline edit
16
     *
17
     * @AclAncestor("default_value_inline_edit_update_value")
18
     *
19
     * @param Request $request
20
     * @param $id
21
     * @param $dataLocale
22
     * @param $scopeCode
23
     * @return Response
24
     */
25
    public function updateAttributeValueAction(Request $request, $id, $dataLocale, $scopeCode)
26
    {
27
        $attributeCode = $request->request->get('attrName');
28
        $attributeValue = $request->request->get('attrVal');
29
        $productUpdater = $this->get('default_value.akeneo_inline_edit.updater.product_updater');
30
31
        $updated = $productUpdater->update($id, $attributeCode, $attributeValue, $dataLocale, $scopeCode);
32
33
        $response = [
34
            'successful' => $updated,
35
            'message'    => $productUpdater->getUpdateInfo()
36
        ];
37
38
        if ($request->isXmlHttpRequest()) {
39
            return new JsonResponse($response);
40
        } else {
41
            return new RedirectResponse('pim_enrich_product_index');
42
        }
43
    }
44
}
45