UserManagerProxy.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. /*
  3. * This file is part of the Sonata Project package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Sonata\UserBundle\Entity;
  11. use Doctrine\Common\Persistence\ManagerRegistry;
  12. use Sonata\CoreBundle\Model\BaseEntityManager;
  13. /**
  14. * This UserManageProxy class is used to keep UserManager compatible with Sonata ManagerInterface implementation
  15. * because UserManager implements FOSUserBundle manager interface.
  16. *
  17. * @author Sylvain Deloux <sylvain.deloux@ekino.com>
  18. */
  19. class UserManagerProxy extends BaseEntityManager
  20. {
  21. /**
  22. * @var UserManager
  23. */
  24. protected $userManager;
  25. /**
  26. * UserManagerProxy constructor.
  27. *
  28. * @param string $class
  29. * @param ManagerRegistry $registry
  30. * @param UserManager $userManager
  31. */
  32. public function __construct($class, ManagerRegistry $registry, UserManager $userManager)
  33. {
  34. parent::__construct($class, $registry);
  35. $this->userManager = $userManager;
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function getClass()
  41. {
  42. return $this->userManager->getClass();
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function findAll()
  48. {
  49. return $this->userManager->findAll();
  50. }
  51. /**
  52. * {@inheritdoc}
  53. */
  54. public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  55. {
  56. return $this->userManager->findBy($criteria, $orderBy, $limit, $offset);
  57. }
  58. /**
  59. * {@inheritdoc}
  60. */
  61. public function findOneBy(array $criteria, array $orderBy = null)
  62. {
  63. return $this->userManager->findOneBy($criteria, $orderBy);
  64. }
  65. /**
  66. * {@inheritdoc}
  67. */
  68. public function find($id)
  69. {
  70. return $this->userManager->find($id);
  71. }
  72. /**
  73. * {@inheritdoc}
  74. */
  75. public function create()
  76. {
  77. return $this->userManager->create();
  78. }
  79. /**
  80. * {@inheritdoc}
  81. */
  82. public function save($entity, $andFlush = true)
  83. {
  84. return $this->userManager->save($entity, $andFlush);
  85. }
  86. /**
  87. * {@inheritdoc}
  88. */
  89. public function delete($entity, $andFlush = true)
  90. {
  91. return $this->userManager->delete($entity, $andFlush);
  92. }
  93. /**
  94. * {@inheritdoc}
  95. */
  96. public function getTableName()
  97. {
  98. return $this->userManager->getTableName();
  99. }
  100. /**
  101. * {@inheritdoc}
  102. */
  103. public function getConnection()
  104. {
  105. return $this->userManager->getConnection();
  106. }
  107. }