Completed
Push — SF4 ( dd087e...1638ab )
by Laurent
09:52 queued 08:17
created

ArticleController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A updateArticleEntity() 0 5 1
A removeArticleEntity() 0 8 1
1
<?php
2
3
namespace App\Controller;
4
5
use Doctrine\ORM\ORMException;
6
use EasyCorp\Bundle\EasyAdminBundle\Controller\EasyAdminController as BaseAdminController;
7
use App\Entity\Settings\Article;
8
9
final class ArticleController extends BaseAdminController
10
{
11
    /**
12
     * Allows applications to modify the entity associated with the item being
13
     * edited before updating it.
14
     */
15
    public function updateArticleEntity(Article $article): void
16
    {
17
        $article->setUpdateAt(new \DateTimeImmutable());
18
        $this->updateEntity($article);
19
    }
20
21
    /**
22
     * Allows applications to modify the entity associated with the item being
23
     * deleted before removing it.
24
     *
25
     * @throws ORMException
26
     */
27
    protected function removeArticleEntity(Article $article): void
28
    {
29
        $article->setUpdateAt(new \DateTimeImmutable());
30
        $article->setDeleteAt(new \DateTimeImmutable());
31
        $article->setActive(false);
32
        $this->em->persist($article);
33
        $this->em->flush();
34
    }
35
}
36