mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-18 16:16:02 +02:00
Renamed domain UserManagement to User
This commit is contained in:
58
application/symfony/src/Domain/User/UserSourceDirector.php
Normal file
58
application/symfony/src/Domain/User/UserSourceDirector.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\User;
|
||||
|
||||
use Infinito\Entity\UserInterface;
|
||||
use Infinito\Entity\User;
|
||||
use Infinito\Repository\Source\SourceRepositoryInterface;
|
||||
use Infinito\Domain\Fixture\FixtureSource\GuestUserFixtureSource;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class UserSourceDirector implements UserSourceDirectorInterface
|
||||
{
|
||||
/**
|
||||
* @var UserInterface
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @var SourceRepositoryInterface
|
||||
*/
|
||||
private $sourceRepository;
|
||||
|
||||
/**
|
||||
* @param UserInterface $user
|
||||
*/
|
||||
private function setUser(?UserInterface $user): void
|
||||
{
|
||||
if ($user) {
|
||||
$this->user = $user;
|
||||
|
||||
return;
|
||||
}
|
||||
$this->user = new User();
|
||||
$this->user->setSource($this->sourceRepository->findOneBySlug(GuestUserFixtureSource::getSlug()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SourceRepositoryInterface $sourceRepository
|
||||
* @param UserInterface $user
|
||||
*/
|
||||
public function __construct(SourceRepositoryInterface $sourceRepository, ?UserInterface $user)
|
||||
{
|
||||
$this->sourceRepository = $sourceRepository;
|
||||
$this->setUser($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\User\UserSourceDirectorInterface::getUser()
|
||||
*/
|
||||
public function getUser(): UserInterface
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\User;
|
||||
|
||||
use Infinito\Entity\UserInterface;
|
||||
|
||||
/**
|
||||
* Offers based on an user variable a user with a source.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface UserSourceDirectorInterface
|
||||
{
|
||||
/**
|
||||
* @return UserInterface
|
||||
*/
|
||||
public function getUser(): UserInterface;
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\User;
|
||||
|
||||
use Infinito\Entity\UserInterface;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Infinito\Entity\Source\AbstractSource;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo Test!
|
||||
*/
|
||||
final class UserSourceDirectorService implements UserSourceDirectorServiceInterface
|
||||
{
|
||||
/**
|
||||
* @var EntityManager
|
||||
*/
|
||||
private $entityManager;
|
||||
|
||||
/**
|
||||
* @var Security
|
||||
*/
|
||||
private $security;
|
||||
|
||||
/**
|
||||
* @param EntityManager $entityManagerInterface
|
||||
* @param Security $security
|
||||
*/
|
||||
public function __construct(EntityManagerInterface $entityManager, Security $security)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UserSourceDirectorInterface
|
||||
*/
|
||||
private function getUserSourceDirector(): UserSourceDirectorInterface
|
||||
{
|
||||
$sourceRepository = $this->entityManager->getRepository(AbstractSource::class);
|
||||
$user = $this->security->getUser();
|
||||
|
||||
return new UserSourceDirector($sourceRepository, $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Optimzed performance!
|
||||
*
|
||||
* @return UserInterface
|
||||
*/
|
||||
public function getUser(): UserInterface
|
||||
{
|
||||
return $this->getUserSourceDirector()->getUser();
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\User;
|
||||
|
||||
/**
|
||||
* Offers UserSourceDirector to be used as a Service.
|
||||
*
|
||||
* @see UserSourceDirector
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface UserSourceDirectorServiceInterface extends UserSourceDirectorInterface
|
||||
{
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\User;
|
||||
|
||||
use Infinito\DBAL\Types\Meta\Right\LayerType;
|
||||
use Infinito\DBAL\Types\ActionType;
|
||||
|
||||
/**
|
||||
* Containes the standart map.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface UserSourceStandartRightMapInterface
|
||||
{
|
||||
const LAYER_RIGHT_MAP = [
|
||||
LayerType::SOURCE => [
|
||||
ActionType::READ,
|
||||
ActionType::UPDATE,
|
||||
],
|
||||
];
|
||||
}
|
Reference in New Issue
Block a user