Applied rector rules up to symfony 6.2

This commit is contained in:
Jan Böhmer 2023-05-28 01:21:05 +02:00
parent 88ea920dfb
commit a43af180a7
145 changed files with 563 additions and 889 deletions

View file

@ -40,9 +40,10 @@ use function count;
use const DIRECTORY_SEPARATOR;
#[\Symfony\Component\Console\Attribute\AsCommand('partdb:attachments:clean-unused|app:clean-attachments', 'Lists (and deletes if wanted) attachments files that are not used anymore (abandoned files).')]
class CleanAttachmentsCommand extends Command
{
protected static $defaultName = 'partdb:attachments:clean-unused|app:clean-attachments';
protected static $defaultDescription = 'Lists (and deletes if wanted) attachments files that are not used anymore (abandoned files).';
protected AttachmentManager $attachment_helper;
protected AttachmentReverseSearch $reverseSearch;
@ -60,10 +61,8 @@ class CleanAttachmentsCommand extends Command
protected function configure(): void
{
$this
->setDescription('Lists (and deletes if wanted) attachments files that are not used anymore (abandoned files).')
->setHelp('This command allows to find all files in the media folder which are not associated with an attachment anymore.'.
' These files are not needed and can eventually deleted.');
$this->setHelp('This command allows to find all files in the media folder which are not associated with an attachment anymore.'.
' These files are not needed and can eventually deleted.');
}
protected function execute(InputInterface $input, OutputInterface $output): int
@ -108,7 +107,7 @@ class CleanAttachmentsCommand extends Command
if (!$continue) {
//We are finished here, when no files should be deleted
return 0;
return \Symfony\Component\Console\Command\Command::SUCCESS;
}
//Delete the files
@ -121,7 +120,7 @@ class CleanAttachmentsCommand extends Command
$io->success('No abandoned files found.');
}
return 0;
return \Symfony\Component\Console\Command\Command::SUCCESS;
}
/**

View file

@ -16,11 +16,9 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
#[\Symfony\Component\Console\Attribute\AsCommand('partdb:backup', 'Backup the files and the database of Part-DB')]
class BackupCommand extends Command
{
protected static $defaultName = 'partdb:backup';
protected static $defaultDescription = 'Backup the files and the database of Part-DB';
private string $project_dir;
private EntityManagerInterface $entityManager;

View file

@ -27,9 +27,10 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
#[\Symfony\Component\Console\Attribute\AsCommand('partdb:check-requirements', 'Checks if the requirements Part-DB needs or recommends are fulfilled.')]
class CheckRequirementsCommand extends Command
{
protected static $defaultName = 'partdb:check-requirements';
protected static $defaultDescription = 'Checks if the requirements Part-DB needs or recommends are fulfilled.';
protected ContainerBagInterface $params;
@ -41,9 +42,7 @@ class CheckRequirementsCommand extends Command
protected function configure(): void
{
$this
->setDescription('Checks if the requirements Part-DB needs or recommends are fulfilled.')
->addOption('only_issues', 'i', InputOption::VALUE_NONE, 'Only show issues, not success messages.')
$this->addOption('only_issues', 'i', InputOption::VALUE_NONE, 'Only show issues, not success messages.')
;
}

View file

@ -35,9 +35,10 @@ use Symfony\Component\Console\Style\SymfonyStyle;
use function count;
use function strlen;
#[\Symfony\Component\Console\Attribute\AsCommand('partdb:currencies:update-exchange-rates|partdb:update-exchange-rates|app:update-exchange-rates', 'Updates the currency exchange rates.')]
class UpdateExchangeRatesCommand extends Command
{
protected static $defaultName = 'partdb:currencies:update-exchange-rates|partdb:update-exchange-rates|app:update-exchange-rates';
protected static $defaultDescription = 'Updates the currency exchange rates.';
protected string $base_current;
protected EntityManagerInterface $em;
@ -56,9 +57,7 @@ class UpdateExchangeRatesCommand extends Command
protected function configure(): void
{
$this
->setDescription('Updates the currency exchange rates.')
->addArgument('iso_code', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'The ISO Codes of the currencies that should be updated.');
$this->addArgument('iso_code', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'The ISO Codes of the currencies that should be updated.');
}
protected function execute(InputInterface $input, OutputInterface $output): int
@ -69,7 +68,7 @@ class UpdateExchangeRatesCommand extends Command
if (3 !== strlen($this->base_current)) {
$io->error('Chosen Base current is not valid. Check your settings!');
return 1;
return \Symfony\Component\Console\Command\Command::FAILURE;
}
$io->note('Update currency exchange rates with base currency: '.$this->base_current);
@ -106,6 +105,6 @@ class UpdateExchangeRatesCommand extends Command
$io->success(sprintf('%d (of %d) currency exchange rates were updated.', $success_counter, count($candidates)));
return 0;
return \Symfony\Component\Console\Command\Command::SUCCESS;
}
}

View file

@ -36,9 +36,10 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Contracts\Translation\TranslatorInterface;
#[\Symfony\Component\Console\Attribute\AsCommand('partdb:logs:show|app:show-logs', 'List the last event log entries.')]
class ShowEventLogCommand extends Command
{
protected static $defaultName = 'partdb:logs:show|app:show-logs';
protected static $defaultDescription = 'List the last event log entries.';
protected EntityManagerInterface $entityManager;
protected TranslatorInterface $translator;
protected ElementTypeNameGenerator $elementTypeNameGenerator;
@ -74,7 +75,7 @@ class ShowEventLogCommand extends Command
if ($page > $max_page && $max_page > 0) {
$io->error("There is no page ${page}! The maximum page is ${max_page}.");
return 1;
return \Symfony\Component\Console\Command\Command::FAILURE;
}
$io->note("There are a total of ${total_count} log entries in the DB.");
@ -84,21 +85,19 @@ class ShowEventLogCommand extends Command
$this->showPage($output, $desc, $limit, $page, $max_page, $showExtra);
if ($onePage) {
return 0;
return \Symfony\Component\Console\Command\Command::SUCCESS;
}
$continue = $io->confirm('Do you want to show the next page?');
++$page;
}
return 0;
return \Symfony\Component\Console\Command\Command::SUCCESS;
}
protected function configure(): void
{
$this
->setDescription('List the last event log entries.')
->addOption('count', 'c', InputOption::VALUE_REQUIRED, 'How many log entries should be shown per page.', 50)
$this->addOption('count', 'c', InputOption::VALUE_REQUIRED, 'How many log entries should be shown per page.', 50)
->addOption('oldest_first', null, InputOption::VALUE_NONE, 'Show older entries first.')
->addOption('page', 'p', InputOption::VALUE_REQUIRED, 'Which page should be shown?', 1)
->addOption('onePage', null, InputOption::VALUE_NONE, 'Show only one page (dont ask to go to next).')

View file

@ -47,6 +47,7 @@ use function count;
/**
* This command converts the BBCode used by old Part-DB versions (<1.0), to the current used Markdown format.
*/
#[\Symfony\Component\Console\Attribute\AsCommand('partdb:migrations:convert-bbcode|app:convert-bbcode', 'Converts BBCode used in old Part-DB versions to newly used Markdown')]
class ConvertBBCodeCommand extends Command
{
/**
@ -58,7 +59,7 @@ class ConvertBBCodeCommand extends Command
*/
protected const BBCODE_REGEX = '/\\[.+\\].*\\[\\/.+\\]/';
protected static $defaultName = 'partdb:migrations:convert-bbcode|app:convert-bbcode';
protected static $defaultDescription = 'Converts BBCode used in old Part-DB versions to newly used Markdown';
protected EntityManagerInterface $em;
protected PropertyAccessorInterface $propertyAccessor;
@ -76,9 +77,7 @@ class ConvertBBCodeCommand extends Command
protected function configure(): void
{
$this
->setDescription('Converts BBCode used in old Part-DB versions to newly used Markdown')
->setHelp('Older versions of Part-DB (<1.0) used BBCode for rich text formatting.
$this->setHelp('Older versions of Part-DB (<1.0) used BBCode for rich text formatting.
Part-DB now uses Markdown which offers more features but is incompatible with BBCode.
When you upgrade from an pre 1.0 version you have to run this command to convert your comment fields');
@ -168,6 +167,6 @@ class ConvertBBCodeCommand extends Command
$io->success('Changes saved to DB successfully!');
}
return 0;
return \Symfony\Component\Console\Command\Command::SUCCESS;
}
}

View file

@ -33,10 +33,11 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
#[\Symfony\Component\Console\Attribute\AsCommand('partdb:migrations:import-partkeepr', 'Import a PartKeepr database XML dump into Part-DB')]
class ImportPartKeeprCommand extends Command
{
protected static $defaultName = 'partdb:migrations:import-partkeepr';
protected static $defaultDescription = 'Import a PartKeepr database XML dump into Part-DB';
protected EntityManagerInterface $em;
protected MySQLDumpXMLConverter $xml_converter;
@ -60,7 +61,6 @@ class ImportPartKeeprCommand extends Command
protected function configure()
{
$this->setDescription('Import a PartKeepr database XML dump into Part-DB');
$this->setHelp('This command allows you to import a PartKeepr database exported by mysqldump as XML file into Part-DB');
$this->addArgument('file', InputArgument::REQUIRED, 'The file to which should be imported.');
@ -100,7 +100,7 @@ class ImportPartKeeprCommand extends Command
if (!$this->importHelper->checkVersion($data)) {
$db_version = $this->importHelper->getDatabaseSchemaVersion($data);
$io->error('The version of the imported database is not supported! (Version: '.$db_version.')');
return 1;
return \Symfony\Component\Console\Command\Command::FAILURE;
}
//Import the mandatory data
@ -118,7 +118,7 @@ class ImportPartKeeprCommand extends Command
$io->success('Imported '.$count.' users.');
}
return 0;
return \Symfony\Component\Console\Command\Command::SUCCESS;
}
private function doImport(SymfonyStyle $io, array $data): void

View file

@ -30,9 +30,10 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
#[\Symfony\Component\Console\Attribute\AsCommand('partdb:user:convert-to-saml-user|partdb:users:convert-to-saml-user', 'Converts a local user to a SAML user (and vice versa)')]
class ConvertToSAMLUserCommand extends Command
{
protected static $defaultName = 'partdb:user:convert-to-saml-user|partdb:users:convert-to-saml-user';
protected static $defaultDescription = 'Converts a local user to a SAML user (and vice versa)';
protected EntityManagerInterface $entityManager;
protected bool $saml_enabled;
@ -46,9 +47,7 @@ class ConvertToSAMLUserCommand extends Command
protected function configure(): void
{
$this
->setDescription('Converts a local user to a SAML user (and vice versa)')
->setHelp('This converts a local user, which can login via the login form, to a SAML user, which can only login via SAML. This is useful if you want to migrate from a local user system to a SAML user system.')
$this->setHelp('This converts a local user, which can login via the login form, to a SAML user, which can only login via SAML. This is useful if you want to migrate from a local user system to a SAML user system.')
->addArgument('user', InputArgument::REQUIRED, 'The username (or email) of the user')
->addOption('to-local', null, InputOption::VALUE_NONE, 'Converts a SAML user to a local user')
;
@ -70,7 +69,7 @@ class ConvertToSAMLUserCommand extends Command
if (!$user) {
$io->error('User not found!');
return 1;
return \Symfony\Component\Console\Command\Command::FAILURE;
}
$io->info('User found: '.$user->getFullName(true) . ': '.$user->getEmail().' [ID: ' . $user->getID() . ']');

View file

@ -34,9 +34,10 @@ use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
#[\Symfony\Component\Console\Attribute\AsCommand('partdb:users:set-password|app:set-password|users:set-password|partdb:user:set-password', 'Sets the password of a user')]
class SetPasswordCommand extends Command
{
protected static $defaultName = 'partdb:users:set-password|app:set-password|users:set-password|partdb:user:set-password';
protected static $defaultDescription = 'Sets the password of a user';
protected EntityManagerInterface $entityManager;
protected UserPasswordHasherInterface $encoder;
@ -53,9 +54,7 @@ class SetPasswordCommand extends Command
protected function configure(): void
{
$this
->setDescription('Sets the password of a user')
->setHelp('This password allows you to set the password of a user, without knowing the old password.')
$this->setHelp('This password allows you to set the password of a user, without knowing the old password.')
->addArgument('user', InputArgument::REQUIRED, 'The username or email of the user')
;
}
@ -70,14 +69,14 @@ class SetPasswordCommand extends Command
if (!$user) {
$io->error(sprintf('No user with the given username %s found in the database!', $user_name));
return 1;
return \Symfony\Component\Console\Command\Command::FAILURE;
}
$io->note('User found!');
if ($user->isSamlUser()) {
$io->error('This user is a SAML user, so you can not change the password!');
return 1;
return \Symfony\Component\Console\Command\Command::FAILURE;
}
$proceed = $io->confirm(
@ -85,7 +84,7 @@ class SetPasswordCommand extends Command
$user->getFullName(true), $user->getID()));
if (!$proceed) {
return 1;
return \Symfony\Component\Console\Command\Command::FAILURE;
}
$success = false;
@ -116,6 +115,6 @@ class SetPasswordCommand extends Command
$security_event = new SecurityEvent($user);
$this->eventDispatcher->dispatch($security_event, SecurityEvents::PASSWORD_CHANGED);
return 0;
return \Symfony\Component\Console\Command\Command::SUCCESS;
}
}

View file

@ -31,11 +31,9 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
#[\Symfony\Component\Console\Attribute\AsCommand('partdb:users:upgrade-permissions-schema', '(Manually) upgrades the permissions schema of all users to the latest version.')]
final class UpgradePermissionsSchemaCommand extends Command
{
protected static $defaultName = 'partdb:users:upgrade-permissions-schema';
protected static $defaultDescription = '(Manually) upgrades the permissions schema of all users to the latest version.';
private PermissionSchemaUpdater $permissionSchemaUpdater;
private EntityManagerInterface $em;
private EventCommentHelper $eventCommentHelper;
@ -84,7 +82,7 @@ final class UpgradePermissionsSchemaCommand extends Command
if (empty($groups_to_upgrade) && empty($users_to_upgrade)) {
$io->success('All users and group permissions schemas are up-to-date. No update needed.');
return 0;
return \Symfony\Component\Console\Command\Command::SUCCESS;
}
//List all users and groups that need an update
@ -100,7 +98,7 @@ final class UpgradePermissionsSchemaCommand extends Command
if(!$io->confirm('Continue with the update?', false)) {
$io->warning('Update aborted.');
return 0;
return \Symfony\Component\Console\Command\Command::SUCCESS;
}
//Update all users and groups

View file

@ -29,9 +29,10 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
#[\Symfony\Component\Console\Attribute\AsCommand('partdb:users:enable|partdb:user:enable', 'Enables/Disable the login of one or more users')]
class UserEnableCommand extends Command
{
protected static $defaultName = 'partdb:users:enable|partdb:user:enable';
protected static $defaultDescription = 'Enables/Disable the login of one or more users';
protected EntityManagerInterface $entityManager;
@ -44,9 +45,7 @@ class UserEnableCommand extends Command
protected function configure(): void
{
$this
->setDescription('Enables/Disable the login of one or more users')
->setHelp('This allows you to allow or prevent the login of certain user. Use the --disable option to disable the login for the given users')
$this->setHelp('This allows you to allow or prevent the login of certain user. Use the --disable option to disable the login for the given users')
->addArgument('users', InputArgument::IS_ARRAY, 'The usernames of the users to use')
->addOption('all', 'a', InputOption::VALUE_NONE, 'Enable/Disable all users')
->addOption('disable', 'd', InputOption::VALUE_NONE, 'Disable the login of the given users')

View file

@ -28,9 +28,10 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
#[\Symfony\Component\Console\Attribute\AsCommand('partdb:users:list|users:list', 'Lists all users')]
class UserListCommand extends Command
{
protected static $defaultName = 'partdb:users:list|users:list';
protected static $defaultDescription = 'Lists all users';
protected EntityManagerInterface $entityManager;
@ -43,9 +44,7 @@ class UserListCommand extends Command
protected function configure(): void
{
$this
->setDescription('Lists all users')
->setHelp('This command lists all users in the database.')
$this->setHelp('This command lists all users in the database.')
->addOption('local', 'l', null, 'Only list local users')
->addOption('saml', 's', null, 'Only list SAML users')
;

View file

@ -34,11 +34,9 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Contracts\Translation\TranslatorInterface;
#[\Symfony\Component\Console\Attribute\AsCommand('partdb:users:permissions|partdb:user:permissions', 'View and edit the permissions of a given user')]
class UsersPermissionsCommand extends Command
{
protected static $defaultName = 'partdb:users:permissions|partdb:user:permissions';
protected static $defaultDescription = 'View and edit the permissions of a given user';
protected EntityManagerInterface $entityManager;
protected UserRepository $userRepository;
protected PermissionManager $permissionResolver;

View file

@ -27,9 +27,10 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
#[\Symfony\Component\Console\Attribute\AsCommand('partdb:version|app:version', 'Shows the currently installed version of Part-DB.')]
class VersionCommand extends Command
{
protected static $defaultName = 'partdb:version|app:version';
protected static $defaultDescription = 'Shows the currently installed version of Part-DB.';
protected VersionManagerInterface $versionManager;
protected GitVersionInfo $gitVersionInfo;
@ -43,9 +44,6 @@ class VersionCommand extends Command
protected function configure(): void
{
$this
->setDescription('Shows the currently installed version of Part-DB.')
;
}
protected function execute(InputInterface $input, OutputInterface $output): int
@ -66,6 +64,6 @@ class VersionCommand extends Command
$io->info('OS: '. php_uname());
$io->info('PHP extension: '. implode(', ', get_loaded_extensions()));
return 0;
return \Symfony\Component\Console\Command\Command::SUCCESS;
}
}

View file

@ -36,9 +36,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/attachment_type")
*/
#[Route(path: '/attachment_type')]
class AttachmentTypeController extends BaseAdminController
{
protected string $entity_class = AttachmentType::class;
@ -48,44 +46,34 @@ class AttachmentTypeController extends BaseAdminController
protected string $attachment_class = AttachmentTypeAttachment::class;
protected ?string $parameter_class = AttachmentTypeParameter::class;
/**
* @Route("/{id}", name="attachment_type_delete", methods={"DELETE"})
*/
#[Route(path: '/{id}', name: 'attachment_type_delete', methods: ['DELETE'])]
public function delete(Request $request, AttachmentType $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
{
return $this->_delete($request, $entity, $recursionHelper);
}
/**
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="attachment_type_edit")
* @Route("/{id}", requirements={"id"="\d+"})
*/
#[Route(path: '/{id}/edit/{timestamp}', requirements: ['id' => '\d+'], name: 'attachment_type_edit')]
#[Route(path: '/{id}', requirements: ['id' => '\d+'])]
public function edit(AttachmentType $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
{
return $this->_edit($entity, $request, $em, $timestamp);
}
/**
* @Route("/new", name="attachment_type_new")
* @Route("/{id}/clone", name="attachment_type_clone")
* @Route("/")
*/
#[Route(path: '/new', name: 'attachment_type_new')]
#[Route(path: '/{id}/clone', name: 'attachment_type_clone')]
#[Route(path: '/')]
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer, ?AttachmentType $entity = null): Response
{
return $this->_new($request, $em, $importer, $entity);
}
/**
* @Route("/export", name="attachment_type_export_all")
*/
#[Route(path: '/export', name: 'attachment_type_export_all')]
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
{
return $this->_exportAll($em, $exporter, $request);
}
/**
* @Route("/{id}/export", name="attachment_type_export")
*/
#[Route(path: '/{id}/export', name: 'attachment_type_export')]
public function exportEntity(AttachmentType $entity, EntityExporter $exporter, Request $request): Response
{
return $this->_exportEntity($entity, $exporter, $request);

View file

@ -245,7 +245,7 @@ abstract class BaseAdminController extends AbstractController
/** @var AbstractPartsContainingRepository $repo */
$repo = $this->entityManager->getRepository($this->entity_class);
return $this->renderForm($this->twig_template, [
return $this->render($this->twig_template, [
'entity' => $entity,
'form' => $form,
'route_base' => $this->route_base,
@ -402,7 +402,7 @@ abstract class BaseAdminController extends AbstractController
}
ret:
return $this->renderForm($this->twig_template, [
return $this->render($this->twig_template, [
'entity' => $new_entity,
'form' => $form,
'import_form' => $import_form,

View file

@ -35,9 +35,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/category")
*/
#[Route(path: '/category')]
class CategoryController extends BaseAdminController
{
protected string $entity_class = Category::class;
@ -47,44 +45,34 @@ class CategoryController extends BaseAdminController
protected string $attachment_class = CategoryAttachment::class;
protected ?string $parameter_class = CategoryParameter::class;
/**
* @Route("/{id}", name="category_delete", methods={"DELETE"})
*/
#[Route(path: '/{id}', name: 'category_delete', methods: ['DELETE'])]
public function delete(Request $request, Category $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
{
return $this->_delete($request, $entity, $recursionHelper);
}
/**
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="category_edit")
* @Route("/{id}", requirements={"id"="\d+"})
*/
#[Route(path: '/{id}/edit/{timestamp}', requirements: ['id' => '\d+'], name: 'category_edit')]
#[Route(path: '/{id}', requirements: ['id' => '\d+'])]
public function edit(Category $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
{
return $this->_edit($entity, $request, $em, $timestamp);
}
/**
* @Route("/new", name="category_new")
* @Route("/{id}/clone", name="category_clone")
* @Route("/")
*/
#[Route(path: '/new', name: 'category_new')]
#[Route(path: '/{id}/clone', name: 'category_clone')]
#[Route(path: '/')]
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer, ?Category $entity = null): Response
{
return $this->_new($request, $em, $importer, $entity);
}
/**
* @Route("/export", name="category_export_all")
*/
#[Route(path: '/export', name: 'category_export_all')]
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
{
return $this->_exportAll($em, $exporter, $request);
}
/**
* @Route("/{id}/export", name="category_export")
*/
#[Route(path: '/{id}/export', name: 'category_export')]
public function exportEntity(Category $entity, EntityExporter $exporter, Request $request): Response
{
return $this->_exportEntity($entity, $exporter, $request);

View file

@ -52,10 +52,9 @@ use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @Route("/currency")
*
* Class CurrencyController
*/
#[Route(path: '/currency')]
class CurrencyController extends BaseAdminController
{
protected string $entity_class = Currency::class;
@ -98,9 +97,7 @@ class CurrencyController extends BaseAdminController
);
}
/**
* @Route("/{id}", name="currency_delete", methods={"DELETE"})
*/
#[Route(path: '/{id}', name: 'currency_delete', methods: ['DELETE'])]
public function delete(Request $request, Currency $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
{
return $this->_delete($request, $entity, $recursionHelper);
@ -131,36 +128,28 @@ class CurrencyController extends BaseAdminController
return true;
}
/**
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="currency_edit")
* @Route("/{id}", requirements={"id"="\d+"})
*/
#[Route(path: '/{id}/edit/{timestamp}', requirements: ['id' => '\d+'], name: 'currency_edit')]
#[Route(path: '/{id}', requirements: ['id' => '\d+'])]
public function edit(Currency $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
{
return $this->_edit($entity, $request, $em, $timestamp);
}
/**
* @Route("/new", name="currency_new")
* @Route("/{id}/clone", name="currency_clone")
* @Route("/")
*/
#[Route(path: '/new', name: 'currency_new')]
#[Route(path: '/{id}/clone', name: 'currency_clone')]
#[Route(path: '/')]
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer, ?Currency $entity = null): Response
{
return $this->_new($request, $em, $importer, $entity);
}
/**
* @Route("/export", name="currency_export_all")
*/
#[Route(path: '/export', name: 'currency_export_all')]
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
{
return $this->_exportAll($em, $exporter, $request);
}
/**
* @Route("/{id}/export", name="currency_export")
*/
#[Route(path: '/{id}/export', name: 'currency_export')]
public function exportEntity(Currency $entity, EntityExporter $exporter, Request $request): Response
{
return $this->_exportEntity($entity, $exporter, $request);

View file

@ -36,9 +36,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/footprint")
*/
#[Route(path: '/footprint')]
class FootprintController extends BaseAdminController
{
protected string $entity_class = Footprint::class;
@ -48,44 +46,34 @@ class FootprintController extends BaseAdminController
protected string $attachment_class = FootprintAttachment::class;
protected ?string $parameter_class = FootprintParameter::class;
/**
* @Route("/{id}", name="footprint_delete", methods={"DELETE"})
*/
#[Route(path: '/{id}', name: 'footprint_delete', methods: ['DELETE'])]
public function delete(Request $request, Footprint $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
{
return $this->_delete($request, $entity, $recursionHelper);
}
/**
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="footprint_edit")
* @Route("/{id}", requirements={"id"="\d+"})
*/
#[Route(path: '/{id}/edit/{timestamp}', requirements: ['id' => '\d+'], name: 'footprint_edit')]
#[Route(path: '/{id}', requirements: ['id' => '\d+'])]
public function edit(Footprint $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
{
return $this->_edit($entity, $request, $em, $timestamp);
}
/**
* @Route("/new", name="footprint_new")
* @Route("/{id}/clone", name="footprint_clone")
* @Route("/")
*/
#[Route(path: '/new', name: 'footprint_new')]
#[Route(path: '/{id}/clone', name: 'footprint_clone')]
#[Route(path: '/')]
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer, ?Footprint $entity = null): Response
{
return $this->_new($request, $em, $importer, $entity);
}
/**
* @Route("/export", name="footprint_export_all")
*/
#[Route(path: '/export', name: 'footprint_export_all')]
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
{
return $this->_exportAll($em, $exporter, $request);
}
/**
* @Route("/{id}/export", name="footprint_export")
*/
#[Route(path: '/{id}/export', name: 'footprint_export')]
public function exportEntity(AttachmentType $entity, EntityExporter $exporter, Request $request): Response
{
return $this->_exportEntity($entity, $exporter, $request);

View file

@ -35,9 +35,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/label_profile")
*/
#[Route(path: '/label_profile')]
class LabelProfileController extends BaseAdminController
{
protected string $entity_class = LabelProfile::class;
@ -48,44 +46,34 @@ class LabelProfileController extends BaseAdminController
//Just a placeholder
protected ?string $parameter_class = null;
/**
* @Route("/{id}", name="label_profile_delete", methods={"DELETE"})
*/
#[Route(path: '/{id}', name: 'label_profile_delete', methods: ['DELETE'])]
public function delete(Request $request, LabelProfile $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
{
return $this->_delete($request, $entity, $recursionHelper);
}
/**
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="label_profile_edit")
* @Route("/{id}", requirements={"id"="\d+"})
*/
#[Route(path: '/{id}/edit/{timestamp}', requirements: ['id' => '\d+'], name: 'label_profile_edit')]
#[Route(path: '/{id}', requirements: ['id' => '\d+'])]
public function edit(LabelProfile $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
{
return $this->_edit($entity, $request, $em, $timestamp);
}
/**
* @Route("/new", name="label_profile_new")
* @Route("/{id}/clone", name="label_profile_clone")
* @Route("/")
*/
#[Route(path: '/new', name: 'label_profile_new')]
#[Route(path: '/{id}/clone', name: 'label_profile_clone')]
#[Route(path: '/')]
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer, ?LabelProfile $entity = null): Response
{
return $this->_new($request, $em, $importer, $entity);
}
/**
* @Route("/export", name="label_profile_export_all")
*/
#[Route(path: '/export', name: 'label_profile_export_all')]
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
{
return $this->_exportAll($em, $exporter, $request);
}
/**
* @Route("/{id}/export", name="label_profile_export")
*/
#[Route(path: '/{id}/export', name: 'label_profile_export')]
public function exportEntity(LabelProfile $entity, EntityExporter $exporter, Request $request): Response
{
return $this->_exportEntity($entity, $exporter, $request);

View file

@ -35,9 +35,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/manufacturer")
*/
#[Route(path: '/manufacturer')]
class ManufacturerController extends BaseAdminController
{
protected string $entity_class = Manufacturer::class;
@ -48,45 +46,36 @@ class ManufacturerController extends BaseAdminController
protected ?string $parameter_class = ManufacturerParameter::class;
/**
* @Route("/{id}", name="manufacturer_delete", methods={"DELETE"})
*
* @return RedirectResponse
*/
#[Route(path: '/{id}', name: 'manufacturer_delete', methods: ['DELETE'])]
public function delete(Request $request, Manufacturer $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
{
return $this->_delete($request, $entity, $recursionHelper);
}
/**
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="manufacturer_edit")
* @Route("/{id}", requirements={"id"="\d+"})
*/
#[Route(path: '/{id}/edit/{timestamp}', requirements: ['id' => '\d+'], name: 'manufacturer_edit')]
#[Route(path: '/{id}', requirements: ['id' => '\d+'])]
public function edit(Manufacturer $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
{
return $this->_edit($entity, $request, $em, $timestamp);
}
/**
* @Route("/new", name="manufacturer_new")
* @Route("/{id}/clone", name="manufacturer_clone")
* @Route("/")
*/
#[Route(path: '/new', name: 'manufacturer_new')]
#[Route(path: '/{id}/clone', name: 'manufacturer_clone')]
#[Route(path: '/')]
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer, ?Manufacturer $entity = null): Response
{
return $this->_new($request, $em, $importer, $entity);
}
/**
* @Route("/export", name="manufacturer_export_all")
*/
#[Route(path: '/export', name: 'manufacturer_export_all')]
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
{
return $this->_exportAll($em, $exporter, $request);
}
/**
* @Route("/{id}/export", name="manufacturer_export")
*/
#[Route(path: '/{id}/export', name: 'manufacturer_export')]
public function exportEntity(Manufacturer $entity, EntityExporter $exporter, Request $request): Response
{
return $this->_exportEntity($entity, $exporter, $request);

View file

@ -36,9 +36,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/measurement_unit")
*/
#[Route(path: '/measurement_unit')]
class MeasurementUnitController extends BaseAdminController
{
protected string $entity_class = MeasurementUnit::class;
@ -48,44 +46,34 @@ class MeasurementUnitController extends BaseAdminController
protected string $attachment_class = MeasurementUnitAttachment::class;
protected ?string $parameter_class = MeasurementUnitParameter::class;
/**
* @Route("/{id}", name="measurement_unit_delete", methods={"DELETE"})
*/
#[Route(path: '/{id}', name: 'measurement_unit_delete', methods: ['DELETE'])]
public function delete(Request $request, MeasurementUnit $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
{
return $this->_delete($request, $entity, $recursionHelper);
}
/**
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="measurement_unit_edit")
* @Route("/{id}", requirements={"id"="\d+"})
*/
#[Route(path: '/{id}/edit/{timestamp}', requirements: ['id' => '\d+'], name: 'measurement_unit_edit')]
#[Route(path: '/{id}', requirements: ['id' => '\d+'])]
public function edit(MeasurementUnit $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
{
return $this->_edit($entity, $request, $em, $timestamp);
}
/**
* @Route("/new", name="measurement_unit_new")
* @Route("/{id}/clone", name="measurement_unit_clone")
* @Route("/")
*/
#[Route(path: '/new', name: 'measurement_unit_new')]
#[Route(path: '/{id}/clone', name: 'measurement_unit_clone')]
#[Route(path: '/')]
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer, ?MeasurementUnit $entity = null): Response
{
return $this->_new($request, $em, $importer, $entity);
}
/**
* @Route("/export", name="measurement_unit_export_all")
*/
#[Route(path: '/export', name: 'measurement_unit_export_all')]
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
{
return $this->_exportAll($em, $exporter, $request);
}
/**
* @Route("/{id}/export", name="measurement_unit_export")
*/
#[Route(path: '/{id}/export', name: 'measurement_unit_export')]
public function exportEntity(AttachmentType $entity, EntityExporter $exporter, Request $request): Response
{
return $this->_exportEntity($entity, $exporter, $request);

View file

@ -35,9 +35,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/project")
*/
#[Route(path: '/project')]
class ProjectAdminController extends BaseAdminController
{
protected string $entity_class = Project::class;
@ -47,44 +45,34 @@ class ProjectAdminController extends BaseAdminController
protected string $attachment_class = ProjectAttachment::class;
protected ?string $parameter_class = ProjectParameter::class;
/**
* @Route("/{id}", name="project_delete", methods={"DELETE"})
*/
#[Route(path: '/{id}', name: 'project_delete', methods: ['DELETE'])]
public function delete(Request $request, Project $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
{
return $this->_delete($request, $entity, $recursionHelper);
}
/**
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="project_edit")
* @Route("/{id}/edit", requirements={"id"="\d+"})
*/
#[Route(path: '/{id}/edit/{timestamp}', requirements: ['id' => '\d+'], name: 'project_edit')]
#[Route(path: '/{id}/edit', requirements: ['id' => '\d+'])]
public function edit(Project $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
{
return $this->_edit($entity, $request, $em, $timestamp);
}
/**
* @Route("/new", name="project_new")
* @Route("/{id}/clone", name="device_clone")
* @Route("/")
*/
#[Route(path: '/new', name: 'project_new')]
#[Route(path: '/{id}/clone', name: 'device_clone')]
#[Route(path: '/')]
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer, ?Project $entity = null): Response
{
return $this->_new($request, $em, $importer, $entity);
}
/**
* @Route("/export", name="project_export_all")
*/
#[Route(path: '/export', name: 'project_export_all')]
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
{
return $this->_exportAll($em, $exporter, $request);
}
/**
* @Route("/{id}/export", name="project_export")
*/
#[Route(path: '/{id}/export', name: 'project_export')]
public function exportEntity(Project $entity, EntityExporter $exporter, Request $request): Response
{
return $this->_exportEntity($entity, $exporter, $request);

View file

@ -35,9 +35,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/store_location")
*/
#[Route(path: '/store_location')]
class StorelocationController extends BaseAdminController
{
protected string $entity_class = Storelocation::class;
@ -47,44 +45,34 @@ class StorelocationController extends BaseAdminController
protected string $attachment_class = StorelocationAttachment::class;
protected ?string $parameter_class = StorelocationParameter::class;
/**
* @Route("/{id}", name="store_location_delete", methods={"DELETE"})
*/
#[Route(path: '/{id}', name: 'store_location_delete', methods: ['DELETE'])]
public function delete(Request $request, Storelocation $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
{
return $this->_delete($request, $entity, $recursionHelper);
}
/**
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="store_location_edit")
* @Route("/{id}", requirements={"id"="\d+"})
*/
#[Route(path: '/{id}/edit/{timestamp}', requirements: ['id' => '\d+'], name: 'store_location_edit')]
#[Route(path: '/{id}', requirements: ['id' => '\d+'])]
public function edit(Storelocation $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
{
return $this->_edit($entity, $request, $em, $timestamp);
}
/**
* @Route("/new", name="store_location_new")
* @Route("/{id}/clone", name="store_location_clone")
* @Route("/")
*/
#[Route(path: '/new', name: 'store_location_new')]
#[Route(path: '/{id}/clone', name: 'store_location_clone')]
#[Route(path: '/')]
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer, ?Storelocation $entity = null): Response
{
return $this->_new($request, $em, $importer, $entity);
}
/**
* @Route("/export", name="store_location_export_all")
*/
#[Route(path: '/export', name: 'store_location_export_all')]
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
{
return $this->_exportAll($em, $exporter, $request);
}
/**
* @Route("/{id}/export", name="store_location_export")
*/
#[Route(path: '/{id}/export', name: 'store_location_export')]
public function exportEntity(Storelocation $entity, EntityExporter $exporter, Request $request): Response
{
return $this->_exportEntity($entity, $exporter, $request);

View file

@ -35,9 +35,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/supplier")
*/
#[Route(path: '/supplier')]
class SupplierController extends BaseAdminController
{
protected string $entity_class = Supplier::class;
@ -47,44 +45,34 @@ class SupplierController extends BaseAdminController
protected string $attachment_class = SupplierAttachment::class;
protected ?string $parameter_class = SupplierParameter::class;
/**
* @Route("/{id}", name="supplier_delete", methods={"DELETE"})
*/
#[Route(path: '/{id}', name: 'supplier_delete', methods: ['DELETE'])]
public function delete(Request $request, Supplier $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
{
return $this->_delete($request, $entity, $recursionHelper);
}
/**
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="supplier_edit")
* @Route("/{id}", requirements={"id"="\d+"})
*/
#[Route(path: '/{id}/edit/{timestamp}', requirements: ['id' => '\d+'], name: 'supplier_edit')]
#[Route(path: '/{id}', requirements: ['id' => '\d+'])]
public function edit(Supplier $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
{
return $this->_edit($entity, $request, $em, $timestamp);
}
/**
* @Route("/new", name="supplier_new")
* @Route("/{id}/clone", name="supplier_clone")
* @Route("/")
*/
#[Route(path: '/new', name: 'supplier_new')]
#[Route(path: '/{id}/clone', name: 'supplier_clone')]
#[Route(path: '/')]
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer, ?Supplier $entity = null): Response
{
return $this->_new($request, $em, $importer, $entity);
}
/**
* @Route("/export", name="supplier_export_all")
*/
#[Route(path: '/export', name: 'supplier_export_all')]
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
{
return $this->_exportAll($em, $exporter, $request);
}
/**
* @Route("/{id}/export", name="supplier_export")
*/
#[Route(path: '/{id}/export', name: 'supplier_export')]
public function exportEntity(Supplier $entity, EntityExporter $exporter, Request $request): Response
{
return $this->_exportEntity($entity, $exporter, $request);

View file

@ -42,9 +42,8 @@ class AttachmentFileController extends AbstractController
{
/**
* Download the selected attachment.
*
* @Route("/attachment/{id}/download", name="attachment_download")
*/
#[Route(path: '/attachment/{id}/download', name: 'attachment_download')]
public function download(Attachment $attachment, AttachmentManager $helper): BinaryFileResponse
{
$this->denyAccessUnlessGranted('read', $attachment);
@ -72,9 +71,8 @@ class AttachmentFileController extends AbstractController
/**
* View the attachment.
*
* @Route("/attachment/{id}/view", name="attachment_view")
*/
#[Route(path: '/attachment/{id}/view', name: 'attachment_view')]
public function view(Attachment $attachment, AttachmentManager $helper): BinaryFileResponse
{
$this->denyAccessUnlessGranted('read', $attachment);
@ -100,9 +98,7 @@ class AttachmentFileController extends AbstractController
return $response;
}
/**
* @Route("/attachment/list", name="attachment_list")
*/
#[Route(path: '/attachment/list', name: 'attachment_list')]
public function attachmentsTable(Request $request, DataTableFactory $dataTableFactory, NodesListBuilder $nodesListBuilder): Response
{
$this->denyAccessUnlessGranted('@attachments.list_attachments');
@ -124,7 +120,7 @@ class AttachmentFileController extends AbstractController
return $this->render('attachment_list.html.twig', [
'datatable' => $table,
'filterForm' => $filterForm->createView(),
'filterForm' => $filterForm,
]);
}
}

View file

@ -39,9 +39,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/group")
*/
#[Route(path: '/group')]
class GroupController extends BaseAdminController
{
protected string $entity_class = Group::class;
@ -51,10 +49,8 @@ class GroupController extends BaseAdminController
protected string $attachment_class = GroupAttachment::class;
protected ?string $parameter_class = GroupParameter::class;
/**
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="group_edit")
* @Route("/{id}/", requirements={"id"="\d+"})
*/
#[Route(path: '/{id}/edit/{timestamp}', requirements: ['id' => '\d+'], name: 'group_edit')]
#[Route(path: '/{id}/', requirements: ['id' => '\d+'])]
public function edit(Group $entity, Request $request, EntityManagerInterface $em, PermissionPresetsHelper $permissionPresetsHelper, PermissionSchemaUpdater $permissionSchemaUpdater, ?string $timestamp = null): Response
{
//Do an upgrade of the permission schema if needed (so the user can see the permissions a user get on next request (even if it was not done yet)
@ -82,35 +78,27 @@ class GroupController extends BaseAdminController
return $this->_edit($entity, $request, $em, $timestamp);
}
/**
* @Route("/new", name="group_new")
* @Route("/{id}/clone", name="group_clone")
* @Route("/")
*/
#[Route(path: '/new', name: 'group_new')]
#[Route(path: '/{id}/clone', name: 'group_clone')]
#[Route(path: '/')]
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer, ?Group $entity = null): Response
{
return $this->_new($request, $em, $importer, $entity);
}
/**
* @Route("/{id}", name="group_delete", methods={"DELETE"})
*/
#[Route(path: '/{id}', name: 'group_delete', methods: ['DELETE'])]
public function delete(Request $request, Group $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
{
return $this->_delete($request, $entity, $recursionHelper);
}
/**
* @Route("/export", name="group_export_all")
*/
#[Route(path: '/export', name: 'group_export_all')]
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
{
return $this->_exportAll($em, $exporter, $request);
}
/**
* @Route("/{id}/export", name="group_export")
*/
#[Route(path: '/{id}/export', name: 'group_export')]
public function exportEntity(Group $entity, EntityExporter $exporter, Request $request): Response
{
return $this->_exportEntity($entity, $exporter, $request);

View file

@ -61,9 +61,7 @@ class HomepageController extends AbstractController
return $banner;
}
/**
* @Route("/", name="homepage")
*/
#[Route(path: '/', name: 'homepage')]
public function homepage(Request $request, GitVersionInfo $versionInfo, EntityManagerInterface $entityManager): Response
{
if ($this->isGranted('@tools.lastActivity')) {

View file

@ -59,9 +59,7 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @Route("/label")
*/
#[Route(path: '/label')]
class LabelController extends AbstractController
{
protected LabelGenerator $labelGenerator;
@ -80,10 +78,8 @@ class LabelController extends AbstractController
$this->translator = $translator;
}
/**
* @Route("/dialog", name="label_dialog")
* @Route("/{profile}/dialog", name="label_dialog_profile")
*/
#[Route(path: '/dialog', name: 'label_dialog')]
#[Route(path: '/{profile}/dialog', name: 'label_dialog_profile')]
public function generator(Request $request, ?LabelProfile $profile = null): Response
{
$this->denyAccessUnlessGranted('@labels.create_labels');
@ -146,7 +142,7 @@ class LabelController extends AbstractController
}
}
return $this->renderForm('label_system/dialog.html.twig', [
return $this->render('label_system/dialog.html.twig', [
'form' => $form,
'pdf_data' => $pdf_data,
'filename' => $filename,

View file

@ -49,9 +49,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/log")
*/
#[Route(path: '/log')]
class LogController extends AbstractController
{
protected EntityManagerInterface $entityManager;
@ -66,10 +64,9 @@ class LogController extends AbstractController
}
/**
* @Route("/", name="log_view")
*
* @return Response
*/
#[Route(path: '/', name: 'log_view')]
public function showLogs(Request $request, DataTableFactory $dataTable): Response
{
$this->denyAccessUnlessGranted('@system.show_logs');
@ -93,17 +90,17 @@ class LogController extends AbstractController
return $this->render('log_system/log_list.html.twig', [
'datatable' => $table,
'filterForm' => $filterForm->createView(),
'filterForm' => $filterForm,
]);
}
/**
* @Route("/{id}/details", name="log_details")
* @param Request $request
* @param AbstractLogEntry $logEntry
* @return Response
*/
public function logDetails(Request $request, AbstractLogEntry $logEntry, LogEntryExtraFormatter $logEntryExtraFormatter,
#[Route(path: '/{id}/details', name: 'log_details')]
public function logDetails(AbstractLogEntry $logEntry, LogEntryExtraFormatter $logEntryExtraFormatter,
LogLevelHelper $logLevelHelper, LogTargetHelper $logTargetHelper, EntityManagerInterface $entityManager): Response
{
$this->denyAccessUnlessGranted('show_details', $logEntry);
@ -123,9 +120,7 @@ class LogController extends AbstractController
]);
}
/**
* @Route("/{id}/delete", name="log_delete", methods={"DELETE"})
*/
#[Route(path: '/{id}/delete', name: 'log_delete', methods: ['DELETE'])]
public function deleteLogEntry(Request $request, AbstractLogEntry $logEntry, EntityManagerInterface $entityManager): RedirectResponse
{
$this->denyAccessUnlessGranted('delete', $logEntry);
@ -142,9 +137,7 @@ class LogController extends AbstractController
}
/**
* @Route("/undo", name="log_undo", methods={"POST"})
*/
#[Route(path: '/undo', name: 'log_undo', methods: ['POST'])]
public function undoRevertLog(Request $request, EventUndoHelper $eventUndoHelper): RedirectResponse
{
$mode = EventUndoHelper::MODE_UNDO;

View file

@ -59,9 +59,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
use function Symfony\Component\Translation\t;
/**
* @Route("/part")
*/
#[Route(path: '/part')]
class PartController extends AbstractController
{
protected PricedetailHelper $pricedetailHelper;
@ -77,11 +75,11 @@ class PartController extends AbstractController
}
/**
* @Route("/{id}/info/{timestamp}", name="part_info")
* @Route("/{id}", requirements={"id"="\d+"})
*
* @throws Exception
*/
#[Route(path: '/{id}/info/{timestamp}', name: 'part_info')]
#[Route(path: '/{id}', requirements: ['id' => '\d+'])]
public function show(Part $part, Request $request, TimeTravel $timeTravel, HistoryHelper $historyHelper,
DataTableFactory $dataTable, ParameterExtractor $parameterExtractor, PartLotWithdrawAddHelper $withdrawAddHelper, ?string $timestamp = null): Response
{
@ -129,9 +127,7 @@ class PartController extends AbstractController
);
}
/**
* @Route("/{id}/edit", name="part_edit")
*/
#[Route(path: '/{id}/edit', name: 'part_edit')]
public function edit(Part $part, Request $request, EntityManagerInterface $em, TranslatorInterface $translator,
AttachmentSubmitHandler $attachmentSubmitHandler): Response
{
@ -182,16 +178,14 @@ class PartController extends AbstractController
$this->addFlash('error', 'part.edited_flash.invalid');
}
return $this->renderForm('parts/edit/edit_part_info.html.twig',
return $this->render('parts/edit/edit_part_info.html.twig',
[
'part' => $part,
'form' => $form,
]);
}
/**
* @Route("/{id}/delete", name="part_delete", methods={"DELETE"})
*/
#[Route(path: '/{id}/delete', name: 'part_delete', methods: ['DELETE'])]
public function delete(Request $request, Part $part, EntityManagerInterface $entityManager): RedirectResponse
{
$this->denyAccessUnlessGranted('delete', $part);
@ -213,12 +207,12 @@ class PartController extends AbstractController
}
/**
* @Route("/new", name="part_new")
* @Route("/{id}/clone", name="part_clone")
* @Route("/new_build_part/{project_id}", name="part_new_build_part")
* @ParamConverter("part", options={"id" = "id"})
* @ParamConverter("project", options={"id" = "project_id"})
*/
#[Route(path: '/new', name: 'part_new')]
#[Route(path: '/{id}/clone', name: 'part_clone')]
#[Route(path: '/new_build_part/{project_id}', name: 'part_new_build_part')]
public function new(Request $request, EntityManagerInterface $em, TranslatorInterface $translator,
AttachmentSubmitHandler $attachmentSubmitHandler, ProjectBuildPartHelper $projectBuildPartHelper,
?Part $part = null, ?Project $project = null): Response
@ -328,16 +322,14 @@ class PartController extends AbstractController
$this->addFlash('error', 'part.created_flash.invalid');
}
return $this->renderForm('parts/edit/new_part.html.twig',
return $this->render('parts/edit/new_part.html.twig',
[
'part' => $new_part,
'form' => $form,
]);
}
/**
* @Route("/{id}/add_withdraw", name="part_add_withdraw", methods={"POST"})
*/
#[Route(path: '/{id}/add_withdraw', name: 'part_add_withdraw', methods: ['POST'])]
public function withdrawAddHandler(Part $part, Request $request, EntityManagerInterface $em, PartLotWithdrawAddHelper $withdrawAddHelper): Response
{
if ($this->isCsrfTokenValid('part_withraw' . $part->getID(), $request->request->get('_csfr'))) {

View file

@ -49,10 +49,10 @@ class PartImportExportController extends AbstractController
}
/**
* @Route("/parts/import", name="parts_import")
* @param Request $request
* @return Response
*/
#[Route(path: '/parts/import', name: 'parts_import')]
public function importParts(Request $request): Response
{
$this->denyAccessUnlessGranted('@parts.import');
@ -109,7 +109,7 @@ class PartImportExportController extends AbstractController
ret:
return $this->renderForm('parts/import/parts_import.html.twig', [
return $this->render('parts/import/parts_import.html.twig', [
'import_form' => $import_form,
'imported_entities' => $entities ?? [],
'import_errors' => $errors ?? [],
@ -117,9 +117,9 @@ class PartImportExportController extends AbstractController
}
/**
* @Route("/parts/export", name="parts_export", methods={"GET"})
* @return Response
*/
#[Route(path: '/parts/export', name: 'parts_export', methods: ['GET'])]
public function exportParts(Request $request, EntityExporter $entityExporter): Response
{
$ids = $request->query->get('ids', '');

View file

@ -62,9 +62,7 @@ class PartListsController extends AbstractController
$this->translator = $translator;
}
/**
* @Route("/table/action", name="table_action", methods={"POST"})
*/
#[Route(path: '/table/action', name: 'table_action', methods: ['POST'])]
public function tableAction(Request $request, PartsTableActionHandler $actionHandler): Response
{
$this->denyAccessUnlessGranted('@parts.edit');
@ -175,10 +173,9 @@ class PartListsController extends AbstractController
}
/**
* @Route("/category/{id}/parts", name="part_list_category")
*
* @return JsonResponse|Response
*/
#[Route(path: '/category/{id}/parts', name: 'part_list_category')]
public function showCategory(Category $category, Request $request): Response
{
$this->denyAccessUnlessGranted('@categories.read');
@ -197,10 +194,9 @@ class PartListsController extends AbstractController
}
/**
* @Route("/footprint/{id}/parts", name="part_list_footprint")
*
* @return JsonResponse|Response
*/
#[Route(path: '/footprint/{id}/parts', name: 'part_list_footprint')]
public function showFootprint(Footprint $footprint, Request $request): Response
{
$this->denyAccessUnlessGranted('@footprints.read');
@ -219,10 +215,9 @@ class PartListsController extends AbstractController
}
/**
* @Route("/manufacturer/{id}/parts", name="part_list_manufacturer")
*
* @return JsonResponse|Response
*/
#[Route(path: '/manufacturer/{id}/parts', name: 'part_list_manufacturer')]
public function showManufacturer(Manufacturer $manufacturer, Request $request): Response
{
$this->denyAccessUnlessGranted('@manufacturers.read');
@ -241,10 +236,9 @@ class PartListsController extends AbstractController
}
/**
* @Route("/store_location/{id}/parts", name="part_list_store_location")
*
* @return JsonResponse|Response
*/
#[Route(path: '/store_location/{id}/parts', name: 'part_list_store_location')]
public function showStorelocation(Storelocation $storelocation, Request $request): Response
{
$this->denyAccessUnlessGranted('@storelocations.read');
@ -263,10 +257,9 @@ class PartListsController extends AbstractController
}
/**
* @Route("/supplier/{id}/parts", name="part_list_supplier")
*
* @return JsonResponse|Response
*/
#[Route(path: '/supplier/{id}/parts', name: 'part_list_supplier')]
public function showSupplier(Supplier $supplier, Request $request): Response
{
$this->denyAccessUnlessGranted('@suppliers.read');
@ -285,10 +278,9 @@ class PartListsController extends AbstractController
}
/**
* @Route("/parts/by_tag/{tag}", name="part_list_tags", requirements={"tag": ".*"})
*
* @return JsonResponse|Response
*/
#[Route(path: '/parts/by_tag/{tag}', name: 'part_list_tags', requirements: ['tag' => '.*'])]
public function showTag(string $tag, Request $request): Response
{
$tag = trim($tag);
@ -330,10 +322,9 @@ class PartListsController extends AbstractController
}
/**
* @Route("/parts/search", name="parts_search")
*
* @return JsonResponse|Response
*/
#[Route(path: '/parts/search', name: 'parts_search')]
public function showSearch(Request $request, DataTableFactory $dataTable): Response
{
$searchFilter = $this->searchRequestToFilter($request);
@ -353,10 +344,9 @@ class PartListsController extends AbstractController
}
/**
* @Route("/parts", name="parts_show_all")
*
* @return Response
*/
#[Route(path: '/parts', name: 'parts_show_all')]
public function showAll(Request $request): Response
{
return $this->showListWithFilter($request,'parts/lists/all_list.html.twig');

View file

@ -47,9 +47,7 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
use function Symfony\Component\Translation\t;
/**
* @Route("/project")
*/
#[Route(path: '/project')]
class ProjectController extends AbstractController
{
private DataTableFactory $dataTableFactory;
@ -59,9 +57,7 @@ class ProjectController extends AbstractController
$this->dataTableFactory = $dataTableFactory;
}
/**
* @Route("/{id}/info", name="project_info", requirements={"id"="\d+"})
*/
#[Route(path: '/{id}/info', name: 'project_info', requirements: ['id' => '\d+'])]
public function info(Project $project, Request $request, ProjectBuildHelper $buildHelper): Response
{
$this->denyAccessUnlessGranted('read', $project);
@ -80,9 +76,7 @@ class ProjectController extends AbstractController
]);
}
/**
* @Route("/{id}/build", name="project_build", requirements={"id"="\d+"})
*/
#[Route(path: '/{id}/build', name: 'project_build', requirements: ['id' => '\d+'])]
public function build(Project $project, Request $request, ProjectBuildHelper $buildHelper, EntityManagerInterface $entityManager): Response
{
$this->denyAccessUnlessGranted('read', $project);
@ -117,7 +111,7 @@ class ProjectController extends AbstractController
$this->addFlash('error', 'project.build.flash.invalid_input');
}
return $this->renderForm('projects/build/build.html.twig', [
return $this->render('projects/build/build.html.twig', [
'buildHelper' => $buildHelper,
'project' => $project,
'build_request' => $projectBuildRequest,
@ -126,9 +120,7 @@ class ProjectController extends AbstractController
]);
}
/**
* @Route("/{id}/import_bom", name="project_import_bom", requirements={"id"="\d+"})
*/
#[Route(path: '/{id}/import_bom', name: 'project_import_bom', requirements: ['id' => '\d+'])]
public function importBOM(Request $request, EntityManagerInterface $entityManager, Project $project,
BOMImporter $BOMImporter, ValidatorInterface $validator): Response
{
@ -195,7 +187,7 @@ class ProjectController extends AbstractController
}
}
return $this->renderForm('projects/import_bom.html.twig', [
return $this->render('projects/import_bom.html.twig', [
'project' => $project,
'form' => $form,
'errors' => $errors ?? null,
@ -203,11 +195,11 @@ class ProjectController extends AbstractController
}
/**
* @Route("/add_parts", name="project_add_parts_no_id")
* @Route("/{id}/add_parts", name="project_add_parts", requirements={"id"="\d+"})
* @param Request $request
* @param Project|null $project
*/
#[Route(path: '/add_parts', name: 'project_add_parts_no_id')]
#[Route(path: '/{id}/add_parts', name: 'project_add_parts', requirements: ['id' => '\d+'])]
public function addPart(Request $request, EntityManagerInterface $entityManager, ?Project $project): Response
{
if($project) {
@ -274,7 +266,7 @@ class ProjectController extends AbstractController
return $this->redirectToRoute('project_info', ['id' => $target_project->getID()]);
}
return $this->renderForm('projects/add_parts.html.twig', [
return $this->render('projects/add_parts.html.twig', [
'project' => $project,
'form' => $form,
]);

View file

@ -51,9 +51,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/scan")
*/
#[Route(path: '/scan')]
class ScanController extends AbstractController
{
protected BarcodeRedirector $barcodeParser;
@ -65,9 +63,7 @@ class ScanController extends AbstractController
$this->barcodeNormalizer = $barcodeNormalizer;
}
/**
* @Route("", name="scan_dialog")
*/
#[Route(path: '', name: 'scan_dialog')]
public function dialog(Request $request): Response
{
$this->denyAccessUnlessGranted('@tools.label_scanner');
@ -91,7 +87,7 @@ class ScanController extends AbstractController
}
}
return $this->renderForm('label_system/scanner/scanner.html.twig', [
return $this->render('label_system/scanner/scanner.html.twig', [
'form' => $form,
]);
}

View file

@ -57,9 +57,7 @@ class SecurityController extends AbstractController
$this->allow_email_pw_reset = $allow_email_pw_reset;
}
/**
* @Route("/login", name="login", methods={"GET", "POST"})
*/
#[Route(path: '/login', name: 'login', methods: ['GET', 'POST'])]
public function login(AuthenticationUtils $authenticationUtils): Response
{
// get the login error if there is one
@ -75,10 +73,9 @@ class SecurityController extends AbstractController
}
/**
* @Route("/pw_reset/request", name="pw_reset_request")
*
* @return RedirectResponse|Response
*/
#[Route(path: '/pw_reset/request', name: 'pw_reset_request')]
public function requestPwReset(PasswordResetManager $passwordReset, Request $request)
{
if (!$this->allow_email_pw_reset) {
@ -113,16 +110,15 @@ class SecurityController extends AbstractController
return $this->redirectToRoute('login');
}
return $this->renderForm('security/pw_reset_request.html.twig', [
return $this->render('security/pw_reset_request.html.twig', [
'form' => $form,
]);
}
/**
* @Route("/pw_reset/new_pw/{user}/{token}", name="pw_reset_new_pw")
*
* @return RedirectResponse|Response
*/
#[Route(path: '/pw_reset/new_pw/{user}/{token}', name: 'pw_reset_new_pw')]
public function pwResetNewPw(PasswordResetManager $passwordReset, Request $request, EntityManagerInterface $em, EventDispatcherInterface $eventDispatcher, ?string $user = null, ?string $token = null)
{
if (!$this->allow_email_pw_reset) {
@ -187,14 +183,12 @@ class SecurityController extends AbstractController
}
}
return $this->renderForm('security/pw_reset_new_pw.html.twig', [
return $this->render('security/pw_reset_new_pw.html.twig', [
'form' => $form,
]);
}
/**
* @Route("/logout", name="logout")
*/
#[Route(path: '/logout', name: 'logout')]
public function logout(): void
{
throw new RuntimeException('Will be intercepted before getting here');

View file

@ -37,10 +37,9 @@ use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @Route("/select_api")
*
* This endpoint is used by the select2 library to dynamically load data (used in the multiselect action helper in parts lists)
*/
#[Route(path: '/select_api')]
class SelectAPIController extends AbstractController
{
private NodesListBuilder $nodesListBuilder;
@ -54,49 +53,37 @@ class SelectAPIController extends AbstractController
$this->choiceHelper = $choiceHelper;
}
/**
* @Route("/category", name="select_category")
*/
#[Route(path: '/category', name: 'select_category')]
public function category(): Response
{
return $this->getResponseForClass(Category::class);
}
/**
* @Route("/footprint", name="select_footprint")
*/
#[Route(path: '/footprint', name: 'select_footprint')]
public function footprint(): Response
{
return $this->getResponseForClass(Footprint::class, true);
}
/**
* @Route("/manufacturer", name="select_manufacturer")
*/
#[Route(path: '/manufacturer', name: 'select_manufacturer')]
public function manufacturer(): Response
{
return $this->getResponseForClass(Manufacturer::class, true);
}
/**
* @Route("/measurement_unit", name="select_measurement_unit")
*/
#[Route(path: '/measurement_unit', name: 'select_measurement_unit')]
public function measurement_unit(): Response
{
return $this->getResponseForClass(MeasurementUnit::class, true);
}
/**
* @Route("/project", name="select_project")
*/
#[Route(path: '/project', name: 'select_project')]
public function projects(): Response
{
return $this->getResponseForClass(Project::class, false);
}
/**
* @Route("/export_level", name="select_export_level")
*/
#[Route(path: '/export_level', name: 'select_export_level')]
public function exportLevel(): Response
{
$entries = [
@ -114,9 +101,9 @@ class SelectAPIController extends AbstractController
}
/**
* @Route("/label_profiles", name="select_label_profiles")
* @return Response
*/
#[Route(path: '/label_profiles', name: 'select_label_profiles')]
public function labelProfiles(EntityManagerInterface $entityManager): Response
{
$this->denyAccessUnlessGranted('@labels.create_labels');
@ -135,9 +122,9 @@ class SelectAPIController extends AbstractController
}
/**
* @Route("/label_profiles_lot", name="select_label_profiles_lot")
* @return Response
*/
#[Route(path: '/label_profiles_lot', name: 'select_label_profiles_lot')]
public function labelProfilesLot(EntityManagerInterface $entityManager): Response
{
$this->denyAccessUnlessGranted('@labels.create_labels');

View file

@ -48,9 +48,7 @@ use Symfony\Component\Routing\Annotation\Route;
class StatisticsController extends AbstractController
{
/**
* @Route("/statistics", name="statistics_view")
*/
#[Route(path: '/statistics', name: 'statistics_view')]
public function showStatistics(StatisticsHelper $helper): Response
{
$this->denyAccessUnlessGranted('@tools.statistics');

View file

@ -32,14 +32,10 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGenerator;
/**
* @Route("/tools")
*/
#[Route(path: '/tools')]
class ToolsController extends AbstractController
{
/**
* @Route("/reel_calc", name="tools_reel_calculator")
*/
#[Route(path: '/reel_calc', name: 'tools_reel_calculator')]
public function reelCalculator(): Response
{
$this->denyAccessUnlessGranted('@tools.reel_calculator');
@ -47,9 +43,7 @@ class ToolsController extends AbstractController
return $this->render('tools/reel_calculator/reel_calculator.html.twig');
}
/**
* @Route("/server_infos", name="tools_server_infos")
*/
#[Route(path: '/server_infos', name: 'tools_server_infos')]
public function systemInfos(GitVersionInfo $versionInfo, DBInfoHelper $DBInfoHelper,
AttachmentSubmitHandler $attachmentSubmitHandler): Response
{
@ -98,9 +92,9 @@ class ToolsController extends AbstractController
}
/**
* @Route("/builtin_footprints", name="tools_builtin_footprints_viewer")
* @return Response
*/
#[Route(path: '/builtin_footprints', name: 'tools_builtin_footprints_viewer')]
public function builtInFootprintsViewer(BuiltinAttachmentsFinder $builtinAttachmentsFinder, AttachmentURLGenerator $urlGenerator): Response
{
$this->denyAccessUnlessGranted('@tools.builtin_footprints_viewer');
@ -121,9 +115,9 @@ class ToolsController extends AbstractController
}
/**
* @Route("/ic_logos", name="tools_ic_logos")
* @return Response
*/
#[Route(path: '/ic_logos', name: 'tools_ic_logos')]
public function icLogos(): Response
{
$this->denyAccessUnlessGranted('@tools.ic_logos');

View file

@ -36,9 +36,8 @@ use Symfony\Component\Routing\Annotation\Route;
/**
* This controller has the purpose to provide the data for all treeviews.
*
* @Route("/tree")
*/
#[Route(path: '/tree')]
class TreeController extends AbstractController
{
protected TreeViewGenerator $treeGenerator;
@ -48,9 +47,7 @@ class TreeController extends AbstractController
$this->treeGenerator = $treeGenerator;
}
/**
* @Route("/tools", name="tree_tools")
*/
#[Route(path: '/tools', name: 'tree_tools')]
public function tools(ToolsTreeBuilder $builder): JsonResponse
{
$tree = $builder->getTree();
@ -58,90 +55,78 @@ class TreeController extends AbstractController
return new JsonResponse($tree);
}
/**
* @Route("/category/{id}", name="tree_category")
* @Route("/categories", name="tree_category_root")
*/
#[Route(path: '/category/{id}', name: 'tree_category')]
#[Route(path: '/categories', name: 'tree_category_root')]
public function categoryTree(?Category $category = null): JsonResponse
{
if ($this->isGranted('@parts.read') && $this->isGranted('@categories.read')) {
$tree = $this->treeGenerator->getTreeView(Category::class, $category, 'list_parts_root');
} else {
return new JsonResponse("Access denied", 403);
return new JsonResponse("Access denied", \Symfony\Component\HttpFoundation\Response::HTTP_FORBIDDEN);
}
return new JsonResponse($tree);
}
/**
* @Route("/footprint/{id}", name="tree_footprint")
* @Route("/footprints", name="tree_footprint_root")
*/
#[Route(path: '/footprint/{id}', name: 'tree_footprint')]
#[Route(path: '/footprints', name: 'tree_footprint_root')]
public function footprintTree(?Footprint $footprint = null): JsonResponse
{
if ($this->isGranted('@parts.read') && $this->isGranted('@footprints.read')) {
$tree = $this->treeGenerator->getTreeView(Footprint::class, $footprint, 'list_parts_root');
} else {
return new JsonResponse("Access denied", 403);
return new JsonResponse("Access denied", \Symfony\Component\HttpFoundation\Response::HTTP_FORBIDDEN);
}
return new JsonResponse($tree);
}
/**
* @Route("/location/{id}", name="tree_location")
* @Route("/locations", name="tree_location_root")
*/
#[Route(path: '/location/{id}', name: 'tree_location')]
#[Route(path: '/locations', name: 'tree_location_root')]
public function locationTree(?Storelocation $location = null): JsonResponse
{
if ($this->isGranted('@parts.read') && $this->isGranted('@storelocations.read')) {
$tree = $this->treeGenerator->getTreeView(Storelocation::class, $location, 'list_parts_root');
} else {
return new JsonResponse("Access denied", 403);
return new JsonResponse("Access denied", \Symfony\Component\HttpFoundation\Response::HTTP_FORBIDDEN);
}
return new JsonResponse($tree);
}
/**
* @Route("/manufacturer/{id}", name="tree_manufacturer")
* @Route("/manufacturers", name="tree_manufacturer_root")
*/
#[Route(path: '/manufacturer/{id}', name: 'tree_manufacturer')]
#[Route(path: '/manufacturers', name: 'tree_manufacturer_root')]
public function manufacturerTree(?Manufacturer $manufacturer = null): JsonResponse
{
if ($this->isGranted('@parts.read') && $this->isGranted('@manufacturers.read')) {
$tree = $this->treeGenerator->getTreeView(Manufacturer::class, $manufacturer, 'list_parts_root');
} else {
return new JsonResponse("Access denied", 403);
return new JsonResponse("Access denied", \Symfony\Component\HttpFoundation\Response::HTTP_FORBIDDEN);
}
return new JsonResponse($tree);
}
/**
* @Route("/supplier/{id}", name="tree_supplier")
* @Route("/suppliers", name="tree_supplier_root")
*/
#[Route(path: '/supplier/{id}', name: 'tree_supplier')]
#[Route(path: '/suppliers', name: 'tree_supplier_root')]
public function supplierTree(?Supplier $supplier = null): JsonResponse
{
if ($this->isGranted('@parts.read') && $this->isGranted('@suppliers.read')) {
$tree = $this->treeGenerator->getTreeView(Supplier::class, $supplier, 'list_parts_root');
} else {
return new JsonResponse("Access denied", 403);
return new JsonResponse("Access denied", \Symfony\Component\HttpFoundation\Response::HTTP_FORBIDDEN);
}
return new JsonResponse($tree);
}
/**
* @Route("/device/{id}", name="tree_device")
* @Route("/devices", name="tree_device_root")
*/
#[Route(path: '/device/{id}', name: 'tree_device')]
#[Route(path: '/devices', name: 'tree_device_root')]
public function deviceTree(?Project $device = null): JsonResponse
{
if ($this->isGranted('@projects.read')) {
$tree = $this->treeGenerator->getTreeView(Project::class, $device, 'devices');
} else {
return new JsonResponse("Access denied", 403);
return new JsonResponse("Access denied", \Symfony\Component\HttpFoundation\Response::HTTP_FORBIDDEN);
}
return new JsonResponse($tree);

View file

@ -51,9 +51,8 @@ use Symfony\Component\Serializer\Serializer;
/**
* In this controller the endpoints for the typeaheads are collected.
*
* @Route("/typeahead")
*/
#[Route(path: '/typeahead')]
class TypeaheadController extends AbstractController
{
protected AttachmentURLGenerator $urlGenerator;
@ -65,9 +64,7 @@ class TypeaheadController extends AbstractController
$this->assets = $assets;
}
/**
* @Route("/builtInResources/search", name="typeahead_builtInRessources")
*/
#[Route(path: '/builtInResources/search', name: 'typeahead_builtInRessources')]
public function builtInResources(Request $request, BuiltinAttachmentsFinder $finder): JsonResponse
{
$query = $request->get('query');
@ -91,7 +88,7 @@ class TypeaheadController extends AbstractController
$serializer = new Serializer($normalizers, $encoders);
$data = $serializer->serialize($result, 'json');
return new JsonResponse($data, 200, [], true);
return new JsonResponse($data, \Symfony\Component\HttpFoundation\Response::HTTP_OK, [], true);
}
/**
@ -131,11 +128,11 @@ class TypeaheadController extends AbstractController
}
/**
* @Route("/parts/search/{query}", name="typeahead_parts")
* @param string $query
* @param EntityManagerInterface $entityManager
* @return JsonResponse
*/
#[Route(path: '/parts/search/{query}', name: 'typeahead_parts')]
public function parts(EntityManagerInterface $entityManager, PartPreviewGenerator $previewGenerator,
AttachmentURLGenerator $attachmentURLGenerator, string $query = ""): JsonResponse
{
@ -170,10 +167,10 @@ class TypeaheadController extends AbstractController
}
/**
* @Route("/parameters/{type}/search/{query}", name="typeahead_parameters", requirements={"type" = ".+"})
* @param string $query
* @return JsonResponse
*/
#[Route(path: '/parameters/{type}/search/{query}', name: 'typeahead_parameters', requirements: ['type' => '.+'])]
public function parameters(string $type, EntityManagerInterface $entityManager, string $query = ""): JsonResponse
{
$class = $this->typeToParameterClass($type);
@ -190,9 +187,7 @@ class TypeaheadController extends AbstractController
return new JsonResponse($data);
}
/**
* @Route("/tags/search/{query}", name="typeahead_tags", requirements={"query"= ".+"})
*/
#[Route(path: '/tags/search/{query}', name: 'typeahead_tags', requirements: ['query' => '.+'])]
public function tags(string $query, TagFinder $finder): JsonResponse
{
$this->denyAccessUnlessGranted('@parts.read');
@ -209,6 +204,6 @@ class TypeaheadController extends AbstractController
$serializer = new Serializer($normalizers, $encoders);
$data = $serializer->serialize($array, 'json');
return new JsonResponse($data, 200, [], true);
return new JsonResponse($data, \Symfony\Component\HttpFoundation\Response::HTTP_OK, [], true);
}
}

View file

@ -46,10 +46,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/user")
* Class UserController
*/
#[Route(path: '/user')]
class UserController extends AdminPages\BaseAdminController
{
protected string $entity_class = User::class;
@ -76,11 +73,11 @@ class UserController extends AdminPages\BaseAdminController
}
/**
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="user_edit")
* @Route("/{id}/", requirements={"id"="\d+"})
*
* @throws Exception
*/
#[Route(path: '/{id}/edit/{timestamp}', requirements: ['id' => '\d+'], name: 'user_edit')]
#[Route(path: '/{id}/', requirements: ['id' => '\d+'])]
public function edit(User $entity, Request $request, EntityManagerInterface $em, PermissionPresetsHelper $permissionPresetsHelper, PermissionSchemaUpdater $permissionSchemaUpdater, ?string $timestamp = null): Response
{
//Do an upgrade of the permission schema if needed (so the user can see the permissions a user get on next request (even if it was not done yet)
@ -148,19 +145,15 @@ class UserController extends AdminPages\BaseAdminController
return true;
}
/**
* @Route("/new", name="user_new")
* @Route("/{id}/clone", name="user_clone")
* @Route("/")
*/
#[Route(path: '/new', name: 'user_new')]
#[Route(path: '/{id}/clone', name: 'user_clone')]
#[Route(path: '/')]
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer, ?User $entity = null): Response
{
return $this->_new($request, $em, $importer, $entity);
}
/**
* @Route("/{id}", name="user_delete", methods={"DELETE"}, requirements={"id"="\d+"})
*/
#[Route(path: '/{id}', name: 'user_delete', methods: ['DELETE'], requirements: ['id' => '\d+'])]
public function delete(Request $request, User $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
{
if (User::ID_ANONYMOUS === $entity->getID()) {
@ -170,26 +163,20 @@ class UserController extends AdminPages\BaseAdminController
return $this->_delete($request, $entity, $recursionHelper);
}
/**
* @Route("/export", name="user_export_all")
*/
#[Route(path: '/export', name: 'user_export_all')]
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
{
return $this->_exportAll($em, $exporter, $request);
}
/**
* @Route("/{id}/export", name="user_export")
*/
#[Route(path: '/{id}/export', name: 'user_export')]
public function exportEntity(User $entity, EntityExporter $exporter, Request $request): Response
{
return $this->_exportEntity($entity, $exporter, $request);
}
/**
* @Route("/info", name="user_info_self")
* @Route("/{id}/info", name="user_info")
*/
#[Route(path: '/info', name: 'user_info_self')]
#[Route(path: '/{id}/info', name: 'user_info')]
public function userInfo(?User $user, Packages $packages, Request $request, DataTableFactory $dataTableFactory): Response
{
//If no user id was passed, then we show info about the current user
@ -229,7 +216,7 @@ class UserController extends AdminPages\BaseAdminController
'data' => $user,
]);
return $this->renderForm('users/user_info.html.twig', [
return $this->render('users/user_info.html.twig', [
'user' => $user,
'form' => $builder->getForm(),
'datatable' => $table ?? null,

View file

@ -51,9 +51,7 @@ use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
use Symfony\Component\Validator\Constraints\Length;
/**
* @Route("/user")
*/
#[Route(path: '/user')]
class UserSettingsController extends AbstractController
{
protected bool $demo_mode;
@ -69,9 +67,7 @@ class UserSettingsController extends AbstractController
$this->eventDispatcher = $eventDispatcher;
}
/**
* @Route("/2fa_backup_codes", name="show_backup_codes")
*/
#[Route(path: '/2fa_backup_codes', name: 'show_backup_codes')]
public function showBackupCodes()
{
$user = $this->getUser();
@ -98,9 +94,7 @@ class UserSettingsController extends AbstractController
]);
}
/**
* @Route("/u2f_delete", name="u2f_delete", methods={"DELETE"})
*/
#[Route(path: '/u2f_delete', name: 'u2f_delete', methods: ['DELETE'])]
public function removeU2FToken(Request $request, EntityManagerInterface $entityManager, BackupCodeManager $backupCodeManager): RedirectResponse
{
if ($this->demo_mode) {
@ -181,10 +175,9 @@ class UserSettingsController extends AbstractController
}
/**
* @Route("/invalidate_trustedDevices", name="tfa_trustedDevices_invalidate", methods={"DELETE"})
*
* @return RuntimeException|RedirectResponse
*/
#[Route(path: '/invalidate_trustedDevices', name: 'tfa_trustedDevices_invalidate', methods: ['DELETE'])]
public function resetTrustedDevices(Request $request, EntityManagerInterface $entityManager)
{
if ($this->demo_mode) {
@ -219,10 +212,9 @@ class UserSettingsController extends AbstractController
}
/**
* @Route("/settings", name="user_settings")
*
* @return RedirectResponse|Response
*/
#[Route(path: '/settings', name: 'user_settings')]
public function userSettings(Request $request, EntityManagerInterface $em, UserPasswordHasherInterface $passwordEncoder, GoogleAuthenticator $googleAuthenticator, BackupCodeManager $backupCodeManager, FormFactoryInterface $formFactory, UserAvatarHelper $avatarHelper)
{
/** @var User $user */
@ -397,7 +389,7 @@ class UserSettingsController extends AbstractController
* Output both forms
*****************************/
return $this->renderForm('users/user_settings.html.twig', [
return $this->render('users/user_settings.html.twig', [
'user' => $user,
'settings_form' => $form,
'pw_form' => $pw_form,

View file

@ -40,9 +40,7 @@ class WebauthnKeyRegistrationController extends AbstractController
$this->demo_mode = $demo_mode;
}
/**
* @Route("/webauthn/register", name="webauthn_register")
*/
#[Route(path: '/webauthn/register', name: 'webauthn_register')]
public function register(Request $request, TFAWebauthnRegistrationHelper $registrationHelper, EntityManagerInterface $em)
{
//When user change its settings, he should be logged in fully.

View file

@ -52,9 +52,9 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class RevertLogColumn extends AbstractColumn
{
protected TranslatorInterface $translator;
protected Security $security;
protected \Symfony\Bundle\SecurityBundle\Security $security;
public function __construct(TranslatorInterface $translator, Security $security)
public function __construct(TranslatorInterface $translator, \Symfony\Bundle\SecurityBundle\Security $security)
{
$this->translator = $translator;
$this->security = $security;

View file

@ -66,13 +66,13 @@ class LogDataTable implements DataTableTypeInterface
protected UrlGeneratorInterface $urlGenerator;
protected EntityURLGenerator $entityURLGenerator;
protected LogEntryRepository $logRepo;
protected Security $security;
protected \Symfony\Bundle\SecurityBundle\Security $security;
protected UserAvatarHelper $userAvatarHelper;
protected LogLevelHelper $logLevelHelper;
public function __construct(ElementTypeNameGenerator $elementTypeNameGenerator, TranslatorInterface $translator,
UrlGeneratorInterface $urlGenerator, EntityURLGenerator $entityURLGenerator, EntityManagerInterface $entityManager,
Security $security, UserAvatarHelper $userAvatarHelper, LogLevelHelper $logLevelHelper)
\Symfony\Bundle\SecurityBundle\Security $security, UserAvatarHelper $userAvatarHelper, LogLevelHelper $logLevelHelper)
{
$this->elementTypeNameGenerator = $elementTypeNameGenerator;
$this->translator = $translator;

View file

@ -56,14 +56,14 @@ final class PartsDataTable implements DataTableTypeInterface
{
private TranslatorInterface $translator;
private AmountFormatter $amountFormatter;
private Security $security;
private \Symfony\Bundle\SecurityBundle\Security $security;
private PartDataTableHelper $partDataTableHelper;
private EntityURLGenerator $urlGenerator;
public function __construct(EntityURLGenerator $urlGenerator, TranslatorInterface $translator,
AmountFormatter $amountFormatter,PartDataTableHelper $partDataTableHelper, Security $security)
AmountFormatter $amountFormatter,PartDataTableHelper $partDataTableHelper, \Symfony\Bundle\SecurityBundle\Security $security)
{
$this->urlGenerator = $urlGenerator;
$this->translator = $translator;

View file

@ -99,9 +99,9 @@ abstract class Attachment extends AbstractNamedDBElement
/**
* @var string the name of this element
* @ORM\Column(type="string")
* @Assert\NotBlank(message="validator.attachment.name_not_blank")
* @Groups({"simple", "extended", "full"})
*/
#[Assert\NotBlank(message: 'validator.attachment.name_not_blank')]
#[Groups(['simple', 'extended', 'full'])]
protected string $name = '';
/**
@ -120,8 +120,8 @@ abstract class Attachment extends AbstractNamedDBElement
* @ORM\ManyToOne(targetEntity="AttachmentType", inversedBy="attachments_with_type")
* @ORM\JoinColumn(name="type_id", referencedColumnName="id", nullable=false)
* @Selectable()
* @Assert\NotNull(message="validator.attachment.must_not_be_null")
*/
#[Assert\NotNull(message: 'validator.attachment.must_not_be_null')]
protected ?AttachmentType $attachment_type = null;
public function __construct()

View file

@ -44,8 +44,8 @@ abstract class AttachmentContainingDBElement extends AbstractNamedDBElement impl
* //@ORM\OneToMany(targetEntity="Attachment", mappedBy="element")
*
* Mapping is done in sub classes like part
* @Groups({"full"})
*/
#[Groups(['full'])]
protected Collection $attachments;
public function __construct()

View file

@ -63,15 +63,15 @@ class AttachmentType extends AbstractStructuralDBElement
* @var Collection<int, AttachmentTypeAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\AttachmentTypeAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"name" = "ASC"})
* @Assert\Valid()
*/
#[Assert\Valid]
protected Collection $attachments;
/** @var Collection<int, AttachmentTypeParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\AttachmentTypeParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()
*/
#[Assert\Valid]
protected Collection $parameters;
/**

View file

@ -29,8 +29,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
* A attachment attached to an attachmentType element.
*
* @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/
#[UniqueEntity(['name', 'attachment_type', 'element'])]
class AttachmentTypeAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = AttachmentType::class;

View file

@ -30,8 +30,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
* An attachment attached to a category element.
*
* @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/
#[UniqueEntity(['name', 'attachment_type', 'element'])]
class CategoryAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = Category::class;

View file

@ -30,8 +30,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
* An attachment attached to a currency element.
*
* @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/
#[UniqueEntity(['name', 'attachment_type', 'element'])]
class CurrencyAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = Currency::class;

View file

@ -30,8 +30,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
* An attachment attached to a footprint element.
*
* @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/
#[UniqueEntity(['name', 'attachment_type', 'element'])]
class FootprintAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = Footprint::class;

View file

@ -30,8 +30,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
* An attachment attached to a Group element.
*
* @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/
#[UniqueEntity(['name', 'attachment_type', 'element'])]
class GroupAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = Group::class;

View file

@ -49,8 +49,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
* A attachment attached to a user element.
*
* @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/
#[UniqueEntity(['name', 'attachment_type', 'element'])]
class LabelAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = LabelProfile::class;

View file

@ -30,8 +30,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
* An attachment attached to a manufacturer element.
*
* @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/
#[UniqueEntity(['name', 'attachment_type', 'element'])]
class ManufacturerAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = Manufacturer::class;

View file

@ -31,8 +31,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
* An attachment attached to a measurement unit element.
*
* @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/
#[UniqueEntity(['name', 'attachment_type', 'element'])]
class MeasurementUnitAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = MeasurementUnit::class;

View file

@ -30,8 +30,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
* A attachment attached to a part element.
*
* @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/
#[UniqueEntity(['name', 'attachment_type', 'element'])]
class PartAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = Part::class;

View file

@ -30,8 +30,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
* A attachment attached to a device element.
*
* @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/
#[UniqueEntity(['name', 'attachment_type', 'element'])]
class ProjectAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = Project::class;

View file

@ -30,8 +30,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
* An attachment attached to a measurement unit element.
*
* @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/
#[UniqueEntity(['name', 'attachment_type', 'element'])]
class StorelocationAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = Storelocation::class;

View file

@ -30,8 +30,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
* A attachment attached to a supplier element.
*
* @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/
#[UniqueEntity(['name', 'attachment_type', 'element'])]
class SupplierAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = Supplier::class;

View file

@ -30,8 +30,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
* An attachment attached to a user element.
*
* @ORM\Entity()
* @UniqueEntity({"name", "attachment_type", "element"})
*/
#[UniqueEntity(['name', 'attachment_type', 'element'])]
class UserAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = User::class;

View file

@ -37,38 +37,38 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
/**
* @var string The address of the company
* @ORM\Column(type="string")
* @Groups({"full"})
*/
#[Groups(['full'])]
protected string $address = '';
/**
* @var string The phone number of the company
* @ORM\Column(type="string")
* @Groups({"full"})
*/
#[Groups(['full'])]
protected string $phone_number = '';
/**
* @var string The fax number of the company
* @ORM\Column(type="string")
* @Groups({"full"})
*/
#[Groups(['full'])]
protected string $fax_number = '';
/**
* @var string The email address of the company
* @ORM\Column(type="string")
* @Assert\Email()
* @Groups({"full"})
*/
#[Assert\Email]
#[Groups(['full'])]
protected string $email_address = '';
/**
* @var string The website of the company
* @ORM\Column(type="string")
* @Assert\Url()
* @Groups({"full"})
*/
#[Assert\Url]
#[Groups(['full'])]
protected string $website = '';
/**

View file

@ -36,41 +36,8 @@ use Symfony\Component\Serializer\Annotation\Groups;
* must have the table row "id"!! The ID is the unique key to identify the elements.
*
* @ORM\MappedSuperclass(repositoryClass="App\Repository\DBElementRepository")
*
* @DiscriminatorMap(typeProperty="type", mapping={
* "attachment_type" = "App\Entity\Attachments\AttachmentType",
* "attachment" = "App\Entity\Attachments\Attachment",
* "attachment_type_attachment" = "App\Entity\Attachments\AttachmentTypeAttachment",
* "category_attachment" = "App\Entity\Attachments\CategoryAttachment",
* "currency_attachment" = "App\Entity\Attachments\CurrencyAttachment",
* "footprint_attachment" = "App\Entity\Attachments\FootprintAttachment",
* "group_attachment" = "App\Entity\Attachments\GroupAttachment",
* "label_attachment" = "App\Entity\Attachments\LabelAttachment",
* "manufacturer_attachment" = "App\Entity\Attachments\ManufacturerAttachment",
* "measurement_unit_attachment" = "App\Entity\Attachments\MeasurementUnitAttachment",
* "part_attachment" = "App\Entity\Attachments\PartAttachment",
* "project_attachment" = "App\Entity\Attachments\ProjectAttachment",
* "storelocation_attachment" = "App\Entity\Attachments\StorelocationAttachment",
* "supplier_attachment" = "App\Entity\Attachments\SupplierAttachment",
* "user_attachment" = "App\Entity\Attachments\UserAttachment",
* "category" = "App\Entity\Parts\Category",
* "project" = "App\Entity\ProjectSystem\Project",
* "project_bom_entry" = "App\Entity\ProjectSystem\ProjectBOMEntry",
* "footprint" = "App\Entity\Parts\Footprint",
* "group" = "App\Entity\UserSystem\Group",
* "manufacturer" = "App\Entity\Parts\Manufacturer",
* "orderdetail" = "App\Entity\PriceInformations\Orderdetail",
* "part" = "App\Entity\Parts\Part",
* "pricedetail" = "App\Entity\PriceInformation\Pricedetail",
* "storelocation" = "App\Entity\Parts\Storelocation",
* "part_lot" = "App\Entity\Parts\PartLot",
* "currency" = "App\Entity\PriceInformations\Currency",
* "measurement_unit" = "App\Entity\Parts\MeasurementUnit",
* "parameter" = "App\Entity\Parts\AbstractParameter",
* "supplier" = "App\Entity\Parts\Supplier",
* "user" = "App\Entity\UserSystem\User"
* })
*/
#[DiscriminatorMap(typeProperty: 'type', mapping: ['attachment_type' => 'App\Entity\Attachments\AttachmentType', 'attachment' => 'App\Entity\Attachments\Attachment', 'attachment_type_attachment' => 'App\Entity\Attachments\AttachmentTypeAttachment', 'category_attachment' => 'App\Entity\Attachments\CategoryAttachment', 'currency_attachment' => 'App\Entity\Attachments\CurrencyAttachment', 'footprint_attachment' => 'App\Entity\Attachments\FootprintAttachment', 'group_attachment' => 'App\Entity\Attachments\GroupAttachment', 'label_attachment' => 'App\Entity\Attachments\LabelAttachment', 'manufacturer_attachment' => 'App\Entity\Attachments\ManufacturerAttachment', 'measurement_unit_attachment' => 'App\Entity\Attachments\MeasurementUnitAttachment', 'part_attachment' => 'App\Entity\Attachments\PartAttachment', 'project_attachment' => 'App\Entity\Attachments\ProjectAttachment', 'storelocation_attachment' => 'App\Entity\Attachments\StorelocationAttachment', 'supplier_attachment' => 'App\Entity\Attachments\SupplierAttachment', 'user_attachment' => 'App\Entity\Attachments\UserAttachment', 'category' => 'App\Entity\Parts\Category', 'project' => 'App\Entity\ProjectSystem\Project', 'project_bom_entry' => 'App\Entity\ProjectSystem\ProjectBOMEntry', 'footprint' => 'App\Entity\Parts\Footprint', 'group' => 'App\Entity\UserSystem\Group', 'manufacturer' => 'App\Entity\Parts\Manufacturer', 'orderdetail' => 'App\Entity\PriceInformations\Orderdetail', 'part' => 'App\Entity\Parts\Part', 'pricedetail' => 'App\Entity\PriceInformation\Pricedetail', 'storelocation' => 'App\Entity\Parts\Storelocation', 'part_lot' => 'App\Entity\Parts\PartLot', 'currency' => 'App\Entity\PriceInformations\Currency', 'measurement_unit' => 'App\Entity\Parts\MeasurementUnit', 'parameter' => 'App\Entity\Parts\AbstractParameter', 'supplier' => 'App\Entity\Parts\Supplier', 'user' => 'App\Entity\UserSystem\User'])]
abstract class AbstractDBElement implements JsonSerializable
{
/** @var int|null The Identification number for this part. This value is unique for the element in this table.
@ -78,8 +45,8 @@ abstract class AbstractDBElement implements JsonSerializable
* @ORM\Column(type="integer")
* @ORM\Id()
* @ORM\GeneratedValue()
* @Groups({"full"})
*/
#[Groups(['full'])]
protected ?int $id = null;
public function __clone()

View file

@ -41,9 +41,9 @@ abstract class AbstractNamedDBElement extends AbstractDBElement implements Named
/**
* @var string the name of this element
* @ORM\Column(type="string")
* @Assert\NotBlank()
* @Groups({"simple", "extended", "full", "import"})
*/
#[Assert\NotBlank]
#[Groups(['simple', 'extended', 'full', 'import'])]
protected string $name = '';
/******************************************************************************

View file

@ -33,6 +33,6 @@ use Symfony\Component\Serializer\Annotation\Groups;
*/
abstract class AbstractPartsContainingDBElement extends AbstractStructuralDBElement
{
/** @Groups({"full"}) */
#[Groups(['full'])]
protected Collection $parameters;
}

View file

@ -46,9 +46,8 @@ use Symfony\Component\Serializer\Annotation\Groups;
* @ORM\MappedSuperclass(repositoryClass="App\Repository\StructuralDBElementRepository")
*
* @ORM\EntityListeners({"App\EntityListeners\TreeCacheInvalidationListener"})
*
* @UniqueEntity(fields={"name", "parent"}, ignoreNull=false, message="structural.entity.unique_name")
*/
#[UniqueEntity(fields: ['name', 'parent'], ignoreNull: false, message: 'structural.entity.unique_name')]
abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
{
use ParametersTrait;
@ -63,16 +62,16 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
/**
* @var string The comment info for this element
* @ORM\Column(type="text")
* @Groups({"full", "import"})
*/
#[Groups(['full', 'import'])]
protected string $comment = '';
/**
* @var bool If this property is set, this element can not be selected for part properties.
* Useful if this element should be used only for grouping, sorting.
* @ORM\Column(type="boolean")
* @Groups({"full", "import"})
*/
#[Groups(['full', 'import'])]
protected bool $not_selectable = false;
/**
@ -85,15 +84,15 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
* subclasses.
*
* @var AbstractStructuralDBElement[]|Collection
* @Groups({"include_children"})
*/
#[Groups(['include_children'])]
protected Collection $children;
/**
* @var AbstractStructuralDBElement
* @NoneOfItsChildren()
* @Groups({"include_parents", "import"})
*/
#[Groups(['include_parents', 'import'])]
protected ?AbstractStructuralDBElement $parent = null;
/** @var string[] all names of all parent elements as an array of strings,

View file

@ -35,8 +35,8 @@ trait MasterAttachmentTrait
* @var Attachment|null
* @ORM\ManyToOne(targetEntity="App\Entity\Attachments\Attachment")
* @ORM\JoinColumn(name="id_preview_attachment", referencedColumnName="id", onDelete="SET NULL", nullable=true)
* @Assert\Expression("value == null or value.isPicture()", message="part.master_attachment.must_be_picture")
*/
#[Assert\Expression('value == null or value.isPicture()', message: 'part.master_attachment.must_be_picture')]
protected ?Attachment $master_picture_attachment = null;
/**

View file

@ -34,15 +34,15 @@ trait TimestampTrait
/**
* @var DateTime|null the date when this element was modified the last time
* @ORM\Column(type="datetime", name="last_modified", options={"default":"CURRENT_TIMESTAMP"})
* @Groups({"extended", "full"})
*/
#[Groups(['extended', 'full'])]
protected ?DateTime $lastModified = null;
/**
* @var DateTime|null the date when this element was created
* @ORM\Column(type="datetime", name="datetime_added", options={"default":"CURRENT_TIMESTAMP"})
* @Groups({"extended", "full"})
*/
#[Groups(['extended', 'full'])]
protected ?DateTime $addedDate = null;
/**

View file

@ -57,37 +57,37 @@ class LabelOptions
/**
* @var float The page size of the label in mm
* @Assert\Positive()
* @ORM\Column(type="float")
*/
#[Assert\Positive]
protected float $width = 50.0;
/**
* @var float The page size of the label in mm
* @Assert\Positive()
* @ORM\Column(type="float")
*/
#[Assert\Positive]
protected float $height = 30.0;
/**
* @var string The type of the barcode that should be used in the label (e.g. 'qr')
* @Assert\Choice(choices=LabelOptions::BARCODE_TYPES)
* @ORM\Column(type="string")
*/
#[Assert\Choice(choices: LabelOptions::BARCODE_TYPES)]
protected string $barcode_type = 'none';
/**
* @var string What image should be shown along the
* @Assert\Choice(choices=LabelOptions::PICTURE_TYPES)
* @ORM\Column(type="string")
*/
#[Assert\Choice(choices: LabelOptions::PICTURE_TYPES)]
protected string $picture_type = 'none';
/**
* @var string
* @Assert\Choice(choices=LabelOptions::SUPPORTED_ELEMENTS)
* @ORM\Column(type="string")
*/
#[Assert\Choice(choices: LabelOptions::SUPPORTED_ELEMENTS)]
protected string $supported_element = 'part';
/**
@ -97,9 +97,9 @@ class LabelOptions
protected string $additional_css = '';
/** @var string The mode that will be used to interpret the lines
* @Assert\Choice(choices=LabelOptions::LINES_MODES)
* @ORM\Column(type="string")
*/
#[Assert\Choice(choices: LabelOptions::LINES_MODES)]
protected string $lines_mode = 'html';
/**

View file

@ -52,8 +52,8 @@ use Symfony\Component\Validator\Constraints as Assert;
* @ORM\Entity(repositoryClass="App\Repository\LabelProfileRepository")
* @ORM\Table(name="label_profiles")
* @ORM\EntityListeners({"App\EntityListeners\TreeCacheInvalidationListener"})
* @UniqueEntity({"name", "options.supported_element"})
*/
#[UniqueEntity(['name', 'options.supported_element'])]
class LabelProfile extends AttachmentContainingDBElement
{
/**
@ -66,8 +66,8 @@ class LabelProfile extends AttachmentContainingDBElement
/**
* @var LabelOptions
* @ORM\Embedded(class="LabelOptions")
* @Assert\Valid()
*/
#[Assert\Valid]
protected LabelOptions $options;
/**

View file

@ -83,59 +83,59 @@ abstract class AbstractParameter extends AbstractNamedDBElement
/**
* @var string The mathematical symbol for this specification. Can be rendered pretty later. Should be short
* @Assert\Length(max=20)
* @ORM\Column(type="string", nullable=false)
* @Groups({"full"})
*/
#[Assert\Length(max: 20)]
#[Groups(['full'])]
protected string $symbol = '';
/**
* @var float|null the guaranteed minimum value of this property
* @Assert\Type({"float","null"})
* @Assert\LessThanOrEqual(propertyPath="value_typical", message="parameters.validator.min_lesser_typical")
* @Assert\LessThan(propertyPath="value_max", message="parameters.validator.min_lesser_max")
* @ORM\Column(type="float", nullable=true)
* @Groups({"full"})
*/
#[Assert\Type(['float', null])]
#[Assert\LessThanOrEqual(propertyPath: 'value_typical', message: 'parameters.validator.min_lesser_typical')]
#[Assert\LessThan(propertyPath: 'value_max', message: 'parameters.validator.min_lesser_max')]
#[Groups(['full'])]
protected ?float $value_min = null;
/**
* @var float|null the typical value of this property
* @Assert\Type({"null", "float"})
* @ORM\Column(type="float", nullable=true)
* @Groups({"full"})
*/
#[Assert\Type([null, 'float'])]
#[Groups(['full'])]
protected ?float $value_typical = null;
/**
* @var float|null the maximum value of this property
* @Assert\Type({"float", "null"})
* @Assert\GreaterThanOrEqual(propertyPath="value_typical", message="parameters.validator.max_greater_typical")
* @ORM\Column(type="float", nullable=true)
* @Groups({"full"})
*/
#[Assert\Type(['float', null])]
#[Assert\GreaterThanOrEqual(propertyPath: 'value_typical', message: 'parameters.validator.max_greater_typical')]
#[Groups(['full'])]
protected ?float $value_max = null;
/**
* @var string The unit in which the value values are given (e.g. V)
* @ORM\Column(type="string", nullable=false)
* @Groups({"full"})
*/
#[Groups(['full'])]
protected string $unit = '';
/**
* @var string a text value for the given property
* @ORM\Column(type="string", nullable=false)
* @Groups({"full"})
*/
#[Groups(['full'])]
protected string $value_text = '';
/**
* @var string the group this parameter belongs to
* @ORM\Column(type="string", nullable=false, name="param_group")
* @Groups({"full"})
* @Groups({"full"})
*/
#[Groups(['full'])]
#[Groups(['full'])]
protected string $group = '';
/**

View file

@ -48,8 +48,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
* @UniqueEntity(fields={"name", "group", "element"})
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])]
class AttachmentTypeParameter extends AbstractParameter
{
public const ALLOWED_ELEMENT_CLASS = AttachmentType::class;

View file

@ -48,8 +48,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
* @UniqueEntity(fields={"name", "group", "element"})
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])]
class CategoryParameter extends AbstractParameter
{
public const ALLOWED_ELEMENT_CLASS = Category::class;

View file

@ -50,8 +50,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
* An attachment attached to a category element.
*
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
* @UniqueEntity(fields={"name", "group", "element"})
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])]
class CurrencyParameter extends AbstractParameter
{
public const ALLOWED_ELEMENT_CLASS = Currency::class;

View file

@ -48,8 +48,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
* @UniqueEntity(fields={"name", "group", "element"})
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])]
class FootprintParameter extends AbstractParameter
{
public const ALLOWED_ELEMENT_CLASS = Footprint::class;

View file

@ -48,8 +48,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
* @UniqueEntity(fields={"name", "group", "element"})
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])]
class GroupParameter extends AbstractParameter
{
public const ALLOWED_ELEMENT_CLASS = Group::class;

View file

@ -48,8 +48,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
* @UniqueEntity(fields={"name", "group", "element"})
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])]
class ManufacturerParameter extends AbstractParameter
{
public const ALLOWED_ELEMENT_CLASS = Manufacturer::class;

View file

@ -48,8 +48,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
* @UniqueEntity(fields={"name", "group", "element"})
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])]
class MeasurementUnitParameter extends AbstractParameter
{
public const ALLOWED_ELEMENT_CLASS = MeasurementUnit::class;

View file

@ -50,8 +50,8 @@ trait ParametersTrait
* Mapping done in subclasses.
*
* @var Collection<int, AbstractParameter>
* @Assert\Valid()
*/
#[Assert\Valid]
protected Collection $parameters;
/**

View file

@ -48,8 +48,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
* @UniqueEntity(fields={"name", "group", "element"})
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])]
class PartParameter extends AbstractParameter
{
public const ALLOWED_ELEMENT_CLASS = Part::class;

View file

@ -48,8 +48,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
* @UniqueEntity(fields={"name", "group", "element"})
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])]
class ProjectParameter extends AbstractParameter
{
public const ALLOWED_ELEMENT_CLASS = Project::class;

View file

@ -48,8 +48,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
* @UniqueEntity(fields={"name", "group", "element"})
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])]
class StorelocationParameter extends AbstractParameter
{
public const ALLOWED_ELEMENT_CLASS = Storelocation::class;

View file

@ -48,8 +48,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParameterRepository")
* @UniqueEntity(fields={"name", "group", "element"})
*/
#[UniqueEntity(fields: ['name', 'group', 'element'])]
class SupplierParameter extends AbstractParameter
{
public const ALLOWED_ELEMENT_CLASS = Supplier::class;

View file

@ -58,74 +58,74 @@ class Category extends AbstractPartsContainingDBElement
/**
* @var string
* @ORM\Column(type="text")
* @Groups({"full", "import"})
*/
#[Groups(['full', 'import'])]
protected string $partname_hint = '';
/**
* @var string
* @ORM\Column(type="text")
* @Groups({"full", "import"})
*/
#[Groups(['full', 'import'])]
protected string $partname_regex = '';
/**
* @var bool
* @ORM\Column(type="boolean")
* @Groups({"full", "import"})
*/
#[Groups(['full', 'import'])]
protected bool $disable_footprints = false;
/**
* @var bool
* @ORM\Column(type="boolean")
* @Groups({"full", "import"})
*/
#[Groups(['full', 'import'])]
protected bool $disable_manufacturers = false;
/**
* @var bool
* @ORM\Column(type="boolean")
* @Groups({"full", "import"})
*/
#[Groups(['full', 'import'])]
protected bool $disable_autodatasheets = false;
/**
* @var bool
* @ORM\Column(type="boolean")
* @Groups({"full", "import"})
*/
#[Groups(['full', 'import'])]
protected bool $disable_properties = false;
/**
* @var string
* @ORM\Column(type="text")
* @Groups({"full", "import"})
*/
#[Groups(['full', 'import'])]
protected string $default_description = '';
/**
* @var string
* @ORM\Column(type="text")
* @Groups({"full", "import"})
*/
#[Groups(['full', 'import'])]
protected string $default_comment = '';
/**
* @var Collection<int, CategoryAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\CategoryAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"name" = "ASC"})
* @Assert\Valid()
* @Groups({"full"})
*/
#[Assert\Valid]
#[Groups(['full'])]
protected Collection $attachments;
/** @var Collection<int, CategoryParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\CategoryParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()
* @Groups({"full"})
*/
#[Assert\Valid]
#[Groups(['full'])]
protected Collection $parameters;
public function getPartnameHint(): string

View file

@ -57,8 +57,8 @@ class Footprint extends AbstractPartsContainingDBElement
* @var Collection<int, FootprintAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\FootprintAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"name" = "ASC"})
* @Assert\Valid()
*/
#[Assert\Valid]
protected Collection $attachments;
/**
@ -71,8 +71,8 @@ class Footprint extends AbstractPartsContainingDBElement
/** @var Collection<int, FootprintParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\FootprintParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()
*/
#[Assert\Valid]
protected Collection $parameters;
/****************************************

View file

@ -57,14 +57,14 @@ class Manufacturer extends AbstractCompany
* @var Collection<int, ManufacturerAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\ManufacturerAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"name" = "ASC"})
* @Assert\Valid()
*/
#[Assert\Valid]
protected Collection $attachments;
/** @var Collection<int, ManufacturerParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\ManufacturerParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()
*/
#[Assert\Valid]
protected Collection $parameters;
}

View file

@ -40,34 +40,34 @@ use Symfony\Component\Validator\Constraints as Assert;
* @ORM\Index(name="unit_idx_name", columns={"name"}),
* @ORM\Index(name="unit_idx_parent_name", columns={"parent_id", "name"}),
* })
* @UniqueEntity("unit")
*/
#[UniqueEntity('unit')]
class MeasurementUnit extends AbstractPartsContainingDBElement
{
/**
* @var string The unit symbol that should be used for the Unit. This could be something like "", g (for grams)
* or m (for meters).
* @ORM\Column(type="string", name="unit", nullable=true)
* @Assert\Length(max=10)
* @Groups({"extended", "full", "import"})
*/
#[Assert\Length(max: 10)]
#[Groups(['extended', 'full', 'import'])]
protected ?string $unit = null;
/**
* @var bool Determines if the amount value associated with this unit should be treated as integer.
* Set to false, to measure continuous sizes likes masses or lengths.
* @ORM\Column(type="boolean", name="is_integer")
* @Groups({"extended", "full", "import"})
*/
#[Groups(['extended', 'full', 'import'])]
protected bool $is_integer = false;
/**
* @var bool Determines if the unit can be used with SI Prefixes (kilo, giga, milli, etc.).
* Useful for sizes like meters. For this the unit must be set
* @ORM\Column(type="boolean", name="use_si_prefix")
* @Assert\Expression("this.isUseSIPrefix() == false or this.getUnit() != null", message="validator.measurement_unit.use_si_prefix_needs_unit")
* @Groups({"full", "import"})
*/
#[Assert\Expression('this.isUseSIPrefix() == false or this.getUnit() != null', message: 'validator.measurement_unit.use_si_prefix_needs_unit')]
#[Groups(['full', 'import'])]
protected bool $use_si_prefix = false;
/**
@ -87,15 +87,15 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
* @var Collection<int, MeasurementUnitAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\MeasurementUnitAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"name" = "ASC"})
* @Assert\Valid()
*/
#[Assert\Valid]
protected Collection $attachments;
/** @var Collection<int, MeasurementUnitParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\MeasurementUnitParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()
*/
#[Assert\Valid]
protected Collection $parameters;
/**

View file

@ -54,8 +54,8 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
* @ORM\Index(name="parts_idx_name", columns={"name"}),
* @ORM\Index(name="parts_idx_ipn", columns={"ipn"}),
* })
* @UniqueEntity(fields={"ipn"}, message="part.ipn.must_be_unique")
*/
#[UniqueEntity(fields: ['ipn'], message: 'part.ipn.must_be_unique')]
class Part extends AttachmentContainingDBElement
{
use AdvancedPropertyTrait;
@ -68,11 +68,11 @@ class Part extends AttachmentContainingDBElement
use ProjectTrait;
/** @var Collection<int, PartParameter>
* @Assert\Valid()
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\PartParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Groups({"full"})
*/
#[Assert\Valid]
#[Groups(['full'])]
protected Collection $parameters;
/**
@ -95,9 +95,9 @@ class Part extends AttachmentContainingDBElement
* @var Collection<int, PartAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\PartAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"name" = "ASC"})
* @Assert\Valid()
* @Groups({"full"})
*/
#[Assert\Valid]
#[Groups(['full'])]
protected Collection $attachments;
/**
@ -110,8 +110,8 @@ class Part extends AttachmentContainingDBElement
* @var Attachment|null
* @ORM\ManyToOne(targetEntity="App\Entity\Attachments\Attachment")
* @ORM\JoinColumn(name="id_preview_attachment", referencedColumnName="id", onDelete="SET NULL", nullable=true)
* @Assert\Expression("value == null or value.isPicture()", message="part.master_attachment.must_be_picture")
*/
#[Assert\Expression('value == null or value.isPicture()', message: 'part.master_attachment.must_be_picture')]
protected ?Attachment $master_picture_attachment = null;
public function __construct()
@ -150,9 +150,7 @@ class Part extends AttachmentContainingDBElement
parent::__clone();
}
/**
* @Assert\Callback
*/
#[Assert\Callback]
public function validate(ExecutionContextInterface $context, $payload)
{
//Ensure that the part name fullfills the regex of the category

View file

@ -55,23 +55,23 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
/**
* @var string A short description about this lot, shown in table
* @ORM\Column(type="text")
* @Groups({"simple", "extended", "full", "import"})
*/
#[Groups(['simple', 'extended', 'full', 'import'])]
protected string $description = '';
/**
* @var string a comment stored with this lot
* @ORM\Column(type="text")
* @Groups({"full", "import"})
*/
#[Groups(['full', 'import'])]
protected string $comment = '';
/**
* @var ?DateTime Set a time until when the lot must be used.
* Set to null, if the lot can be used indefinitely.
* @ORM\Column(type="datetime", name="expiration_date", nullable=true)
* @Groups({"extended", "full", "import"})
*/
#[Groups(['extended', 'full', 'import'])]
protected ?DateTime $expiration_date = null;
/**
@ -79,38 +79,38 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
* @ORM\ManyToOne(targetEntity="Storelocation")
* @ORM\JoinColumn(name="id_store_location", referencedColumnName="id", nullable=true)
* @Selectable()
* @Groups({"simple", "extended", "full", "import"})
*/
#[Groups(['simple', 'extended', 'full', 'import'])]
protected ?Storelocation $storage_location = null;
/**
* @var bool If this is set to true, the instock amount is marked as not known
* @ORM\Column(type="boolean")
* @Groups({"simple", "extended", "full", "import"})
*/
#[Groups(['simple', 'extended', 'full', 'import'])]
protected bool $instock_unknown = false;
/**
* @var float For continuous sizes (length, volume, etc.) the instock is saved here.
* @ORM\Column(type="float")
* @Assert\PositiveOrZero()
* @Groups({"simple", "extended", "full", "import"})
*/
#[Assert\PositiveOrZero]
#[Groups(['simple', 'extended', 'full', 'import'])]
protected float $amount = 0.0;
/**
* @var bool determines if this lot was manually marked for refilling
* @ORM\Column(type="boolean")
* @Groups({"extended", "full", "import"})
*/
#[Groups(['extended', 'full', 'import'])]
protected bool $needs_refill = false;
/**
* @var Part The part that is stored in this lot
* @ORM\ManyToOne(targetEntity="Part", inversedBy="partLots")
* @ORM\JoinColumn(name="id_part", referencedColumnName="id", nullable=false, onDelete="CASCADE")
* @Assert\NotNull()
*/
#[Assert\NotNull]
protected Part $part;
/**
@ -338,9 +338,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
return $this->description;
}
/**
* @Assert\Callback
*/
#[Assert\Callback]
public function validate(ExecutionContextInterface $context, $payload)
{
//Ensure that the owner is not the anonymous user

View file

@ -35,31 +35,31 @@ trait AdvancedPropertyTrait
/**
* @var bool Determines if this part entry needs review (for example, because it is work in progress)
* @ORM\Column(type="boolean")
* @Groups({"extended", "full", "import"})
*/
#[Groups(['extended', 'full', 'import'])]
protected bool $needs_review = false;
/**
* @var string a comma separated list of tags, associated with the part
* @ORM\Column(type="text")
* @Groups({"extended", "full", "import"})
*/
#[Groups(['extended', 'full', 'import'])]
protected string $tags = '';
/**
* @var float|null how much a single part unit weighs in grams
* @ORM\Column(type="float", nullable=true)
* @Assert\PositiveOrZero()
* @Groups({"extended", "full", "import"})
*/
#[Assert\PositiveOrZero]
#[Groups(['extended', 'full', 'import'])]
protected ?float $mass = null;
/**
* @var string|null The internal part number of the part
* @ORM\Column(type="string", length=100, nullable=true, unique=true)
* @Assert\Length(max="100")
* @Groups({"extended", "full", "import"})
*/
#[Assert\Length(max: 100)]
#[Groups(['extended', 'full', 'import'])]
protected ?string $ipn = null;
/**

View file

@ -34,15 +34,15 @@ trait BasicPropertyTrait
/**
* @var string A text describing what this part does
* @ORM\Column(type="text")
* @Groups({"simple", "extended", "full", "import"})
*/
#[Groups(['simple', 'extended', 'full', 'import'])]
protected string $description = '';
/**
* @var string A comment/note related to this part
* @ORM\Column(type="text")
* @Groups({"extended", "full", "import"})
*/
#[Groups(['extended', 'full', 'import'])]
protected string $comment = '';
/**
@ -54,8 +54,8 @@ trait BasicPropertyTrait
/**
* @var bool true, if the part is marked as favorite
* @ORM\Column(type="boolean")
* @Groups({"extended", "full", "import"})
*/
#[Groups(['extended', 'full', 'import'])]
protected bool $favorite = false;
/**
@ -64,9 +64,9 @@ trait BasicPropertyTrait
* @ORM\ManyToOne(targetEntity="Category")
* @ORM\JoinColumn(name="id_category", referencedColumnName="id", nullable=false)
* @Selectable()
* @Assert\NotNull(message="validator.select_valid_category")
* @Groups({"simple", "extended", "full", "import"})
*/
#[Assert\NotNull(message: 'validator.select_valid_category')]
#[Groups(['simple', 'extended', 'full', 'import'])]
protected ?Category $category = null;
/**
@ -74,8 +74,8 @@ trait BasicPropertyTrait
* @ORM\ManyToOne(targetEntity="Footprint")
* @ORM\JoinColumn(name="id_footprint", referencedColumnName="id")
* @Selectable()
* @Groups({"simple", "extended", "full", "import"})
*/
#[Groups(['simple', 'extended', 'full', 'import'])]
protected ?Footprint $footprint = null;
/**

View file

@ -37,27 +37,27 @@ trait InstockTrait
/**
* @var Collection|PartLot[] A list of part lots where this part is stored
* @ORM\OneToMany(targetEntity="PartLot", mappedBy="part", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
* @ORM\OrderBy({"amount" = "DESC"})
* @Groups({"extended", "full", "import"})
*/
#[Assert\Valid]
#[Groups(['extended', 'full', 'import'])]
protected $partLots;
/**
* @var float The minimum amount of the part that has to be instock, otherwise more is ordered.
* Given in the partUnit.
* @ORM\Column(type="float")
* @Assert\PositiveOrZero()
* @Groups({"extended", "full", "import"})
*/
#[Assert\PositiveOrZero]
#[Groups(['extended', 'full', 'import'])]
protected float $minamount = 0;
/**
* @var ?MeasurementUnit the unit in which the part's amount is measured
* @ORM\ManyToOne(targetEntity="MeasurementUnit")
* @ORM\JoinColumn(name="id_part_unit", referencedColumnName="id", nullable=true)
* @Groups({"extended", "full", "import"})
*/
#[Groups(['extended', 'full', 'import'])]
protected ?MeasurementUnit $partUnit = null;
/**

View file

@ -39,31 +39,31 @@ trait ManufacturerTrait
* @ORM\ManyToOne(targetEntity="Manufacturer")
* @ORM\JoinColumn(name="id_manufacturer", referencedColumnName="id")
* @Selectable()
* @Groups({"simple","extended", "full", "import"})
*/
#[Groups(['simple', 'extended', 'full', 'import'])]
protected ?Manufacturer $manufacturer = null;
/**
* @var string the url to the part on the manufacturer's homepage
* @ORM\Column(type="string")
* @Assert\Url()
* @Groups({"full", "import"})
*/
#[Assert\Url]
#[Groups(['full', 'import'])]
protected string $manufacturer_product_url = '';
/**
* @var string The product number used by the manufacturer. If this is set to "", the name field is used.
* @ORM\Column(type="string")
* @Groups({"extended", "full", "import"})
*/
#[Groups(['extended', 'full', 'import'])]
protected string $manufacturer_product_number = '';
/**
* @var string|null The production status of this part. Can be one of the specified ones.
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\Choice({"announced", "active", "nrfnd", "eol", "discontinued", ""})
* @Groups({"extended", "full", "import"})
*/
#[Assert\Choice(['announced', 'active', 'nrfnd', 'eol', 'discontinued', ''])]
#[Groups(['extended', 'full', 'import'])]
protected ?string $manufacturing_status = '';
/**

View file

@ -37,10 +37,10 @@ trait OrderTrait
/**
* @var Orderdetail[]|Collection the details about how and where you can order this part
* @ORM\OneToMany(targetEntity="App\Entity\PriceInformations\Orderdetail", mappedBy="part", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
* @ORM\OrderBy({"supplierpartnr" = "ASC"})
* @Groups({"extended", "full", "import"})
*/
#[Assert\Valid]
#[Groups(['extended', 'full', 'import'])]
protected $orderdetails;
/**

View file

@ -66,37 +66,37 @@ class Storelocation extends AbstractPartsContainingDBElement
/** @var Collection<int, StorelocationParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\StorelocationParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()
*/
#[Assert\Valid]
protected Collection $parameters;
/**
* @var bool
* @ORM\Column(type="boolean")
* @Groups({"full", "import"})
*/
#[Groups(['full', 'import'])]
protected bool $is_full = false;
/**
* @var bool
* @ORM\Column(type="boolean")
* @Groups({"full", "import"})
*/
#[Groups(['full', 'import'])]
protected bool $only_single_part = false;
/**
* @var bool
* @ORM\Column(type="boolean")
* @Groups({"full", "import"})
*/
#[Groups(['full', 'import'])]
protected bool $limit_to_existing_parts = false;
/**
* @var User|null The owner of this storage location
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User")
* @ORM\JoinColumn(name="id_owner", referencedColumnName="id", nullable=true, onDelete="SET NULL")
* @Assert\Expression("this.getOwner() == null or this.getOwner().isAnonymousUser() === false", message="validator.part_lot.owner_must_not_be_anonymous")
*/
#[Assert\Expression('this.getOwner() == null or this.getOwner().isAnonymousUser() === false', message: 'validator.part_lot.owner_must_not_be_anonymous')]
protected ?User $owner = null;
/**
@ -108,8 +108,8 @@ class Storelocation extends AbstractPartsContainingDBElement
/**
* @var Collection<int, StorelocationAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\StorelocationAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
*/
#[Assert\Valid]
protected Collection $attachments;
/********************************************************************************

View file

@ -76,24 +76,24 @@ class Supplier extends AbstractCompany
/**
* @var BigDecimal|null the shipping costs that have to be paid, when ordering via this supplier
* @ORM\Column(name="shipping_costs", nullable=true, type="big_decimal", precision=11, scale=5)
* @Groups({"extended", "full", "import"})
* @BigDecimalPositiveOrZero()
*/
#[Groups(['extended', 'full', 'import'])]
protected ?BigDecimal $shipping_costs = null;
/**
* @var Collection<int, SupplierAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\SupplierAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"name" = "ASC"})
* @Assert\Valid()
*/
#[Assert\Valid]
protected Collection $attachments;
/** @var Collection<int, SupplierParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\SupplierParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()
*/
#[Assert\Valid]
protected Collection $parameters;
/**

View file

@ -38,13 +38,13 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* This entity describes a currency that can be used for price information.
*
* @UniqueEntity("iso_code")
* @ORM\Entity()
* @ORM\Table(name="currencies", indexes={
* @ORM\Index(name="currency_idx_name", columns={"name"}),
* @ORM\Index(name="currency_idx_parent_name", columns={"parent_id", "name"}),
* })
*/
#[UniqueEntity('iso_code')]
class Currency extends AbstractStructuralDBElement
{
public const PRICE_SCALE = 5;
@ -60,9 +60,9 @@ class Currency extends AbstractStructuralDBElement
/**
* @var string the 3-letter ISO code of the currency
* @ORM\Column(type="string")
* @Assert\Currency()
* @Groups({"extended", "full", "import"})
*/
#[Assert\Currency]
#[Groups(['extended', 'full', 'import'])]
protected string $iso_code = "";
/**
@ -81,15 +81,15 @@ class Currency extends AbstractStructuralDBElement
* @var Collection<int, CurrencyAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\CurrencyAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"name" = "ASC"})
* @Assert\Valid()
*/
#[Assert\Valid]
protected Collection $attachments;
/** @var Collection<int, CurrencyParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\CurrencyParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()
*/
#[Assert\Valid]
protected Collection $parameters;
/** @var Collection<int, Pricedetail>

View file

@ -45,57 +45,57 @@ use Symfony\Component\Validator\Constraints as Assert;
* })
* @ORM\Entity()
* @ORM\HasLifecycleCallbacks()
* @UniqueEntity({"supplierpartnr", "supplier", "part"})
*/
#[UniqueEntity(['supplierpartnr', 'supplier', 'part'])]
class Orderdetail extends AbstractDBElement implements TimeStampableInterface, NamedElementInterface
{
use TimestampTrait;
/**
* @ORM\OneToMany(targetEntity="Pricedetail", mappedBy="orderdetail", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
* @ORM\OrderBy({"min_discount_quantity" = "ASC"})
* @Groups({"extended", "full", "import"})
*/
#[Assert\Valid]
#[Groups(['extended', 'full', 'import'])]
protected Collection $pricedetails;
/**
* @var string
* @ORM\Column(type="string")
* @Groups({"extended", "full", "import"})
*/
#[Groups(['extended', 'full', 'import'])]
protected string $supplierpartnr = '';
/**
* @var bool
* @ORM\Column(type="boolean")
* @Groups({"extended", "full", "import"})
*/
#[Groups(['extended', 'full', 'import'])]
protected bool $obsolete = false;
/**
* @var string
* @ORM\Column(type="string")
* @Assert\Url()
* @Groups({"full", "import"})
*/
#[Assert\Url]
#[Groups(['full', 'import'])]
protected string $supplier_product_url = '';
/**
* @var Part|null
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Part", inversedBy="orderdetails")
* @ORM\JoinColumn(name="part_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
* @Assert\NotNull()
*/
#[Assert\NotNull]
protected ?Part $part = null;
/**
* @var Supplier|null
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Supplier", inversedBy="orderdetails")
* @ORM\JoinColumn(name="id_supplier", referencedColumnName="id")
* @Assert\NotNull(message="validator.orderdetail.supplier_must_not_be_null")
* @Groups({"extended", "full", "import"})
*/
#[Assert\NotNull(message: 'validator.orderdetail.supplier_must_not_be_null')]
#[Groups(['extended', 'full', 'import'])]
protected ?Supplier $supplier = null;
public function __construct()

Some files were not shown because too many files have changed in this diff Show more