GroupManager.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Muzich\CoreBundle\Managers;
  3. use Muzich\CoreBundle\Entity\Group;
  4. use Muzich\CoreBundle\Entity\User;
  5. use Doctrine\ORM\EntityManager;
  6. use Symfony\Component\DependencyInjection\Container;
  7. /**
  8. *
  9. *
  10. * @author bux
  11. */
  12. class GroupManager
  13. {
  14. protected $em;
  15. protected $group;
  16. protected $container;
  17. public function __construct(Group $group, EntityManager $em, Container $container)
  18. {
  19. $this->group = $group;
  20. $this->em = $em;
  21. $this->container = $container;
  22. // Slug stuff
  23. $evm = new \Doctrine\Common\EventManager();
  24. // ORM and ODM
  25. $sluggableListener = new \Gedmo\Sluggable\SluggableListener();
  26. $evm->addEventSubscriber($sluggableListener);
  27. // now this event manager should be passed to entity manager constructor
  28. $this->em->getEventManager()->addEventSubscriber($sluggableListener);
  29. }
  30. /**
  31. * Procédure chargé de construire le contenu tags.
  32. *
  33. * @param array $tags_ids
  34. */
  35. public function proceedTags($tags_ids)
  36. {
  37. // La procédure se charge pour le moment des tags
  38. $this->group->setTags(null);
  39. $this->group->setTagsWithIds($this->em, $tags_ids);
  40. }
  41. }