Renamed the base DBElement classes to AbstractDBElement to comply with symfony recommendations.

This commit is contained in:
Jan Böhmer 2020-02-01 19:48:07 +01:00
parent da72f5b3ec
commit 594c694ee0
62 changed files with 203 additions and 203 deletions

View file

@ -24,7 +24,7 @@ declare(strict_types=1);
namespace App\Repository;
use App\Entity\Base\DBElement;
use App\Entity\Base\AbstractDBElement;
use App\Entity\LogSystem\AbstractLogEntry;
use Doctrine\ORM\EntityRepository;
@ -33,7 +33,7 @@ class LogEntryRepository extends EntityRepository
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null)
{
//Emulate a target element criteria by splitting it manually in the needed criterias
if (isset($criteria['target']) && $criteria['target'] instanceof DBElement) {
if (isset($criteria['target']) && $criteria['target'] instanceof AbstractDBElement) {
$element = $criteria['target'];
$criteria['target_id'] = $element;
$criteria['target_type'] = AbstractLogEntry::targetTypeClassToID(get_class($element));
@ -46,14 +46,14 @@ class LogEntryRepository extends EntityRepository
/**
* Find log entries associated with the given element (the history of the element).
*
* @param DBElement $element The element for which the history should be generated
* @param AbstractDBElement $element The element for which the history should be generated
* @param string $order By default newest entries are shown first. Change this to ASC to show oldest entries first.
* @param null $limit
* @param null $offset
*
* @return AbstractLogEntry[]
*/
public function getElementHistory(DBElement $element, $order = 'DESC', $limit = null, $offset = null)
public function getElementHistory(AbstractDBElement $element, $order = 'DESC', $limit = null, $offset = null)
{
return $this->findBy(['element' => $element], ['timestamp' => $order], $limit, $offset);
}
@ -75,10 +75,10 @@ class LogEntryRepository extends EntityRepository
/**
* Gets the target element associated with the logentry.
*
* @return DBElement|null Returns the associated DBElement or null if the log either has no target or the element
* @return AbstractDBElement|null Returns the associated DBElement or null if the log either has no target or the element
* was deleted from DB.
*/
public function getTargetElement(AbstractLogEntry $logEntry): ?DBElement
public function getTargetElement(AbstractLogEntry $logEntry): ?AbstractDBElement
{
$class = $logEntry->getTargetClass();
$id = $logEntry->getTargetID();

View file

@ -24,7 +24,7 @@ declare(strict_types=1);
namespace App\Repository;
use App\Entity\Base\NamedDBElement;
use App\Entity\Base\AbstractNamedDBElement;
use App\Helpers\Trees\TreeViewNode;
use Doctrine\ORM\EntityRepository;
@ -42,7 +42,7 @@ class NamedDBElementRepository extends EntityRepository
$entities = $this->findBy([], ['name' => 'ASC']);
foreach ($entities as $entity) {
/** @var NamedDBElement $entity */
/** @var AbstractNamedDBElement $entity */
$node = new TreeViewNode($entity->getName(), null, null);
$node->setId($entity->getID());
$result[] = $node;

View file

@ -24,7 +24,7 @@ declare(strict_types=1);
namespace App\Repository;
use App\Entity\Base\StructuralDBElement;
use App\Entity\Base\AbstractStructuralDBElement;
use App\Helpers\Trees\StructuralDBElementIterator;
use App\Helpers\Trees\TreeViewNode;
use RecursiveIteratorIterator;
@ -34,7 +34,7 @@ class StructuralDBElementRepository extends NamedDBElementRepository
/**
* Finds all nodes without a parent node. They are our root nodes.
*
* @return StructuralDBElement[]
* @return AbstractStructuralDBElement[]
*/
public function findRootNodes(): array
{
@ -45,17 +45,17 @@ class StructuralDBElementRepository extends NamedDBElementRepository
* Gets a tree of TreeViewNode elements. The root elements has $parent as parent.
* The treeview is generic, that means the href are null and ID values are set.
*
* @param StructuralDBElement|null $parent The parent the root elements should have.
* @param AbstractStructuralDBElement|null $parent The parent the root elements should have.
*
* @return TreeViewNode[]
*/
public function getGenericNodeTree(?StructuralDBElement $parent = null): array
public function getGenericNodeTree(?AbstractStructuralDBElement $parent = null): array
{
$result = [];
$entities = $this->findBy(['parent' => $parent], ['name' => 'ASC']);
foreach ($entities as $entity) {
/** @var StructuralDBElement $entity */
/** @var AbstractStructuralDBElement $entity */
//Make a recursive call to find all children nodes
$children = $this->getGenericNodeTree($entity);
$node = new TreeViewNode($entity->getName(), null, $children);
@ -70,11 +70,11 @@ class StructuralDBElementRepository extends NamedDBElementRepository
/**
* Gets a flattened hierarchical tree. Useful for generating option lists.
*
* @param StructuralDBElement|null $parent This entity will be used as root element. Set to null, to use global root
* @param AbstractStructuralDBElement|null $parent This entity will be used as root element. Set to null, to use global root
*
* @return StructuralDBElement[] A flattened list containing the tree elements.
* @return AbstractStructuralDBElement[] A flattened list containing the tree elements.
*/
public function toNodesList(?StructuralDBElement $parent = null): array
public function toNodesList(?AbstractStructuralDBElement $parent = null): array
{
$result = [];