@@ 57-69 (lines=13) @@ | ||
54 | throw new \Exception('Container passed to Sinergi\\Users must contain user, group and session\'s entities'); |
|
55 | } |
|
56 | ||
57 | if ($hasUserEntity && !$hasUserRepository) { |
|
58 | $userEntity = $this->container->get(UserEntityInterface::class); |
|
59 | if ($userEntity instanceof DoctrineUserEntity) { |
|
60 | $em = $this->container->get(EntityManager::class); |
|
61 | $this->items[UserRepositoryInterface::class] = function () use ($em, $userEntity, $self) { |
|
62 | return new DoctrineUserRepository($em, $em->getClassMetadata(get_class($userEntity)), $self); |
|
63 | }; |
|
64 | } elseif ($userEntity instanceof EloquentUserEntity) { |
|
65 | $this->items[UserRepositoryInterface::class] = function () { |
|
66 | return new EloquentUserRepository(); |
|
67 | }; |
|
68 | } |
|
69 | } |
|
70 | ||
71 | if ($hasSessionEntity && !$hasSessionRepository) { |
|
72 | $sessionEntity = $this->container->get(SessionEntityInterface::class); |
|
@@ 71-83 (lines=13) @@ | ||
68 | } |
|
69 | } |
|
70 | ||
71 | if ($hasSessionEntity && !$hasSessionRepository) { |
|
72 | $sessionEntity = $this->container->get(SessionEntityInterface::class); |
|
73 | if ($sessionEntity instanceof DoctrineSessionEntity) { |
|
74 | $em = $this->container->get(EntityManager::class); |
|
75 | $this->items[SessionRepositoryInterface::class] = function () use ($em, $sessionEntity, $self) { |
|
76 | return new DoctrineSessionRepository($em, $em->getClassMetadata(get_class($sessionEntity)), $self); |
|
77 | }; |
|
78 | } elseif ($sessionEntity instanceof EloquentSessionEntity) { |
|
79 | $this->items[SessionRepositoryInterface::class] = function () { |
|
80 | return new EloquentSessionRepository(); |
|
81 | }; |
|
82 | } |
|
83 | } |
|
84 | ||
85 | if ($hasGroupEntity && !$hasGroupRepository) { |
|
86 | $groupEntity = $this->container->get(GroupEntityInterface::class); |
|
@@ 85-97 (lines=13) @@ | ||
82 | } |
|
83 | } |
|
84 | ||
85 | if ($hasGroupEntity && !$hasGroupRepository) { |
|
86 | $groupEntity = $this->container->get(GroupEntityInterface::class); |
|
87 | if ($groupEntity instanceof DoctrineGroupEntity) { |
|
88 | $em = $this->container->get(EntityManager::class); |
|
89 | $this->items[GroupRepositoryInterface::class] = function () use ($em, $groupEntity, $self) { |
|
90 | return new DoctrineGroupRepository($em, $em->getClassMetadata(get_class($groupEntity)), $self); |
|
91 | }; |
|
92 | } elseif ($groupEntity instanceof EloquentGroupEntity) { |
|
93 | $this->items[GroupRepositoryInterface::class] = function () { |
|
94 | return new EloquentGroupRepository(); |
|
95 | }; |
|
96 | } |
|
97 | } |
|
98 | ||
99 | if (!$hasUserValidator) { |
|
100 | $this->items[UserValidatorInterface::class] = function () use ($self) { |