mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-26 19:58:53 +02:00
Use enums for LabelOptions
This commit is contained in:
parent
485b35fbd4
commit
71cd4057a7
23 changed files with 329 additions and 157 deletions
|
@ -42,6 +42,7 @@ declare(strict_types=1);
|
|||
namespace App\Services\LabelSystem;
|
||||
|
||||
use App\Entity\LabelSystem\LabelProfile;
|
||||
use App\Entity\LabelSystem\LabelSupportedElement;
|
||||
use App\Repository\LabelProfileRepository;
|
||||
use App\Services\UserSystem\UserCacheKeyGenerator;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
@ -54,10 +55,20 @@ final class LabelProfileDropdownHelper
|
|||
{
|
||||
}
|
||||
|
||||
public function getDropdownProfiles(string $type): array
|
||||
/**
|
||||
* Return all label profiles for the given supported element type
|
||||
* @param LabelSupportedElement|string $type
|
||||
* @return array
|
||||
*/
|
||||
public function getDropdownProfiles(LabelSupportedElement|string $type): array
|
||||
{
|
||||
//Useful for the twig templates, where we use the string representation of the enum
|
||||
if (is_string($type)) {
|
||||
$type = LabelSupportedElement::from($type);
|
||||
}
|
||||
|
||||
$secure_class_name = str_replace('\\', '_', LabelProfile::class);
|
||||
$key = 'profile_dropdown_'.$this->keyGenerator->generateKey().'_'.$secure_class_name.'_'.$type;
|
||||
$key = 'profile_dropdown_'.$this->keyGenerator->generateKey().'_'.$secure_class_name.'_'.$type->value;
|
||||
|
||||
/** @var LabelProfileRepository $repo */
|
||||
$repo = $this->entityManager->getRepository(LabelProfile::class);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue