Use imports instead of FQNs

This commit is contained in:
Jan Böhmer 2023-06-11 14:55:06 +02:00
parent f63b6d7207
commit 5629215ce4
179 changed files with 792 additions and 597 deletions

View file

@ -49,7 +49,7 @@ class NodesListBuilder
*/
public function typeToNodesList(string $class_name, ?AbstractStructuralDBElement $parent = null): array
{
$parent_id = $parent instanceof \App\Entity\Base\AbstractStructuralDBElement ? $parent->getID() : '0';
$parent_id = $parent instanceof AbstractStructuralDBElement ? $parent->getID() : '0';
// Backslashes are not allowed in cache keys
$secure_class_name = str_replace('\\', '_', $class_name);
$key = 'list_'.$this->keyGenerator->generateKey().'_'.$secure_class_name.$parent_id;

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Services\Trees;
use Symfony\Bundle\SecurityBundle\Security;
use App\Entity\Attachments\AttachmentType;
use App\Entity\ProjectSystem\Project;
use App\Entity\LabelSystem\LabelProfile;
@ -38,7 +39,6 @@ use App\Entity\UserSystem\User;
use App\Helpers\Trees\TreeViewNode;
use App\Services\UserSystem\UserCacheKeyGenerator;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Cache\ItemInterface;
use Symfony\Contracts\Cache\TagAwareCacheInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
@ -49,7 +49,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
*/
class ToolsTreeBuilder
{
public function __construct(protected TranslatorInterface $translator, protected UrlGeneratorInterface $urlGenerator, protected TagAwareCacheInterface $cache, protected UserCacheKeyGenerator $keyGenerator, protected \Symfony\Bundle\SecurityBundle\Security $security)
public function __construct(protected TranslatorInterface $translator, protected UrlGeneratorInterface $urlGenerator, protected TagAwareCacheInterface $cache, protected UserCacheKeyGenerator $keyGenerator, protected Security $security)
{
}

View file

@ -74,7 +74,7 @@ class TreeViewGenerator
$href = $this->urlGenerator->createURL(new $class());
$new_node = new TreeViewNode($this->translator->trans('entity.tree.new'), $href);
//When the id of the selected element is null, then we have a new element, and we need to select "new" node
if (!$selectedElement instanceof \App\Entity\Base\AbstractDBElement || null === $selectedElement->getID()) {
if (!$selectedElement instanceof AbstractDBElement || null === $selectedElement->getID()) {
$new_node->setSelected(true);
}
$head[] = $new_node;
@ -98,7 +98,7 @@ class TreeViewGenerator
$recursiveIterator = new RecursiveIteratorIterator($treeIterator, RecursiveIteratorIterator::SELF_FIRST);
foreach ($recursiveIterator as $item) {
/** @var TreeViewNode $item */
if ($selectedElement instanceof \App\Entity\Base\AbstractDBElement && $item->getId() === $selectedElement->getID()) {
if ($selectedElement instanceof AbstractDBElement && $item->getId() === $selectedElement->getID()) {
$item->setSelected(true);
}
@ -184,7 +184,7 @@ class TreeViewGenerator
if (!is_a($class, AbstractNamedDBElement::class, true)) {
throw new InvalidArgumentException('$class must be a class string that implements StructuralDBElement or NamedDBElement!');
}
if ($parent instanceof \App\Entity\Base\AbstractStructuralDBElement && !$parent instanceof $class) {
if ($parent instanceof AbstractStructuralDBElement && !$parent instanceof $class) {
throw new InvalidArgumentException('$parent must be of the type $class!');
}
@ -192,7 +192,7 @@ class TreeViewGenerator
$repo = $this->em->getRepository($class);
//If we just want a part of a tree, don't cache it
if ($parent instanceof \App\Entity\Base\AbstractStructuralDBElement) {
if ($parent instanceof AbstractStructuralDBElement) {
return $repo->getGenericNodeTree($parent);
}