Browse Source

Merge branch 'develop' of https://forge.laclic.fr/Laclic/SovBundle into develop

develop
Guillaume 3 years ago
parent
commit
4496d3519e
10 changed files with 94 additions and 82 deletions
  1. +37
    -3
      Builder/User/UserBuilder.php
  2. +0
    -27
      Doctrine/Extension/BlameableNullableTrait.php
  3. +39
    -40
      Doctrine/Extension/BlameableTrait.php
  4. +4
    -3
      EventSubscriber/SortablePropertyEventSubscriber.php
  5. +6
    -1
      Model/Site/NewsModel.php
  6. +1
    -1
      Model/Ticket/TicketMessageModel.php
  7. +1
    -1
      Model/Ticket/TicketModel.php
  8. +2
    -6
      Model/User/GroupUserModel.php
  9. +3
    -0
      Model/User/UserModel.php
  10. +1
    -0
      Repository/User/UserStore.php

+ 37
- 3
Builder/User/UserBuilder.php View File

@@ -3,18 +3,22 @@
namespace Lc\SovBundle\Builder\User;

use Doctrine\ORM\EntityManagerInterface;
use Lc\SovBundle\Doctrine\EntityInterface;
use Lc\SovBundle\Doctrine\Extension\BlameableInterface;
use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\User\UserStore;
use Lc\SovBundle\Solver\User\UserSolver;

class UserBuilder
{
protected EntityManagerInterface $entityManager;
protected UserStore $userStore;
protected UserSolver $userSolver;

public function __construct(EntityManagerInterface $entityManager, UserSolver $userSolver)
public function __construct(EntityManagerInterface $entityManager, UserStore $userStore, UserSolver $userSolver)
{
$this->entityManager = $entityManager;
$this->userStore = $userStore;
$this->userSolver = $userSolver;
}

@@ -25,8 +29,38 @@ class UserBuilder
} else {
$user->removeNewsletter($newsletter);
}
$this->entityManager->persist($user);
$this->entityManager->flush();
}

public function initBlameableSystem(EntityInterface $entity)
{
$userSystem = $this->userStore->getOneByDevAlias('system');
$this->initBlameable($entity, $userSystem);

return $entity;
}
public function initBlameableUpdatedSystem(EntityInterface $entity)
{
$userSystem = $this->userStore->getOneByDevAlias('system');
$this->initBlameableUpdated($entity, $userSystem);

return $entity;
}

public function initBlameable(EntityInterface $entity, UserInterface $user)
{
if ($entity instanceof BlameableInterface) {
$entity->setCreatedBy($user);
}
$this->initBlameableUpdated($entity, $user);
}

public function initBlameableUpdated(EntityInterface $entity, UserInterface $user)
{
if ($entity instanceof BlameableInterface) {
$entity->setUpdatedBy($user);
}
}
}

+ 0
- 27
Doctrine/Extension/BlameableNullableTrait.php View File

@@ -1,27 +0,0 @@
<?php

namespace Lc\SovBundle\Doctrine\Extension;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Lc\SovBundle\Model\User\UserInterface;

trait BlameableNullableTrait
{

/**
* @Gedmo\Blameable(on="create")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $createdBy;

/**
* @Gedmo\Blameable(on="update")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $updatedBy;


}

+ 39
- 40
Doctrine/Extension/BlameableTrait.php View File

@@ -9,43 +9,42 @@ use Lc\SovBundle\Model\User\UserInterface;
trait BlameableTrait
{

/**
* @Gedmo\Blameable(on="create")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $createdBy;

/**
* @Gedmo\Blameable(on="update")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $updatedBy;


public function getCreatedBy(): ?UserInterface
{
return $this->createdBy;
}

public function setCreatedBy(?UserInterface $createdBy): self
{
$this->createdBy = $createdBy;

return $this;
}

public function getUpdatedBy(): ?UserInterface
{
return $this->updatedBy;
}

public function setUpdatedBy(?UserInterface $updatedBy): self
{
$this->updatedBy = $updatedBy;

return $this;
}

}
/**
* @Gedmo\Blameable(on="create")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $createdBy;

/**
* @Gedmo\Blameable(on="update")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $updatedBy;


public function getCreatedBy(): ?UserInterface
{
return $this->createdBy;
}

public function setCreatedBy(?UserInterface $createdBy): self
{
$this->createdBy = $createdBy;

return $this;
}

public function getUpdatedBy(): ?UserInterface
{
return $this->updatedBy;
}

public function setUpdatedBy(?UserInterface $updatedBy): self
{
$this->updatedBy = $updatedBy;

return $this;
}
}

+ 4
- 3
EventSubscriber/SortablePropertyEventSubscriber.php View File

@@ -41,14 +41,15 @@ class SortablePropertyEventSubscriber implements EventSubscriberInterface

private function setSortableProperty(EntityInterface $entity, AbstractRepositoryInterface $entityRepository)
{
$countParam = array();
if ($entity instanceof StatusInterface) {
$countParam['status'] = 1;
}

if ($entity instanceof TreeInterface) {
if($entity->getParent()){
if ($entity->getParent()) {
$countParam['parent'] = $entity->getParent()->getId();
}else{
} else {
$countParam['parent'] = null;
}
}
@@ -59,4 +60,4 @@ class SortablePropertyEventSubscriber implements EventSubscriberInterface
}


}
}

+ 6
- 1
Model/Site/NewsModel.php View File

@@ -4,6 +4,8 @@ namespace Lc\SovBundle\Model\Site;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Lc\SovBundle\Doctrine\Extension\OpenGraphInterface;
use Lc\SovBundle\Doctrine\Extension\OpenGraphTrait;
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
use Lc\SovBundle\Model\File\FileInterface;
use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
@@ -11,9 +13,12 @@ use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
/**
* @ORM\MappedSuperclass()
*/
abstract class NewsModel extends AbstractFullEntity implements NewsInterface
abstract class NewsModel extends AbstractFullEntity implements NewsInterface, OpenGraphInterface
{

use OpenGraphTrait;


/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")

+ 1
- 1
Model/Ticket/TicketMessageModel.php View File

@@ -16,7 +16,7 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
abstract class TicketMessageModel extends AbstractLightEntity implements TicketMessageInterface, EntityInterface, StatusInterface
{
use StatusTrait;
use BlameableNullableTrait;

/**
* @ORM\Column(type="text")

+ 1
- 1
Model/Ticket/TicketModel.php View File

@@ -16,7 +16,7 @@ use Lc\SovBundle\Model\User\UserInterface;
*/
abstract class TicketModel extends AbstractLightEntity implements TicketInterface, EntityInterface
{
use BlameableNullableTrait;


const TYPE_TECHNICAL_PROBLEM = 'technical-problem';

+ 2
- 6
Model/User/GroupUserModel.php View File

@@ -6,19 +6,15 @@ use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Lc\SovBundle\Doctrine\EntityInterface;
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;

/**
* @ORM\MappedSuperclass()
*/
abstract class GroupUserModel extends AbstractLightEntity implements GroupUserInterface, EntityInterface
abstract class GroupUserModel extends AbstractFullEntity implements GroupUserInterface, EntityInterface
{

/**
* @ORM\Column(type="string", length=255)
*/
protected $title;

/**
* @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\User\UserInterface", mappedBy="groupUsers")
*/

+ 3
- 0
Model/User/UserModel.php View File

@@ -8,6 +8,7 @@ use Doctrine\ORM\Mapping as ORM;
use Lc\SovBundle\Doctrine\EntityInterface;
use Lc\SovBundle\Doctrine\Extension\DevAliasInterface;
use Lc\SovBundle\Doctrine\Extension\DevAliasTrait;
use Lc\SovBundle\Doctrine\Extension\TimestampableTrait;
use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
use Lc\SovBundle\Model\Ticket\TicketInterface;
use Symfony\Component\Security\Core\User\UserInterface;
@@ -18,6 +19,8 @@ use Symfony\Component\Security\Core\User\UserInterface;
abstract class UserModel implements EntityInterface, UserInterface, DevAliasInterface
{
use DevAliasTrait;
use TimestampableTrait;

/**
* @ORM\Column(type="string", length=180, unique=true)
*/

+ 1
- 0
Repository/User/UserStore.php View File

@@ -61,4 +61,5 @@ class UserStore extends AbstractStore implements UserStoreInterface
$query->filterByEmail($email);
return $query->findOne();
}

}

Loading…
Cancel
Save