ElementReportManager.php 794B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace Muzich\CoreBundle\Managers;
  3. use Muzich\CoreBundle\Entity\Element;
  4. use Muzich\CoreBundle\Entity\User;
  5. /**
  6. * Manager de rapport sur elements
  7. *
  8. * @author bux
  9. */
  10. class ElementReportManager
  11. {
  12. protected $element;
  13. public function __construct(Element $element)
  14. {
  15. $this->element = $element;
  16. }
  17. /**
  18. * Ajouter un rapport
  19. *
  20. * @param \Muzich\CoreBundle\Entity\User $user
  21. * @param String $comment
  22. * @param String $date
  23. */
  24. public function add(User $user)
  25. {
  26. $ids = $this->element->getReportIds();
  27. if ($ids === null){$ids = array();}
  28. if (!in_array($user->getId(), $ids))
  29. {
  30. $ids[] = (string)$user->getId();
  31. }
  32. $this->element->setCountReport(count($ids));
  33. $this->element->setReportIds($ids);
  34. }
  35. }