Optimized documentation and class naming

This commit is contained in:
Kevin Frantz 2019-01-19 22:52:49 +01:00
parent 71c7a7f080
commit 4b86acb372
24 changed files with 195 additions and 41 deletions

View File

@ -1,12 +0,0 @@
<?php
namespace App\Domain;
/**
* @deprecated Doesn't make sense!
*
* @author kevinfrantz
*/
abstract class AbstractDomainService
{
}

View File

@ -9,7 +9,7 @@ use App\Domain\PathManagement\NamespacePathMap;
use App\Domain\PathManagement\NamespacePathMapInterface;
/**
* Offers informations, which the system needs to handle Entities.
* Offers some meta information about an entity.
*
* @author kevinfrantz
*/

View File

@ -17,7 +17,7 @@ use App\Domain\SourceManagement\SourceMemberInformation;
*
* @author kevinfrantz
*/
final class LawPermissionCheckerService implements LawPermissionCheckerServiceInterface
final class LawPermissionChecker implements LawPermissionCheckerInterface
{
/**
* @var LawInterface
@ -153,7 +153,7 @@ final class LawPermissionCheckerService implements LawPermissionCheckerServiceIn
/**
* {@inheritdoc}
*
* @see \App\Domain\LawManagement\LawPermissionCheckerServiceInterface::hasPermission()
* @see \App\Domain\LawManagement\LawPermissionCheckerInterface::hasPermission()
*/
public function hasPermission(RightInterface $clientRight): bool
{

View File

@ -5,11 +5,11 @@ namespace App\Domain\LawManagement;
use App\Entity\Meta\RightInterface;
/**
* Allows to check if a source has rights on a source.
* Allows to check if a right has permission by a law.
*
* @author kevinfrantz
*/
interface LawPermissionCheckerServiceInterface
interface LawPermissionCheckerInterface
{
/**
* Checks if the client has the right for executing.

View File

@ -4,6 +4,13 @@ namespace App\Domain\MemberManagement;
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
/**
* Allows to add and remove members and memberships from member relations.
*
* @see MemberRelationInterface
*
* @author kevinfrantz
*/
final class MemberManager implements MemberManagerInterface
{
/**

View File

@ -3,7 +3,7 @@
namespace App\Domain\PathManagement;
/**
* Be carefull with the case sensivity.
* @todo Be carefull with the case sensivity. Solve this!
*
* @author kevinfrantz
*/

View File

@ -0,0 +1,69 @@
# Domain
This folder contains the [domain logic](https://en.wikipedia.org/wiki/Business_logic) of the application.
## Conventions
### Services
Classes which are optimized to be injected as a service MUST end on the suffix ** *Service.php**.
## Folders
A folder MUST end on the suffix ** *Management ** to show that it has the purpose to manage something.
# Domain Overview
## Entity Management
### Entity Meta Information ###
Offers some meta information about an entity
## Form Management
- FormMetaInformation
## Law Management
### LawPermissionChecker ###
Allows to check if a right has permission by a law.
## Member Management
### Member Manager ###
Allows to add and remove members and memberships from member relations.
## Path Management
### Namespace Path Map ###
Maps a path to a namespace.
## Request Management
Offers classes to manage requests for rights, users and sources.
### Logic
- Requested Right
- Requested Source
- Requested User
### Services
- Requested Right Service
- Requested Source Service
- Requested User Service
## Right Management
### Right Checker ###
Checks if the crud, layer and source combination is granted by a right.
### Right Layer Combination Service ###
Allows to get the possible cruds for a layer, or the possible layers for a crud.
## Source Management
### Source Member Information ###
Offers to get all source members over all dimensions.
### Source Member Manager
Offers to add and remove source members and memberships.
### Source Membership Information
Offers to get all memberships of a source.
### Source Right Manager
Allows to add and remove rights of a source.
### Tree Source Information
Allows to get branches and leaves of a tree.
## Template Management
### Template Path Management
Manages all informations which are needed to process templates.
## User Management
### User Source Director
Offers based on an user variable a user with a source.
### User Source Director Service
Offers the _user source director_ to be used as a service, based on the _entity manager_ and _security_.

View File

@ -5,6 +5,8 @@ namespace App\Domain\RightManagement;
use App\Entity\Source\SourceInterface;
/**
* Checks if the crud, layer and source combination is granted by a right.
*
* @author kevinfrantz
*/
interface RightCheckerInterface

View File

@ -6,6 +6,8 @@ use App\DBAL\Types\Meta\Right\LayerType;
use App\DBAL\Types\Meta\Right\CRUDType;
/**
* Allows to get the possible cruds for a layer, or the possible layers for a crud.
*
* @author kevinfrantz
*/
interface RightLayerCombinationServiceInterface

View File

@ -4,7 +4,7 @@ namespace App\Domain\SecureManagement;
use App\Entity\Meta\RightInterface;
use App\Entity\Source\SourceInterface;
use App\Domain\LawManagement\LawPermissionCheckerService;
use App\Domain\LawManagement\LawPermissionChecker;
use App\Exception\SourceAccessDenied;
/**
@ -94,7 +94,7 @@ final class SecureSourceChecker implements SecureSourceCheckerInterface
*/
public function hasPermission(RightInterface $requestedRight): bool
{
$law = new LawPermissionCheckerService($this->source->getLaw());
$law = new LawPermissionChecker($this->source->getLaw());
return $law->hasPermission($requestedRight) && $this->itterateOverSourceAttributs($requestedRight);
}

View File

@ -1,9 +0,0 @@
<?php
namespace App\Domain\SourceManagement;
use App\Domain\AbstractDomainService;
abstract class AbstractSourceService extends AbstractDomainService
{
}

View File

@ -5,6 +5,11 @@ namespace App\Domain\SourceManagement;
use Doctrine\Common\Collections\Collection;
use App\Entity\Source\SourceInterface;
/**
* Offers to get all source members over all dimensions.
*
* @author kevinfrantz
*/
interface SourceMemberInformationInterface
{
/**

View File

@ -6,6 +6,9 @@ use App\Entity\Source\SourceInterface;
use App\Domain\MemberManagement\MemberManagerInterface;
use App\Domain\MemberManagement\MemberManager;
/**
* @author kevinfrantz
*/
final class SourceMemberManager implements SourceMemberManagerInterface
{
/**
@ -18,27 +21,50 @@ final class SourceMemberManager implements SourceMemberManagerInterface
*/
private $memberManager;
/**
* @param SourceInterface $source
*/
public function __construct(SourceInterface $source)
{
$this->source = $source;
$this->memberManager = new MemberManager($this->source->getMemberRelation());
}
/**
* {@inheritdoc}
*
* @see \App\Domain\SourceManagement\SourceMemberManagerInterface::addMember()
*/
public function addMember(SourceInterface $member): void
{
$this->memberManager->addMember($member->getMemberRelation());
}
/**
* {@inheritdoc}
*
* @see \App\Domain\SourceManagement\SourceMemberManagerInterface::removeMember()
*/
public function removeMember(SourceInterface $member): void
{
$this->memberManager->removeMember($member->getMemberRelation());
}
/**
* {@inheritdoc}
*
* @see \App\Domain\SourceManagement\SourceMemberManagerInterface::addMembership()
*/
public function addMembership(SourceInterface $membership): void
{
$this->memberManager->addMembership($membership->getMemberRelation());
}
/**
* {@inheritdoc}
*
* @see \App\Domain\SourceManagement\SourceMemberManagerInterface::removeMembership()
*/
public function removeMembership(SourceInterface $membership): void
{
$this->memberManager->removeMembership($membership->getMemberRelation());

View File

@ -4,6 +4,11 @@ namespace App\Domain\SourceManagement;
use App\Entity\Source\SourceInterface;
/**
* Offers to add and remove source members and memberships.
*
* @author kevinfrantz
*/
interface SourceMemberManagerInterface
{
/**

View File

@ -7,6 +7,9 @@ use App\Entity\Source\SourceInterface;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
/**
* @author kevinfrantz
*/
final class SourceMembershipInformation implements SourceMembershipInformationInterface
{
/**
@ -19,6 +22,9 @@ final class SourceMembershipInformation implements SourceMembershipInformationIn
*/
private $memberships;
/**
* @param SourceInterface $source
*/
public function __construct(SourceInterface $source)
{
$this->source = $source;

View File

@ -5,6 +5,11 @@ namespace App\Domain\SourceManagement;
use Doctrine\Common\Collections\Collection;
use App\Entity\Source\SourceInterface;
/**
* Offers to get all memberships of a source.
*
* @author kevinfrantz
*/
interface SourceMembershipInformationInterface
{
/**

View File

@ -7,6 +7,11 @@ use App\Exception\AllreadySetException;
use App\Exception\AllreadyDefinedException;
use App\Exception\NotSetException;
/**
* Allows to add and remove rights of a source.
*
* @author kevinfrantz
*/
interface SourceRightManagerInterface
{
/**

View File

@ -15,7 +15,7 @@ use App\Entity\Source\SourceInterface;
*
* @todo Maybe lazy loading would be helpfull for performance
*/
final class TreeSourceService extends AbstractSourceService implements TreeSourceServiceInterface
final class TreeSourceInformation implements TreeSourceInformationInterface
{
/**
* @var TreeCollectionSourceInterface
@ -36,6 +36,9 @@ final class TreeSourceService extends AbstractSourceService implements TreeSourc
*/
private $leaves;
/**
* @param TreeCollectionSource $source
*/
public function __construct(TreeCollectionSource $source)
{
$this->source = $source;
@ -44,6 +47,11 @@ final class TreeSourceService extends AbstractSourceService implements TreeSourc
$this->basicSort();
}
/**
* @param SourceInterface $member
*
* @return bool
*/
private function sortMember(SourceInterface $member): bool
{
if ($member instanceof TreeCollectionSource) {
@ -60,6 +68,11 @@ final class TreeSourceService extends AbstractSourceService implements TreeSourc
}
}
/**
* {@inheritdoc}
*
* @see \App\Domain\SourceManagement\TreeSourceInformationInterface::getBranches()
*/
public function getBranches(): Collection
{
return $this->branches;
@ -70,7 +83,7 @@ final class TreeSourceService extends AbstractSourceService implements TreeSourc
* @todo Remove the getAllBranches use inside the function.
* {@inheritdoc}
*
* @see \App\Domain\SourceManagement\TreeSourceServiceInterface::getAllBranches()
* @see \App\Domain\SourceManagement\TreeSourceInformationInterface::getAllBranches()
*/
public function getAllBranches(): Collection
{
@ -82,6 +95,10 @@ final class TreeSourceService extends AbstractSourceService implements TreeSourc
return $allBranches;
}
/**
* @param TreeCollectionSourceInterface $branch
* @param ArrayCollection $allBranches
*/
private function itterateOverBranch(TreeCollectionSourceInterface $branch, ArrayCollection $allBranches): void
{
foreach ((new self($branch))->getBranches() as $branchBranch) {
@ -94,11 +111,21 @@ final class TreeSourceService extends AbstractSourceService implements TreeSourc
}
}
/**
* {@inheritdoc}
*
* @see \App\Domain\SourceManagement\TreeSourceInformationInterface::getLeaves()
*/
public function getLeaves(): Collection
{
return $this->leaves;
}
/**
* {@inheritdoc}
*
* @see \App\Domain\SourceManagement\TreeSourceInformationInterface::getAllLeaves()
*/
public function getAllLeaves(): Collection
{
$leaves = new ArrayCollection($this->getLeaves()->toArray());

View File

@ -4,7 +4,12 @@ namespace App\Domain\SourceManagement;
use Doctrine\Common\Collections\Collection;
interface TreeSourceServiceInterface
/**
* Allows to get branches and leaves of a tree.
*
* @author kevinfrantz
*/
interface TreeSourceInformationInterface
{
/**
* Delivers the branches of the actual tree back.

View File

@ -22,6 +22,8 @@ interface TemplatePathInformationInterface extends ReloadTypeInterface
public function getAtomTemplatePath(): string;
/**
* @todo Check if this is really needed. Otherwise remove it!
*
* @see RESTResponseType::$choices
*
* @return string Type of the template

View File

@ -4,6 +4,11 @@ namespace App\Domain\UserManagement;
use App\Entity\UserInterface;
/**
* Offers based on an user variable a user with a source.
*
* @author kevinfrantz
*/
interface UserSourceDirectorInterface
{
/**

View File

@ -3,6 +3,10 @@
namespace App\Domain\UserManagement;
/**
* Offers UserSourceDirector to be used as a Service.
*
* @see UserSourceDirector
*
* @author kevinfrantz
*/
interface UserSourceDirectorServiceInterface extends UserSourceDirectorInterface

View File

@ -3,8 +3,8 @@
namespace Unit\Domain\LawManagement;
use PHPUnit\Framework\TestCase;
use App\Domain\LawManagement\LawPermissionCheckerService;
use App\Domain\LawManagement\LawPermissionCheckerServiceInterface;
use App\Domain\LawManagement\LawPermissionChecker;
use App\Domain\LawManagement\LawPermissionCheckerInterface;
use App\Entity\Source\SourceInterface;
use App\Entity\Meta\Right;
use App\DBAL\Types\Meta\Right\LayerType;
@ -22,7 +22,7 @@ use App\Entity\Source\PureSource;
class LawPermissionCheckerTest extends TestCase
{
/**
* @var LawPermissionCheckerServiceInterface The service which checks the law
* @var LawPermissionCheckerInterface The service which checks the law
*/
private $lawPermissionChecker;
@ -62,7 +62,7 @@ class LawPermissionCheckerTest extends TestCase
private function setLawPermissionChecker(): void
{
$this->lawPermissionChecker = new LawPermissionCheckerService($this->law);
$this->lawPermissionChecker = new LawPermissionChecker($this->law);
}
private function setLawDummy(): void

View File

@ -6,13 +6,13 @@ use PHPUnit\Framework\TestCase;
use App\Entity\Source\Complex\Collection\TreeCollectionSource;
use App\Entity\Source\SourceInterface;
use Doctrine\Common\Collections\ArrayCollection;
use App\Domain\SourceManagement\TreeSourceServiceInterface;
use App\Domain\SourceManagement\TreeSourceService;
use App\Domain\SourceManagement\TreeSourceInformationInterface;
use App\Domain\SourceManagement\TreeSourceInformation;
class TreeSourceServiceTest extends TestCase
class TreeSourceInformationTest extends TestCase
{
/**
* @var TreeSourceServiceInterface
* @var TreeSourceInformationInterface
*/
protected $treeService;
@ -31,7 +31,7 @@ class TreeSourceServiceTest extends TestCase
$tree2->setCollection(new ArrayCollection([$leave3, $leave4, $tree5, $leave5]));
$collection = new ArrayCollection([$tree2, $tree3, $leave1, $leave2, $tree4, $tree1]);
$tree1->setCollection($collection);
$this->treeService = new TreeSourceService($tree1);
$this->treeService = new TreeSourceInformation($tree1);
}
public function testGetLeaves(): void