Completed
Push — SF4 ( 211d37...f4ba4a )
by Laurent
02:09
created

ArticleController::updateArticleEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
4
/**
5
 * ArticleController Controller of Article entity.
6
 *
7
 * PHP Version 7
8
 *
9
 * @author    Quétier Laurent <[email protected]>
10
 * @copyright 2018 Dev-Int GLSR
11
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
12
 *
13
 * @version GIT: $Id$
14
 *
15
 * @link https://github.com/Dev-Int/glsr
16
 */
17
18
namespace App\Controller;
19
20
use EasyCorp\Bundle\EasyAdminBundle\Controller\AdminController as BaseAdminController;
21
use App\Entity\Settings\Article;
22
23
/**
24
 * Article Controller override EasyAdminBundle::AdminController
25
 *
26
 * @category Controller
27
 */
28
class ArticleController extends BaseAdminController
29
{
30
    /**
31
     * Allows applications to modify the entity associated with the item being
32
     * edited before updating it.
33
     *
34
     * @param Article $article
35
     */
36
    public function updateArticleEntity(Article $article)
37
    {
38
        $article->setUpdateAt(new \DateTime());
39
        parent::updateEntity($article);
1 ignored issue
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (updateEntity() instead of updateArticleEntity()). Are you sure this is correct? If so, you might want to change this to $this->updateEntity().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
40
    }
41
42
    /**
43
     * Allows applications to modify the entity associated with the item being
44
     * deleted before removing it.
45
     *
46
     * @param Article $article
47
     */
48
    protected function removeArticleEntity(Article $article)
49
    {
50
        $article->setUpdateAt(new \DateTime());
51
        $article->setDeleteAt(new \DateTime());
52
        $article->setActive(false);
53
        $this->em->persist($article);
54
        $this->em->flush();
55
    }
56
}
57