Completed
Push — SF4 ( dd087e...1638ab )
by Laurent
09:52 queued 08:17
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
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