mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Fixed some inspection issues.
This commit is contained in:
parent
6caf605fe2
commit
e01b06fb85
80 changed files with 173 additions and 218 deletions
|
@ -66,6 +66,7 @@ body {
|
||||||
/** Hide scrollbar in old Firefox and Edge **/
|
/** Hide scrollbar in old Firefox and Edge **/
|
||||||
-ms-overflow-style: none;
|
-ms-overflow-style: none;
|
||||||
overflow: -moz-scrollbars-none;
|
overflow: -moz-scrollbars-none;
|
||||||
|
/*noinspection CssUnknownProperty*/
|
||||||
scrollbar-width: none;
|
scrollbar-width: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -764,7 +765,6 @@ div.dataTables_wrapper div.dataTables_info {
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
padding: 4px 0;
|
padding: 4px 0;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border: 1px solid #ccc;
|
|
||||||
border: 1px solid rgba(0, 0, 0, 0.2);
|
border: 1px solid rgba(0, 0, 0, 0.2);
|
||||||
-webkit-border-radius: 4px;
|
-webkit-border-radius: 4px;
|
||||||
-moz-border-radius: 4px;
|
-moz-border-radius: 4px;
|
||||||
|
@ -805,7 +805,7 @@ div.dataTables_wrapper div.dataTables_info {
|
||||||
|
|
||||||
.markdown pre {
|
.markdown pre {
|
||||||
display: block;
|
display: block;
|
||||||
padding: 9.5px;
|
padding: 10px;
|
||||||
margin: 0 0 10px;
|
margin: 0 0 10px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
line-height: 1.42857143;
|
line-height: 1.42857143;
|
||||||
|
@ -825,7 +825,7 @@ div.dataTables_wrapper div.dataTables_info {
|
||||||
.markdown blockquote {
|
.markdown blockquote {
|
||||||
padding: 10px 10px;
|
padding: 10px 10px;
|
||||||
margin: 0 0 10px;
|
margin: 0 0 10px;
|
||||||
font-size: 17.5px;
|
font-size: 18px;
|
||||||
border-left: 5px solid #aaa;
|
border-left: 5px solid #aaa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,7 @@ class CleanAttachmentsCommand extends Command
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function removeEmptySubFolders($path)
|
protected function removeEmptySubFolders($path): bool
|
||||||
{
|
{
|
||||||
$empty = true;
|
$empty = true;
|
||||||
foreach (glob($path.DIRECTORY_SEPARATOR.'*') as $file) {
|
foreach (glob($path.DIRECTORY_SEPARATOR.'*') as $file) {
|
||||||
|
|
|
@ -52,7 +52,7 @@ final class PermissionsConfiguration implements ConfigurationInterface
|
||||||
*
|
*
|
||||||
* @return TreeBuilder The tree builder
|
* @return TreeBuilder The tree builder
|
||||||
*/
|
*/
|
||||||
public function getConfigTreeBuilder()
|
public function getConfigTreeBuilder(): TreeBuilder
|
||||||
{
|
{
|
||||||
$treeBuilder = new TreeBuilder('permissions');
|
$treeBuilder = new TreeBuilder('permissions');
|
||||||
$rootNode = $treeBuilder->getRootNode();
|
$rootNode = $treeBuilder->getRootNode();
|
||||||
|
|
|
@ -113,12 +113,10 @@ class AttachmentTypeController extends BaseAdminController
|
||||||
|
|
||||||
protected function deleteCheck(AbstractNamedDBElement $entity): bool
|
protected function deleteCheck(AbstractNamedDBElement $entity): bool
|
||||||
{
|
{
|
||||||
if ($entity instanceof AttachmentType) {
|
if (($entity instanceof AttachmentType) && $entity->getAttachmentsForType()->count() > 0) {
|
||||||
if ($entity->getAttachmentsForType()->count() > 0) {
|
$this->addFlash('error', 'entity.delete.must_not_contain_attachments');
|
||||||
$this->addFlash('error', 'entity.delete.must_not_contain_attachments');
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -192,7 +192,7 @@ abstract class BaseAdminController extends AbstractController
|
||||||
$form_options = [
|
$form_options = [
|
||||||
'attachment_class' => $this->attachment_class,
|
'attachment_class' => $this->attachment_class,
|
||||||
'parameter_class' => $this->parameter_class,
|
'parameter_class' => $this->parameter_class,
|
||||||
'disabled' => null !== $timeTravel_timestamp ? true : false,
|
'disabled' => null !== $timeTravel_timestamp,
|
||||||
];
|
];
|
||||||
|
|
||||||
//Disable editing of options, if user is not allowed to use twig...
|
//Disable editing of options, if user is not allowed to use twig...
|
||||||
|
@ -476,7 +476,7 @@ abstract class BaseAdminController extends AbstractController
|
||||||
return $exporter->exportEntityFromRequest($entities, $request);
|
return $exporter->exportEntityFromRequest($entities, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _exportEntity(AbstractNamedDBElement $entity, EntityExporter $exporter, Request $request): \Symfony\Component\HttpFoundation\Response
|
protected function _exportEntity(AbstractNamedDBElement $entity, EntityExporter $exporter, Request $request): Response
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('read', $entity);
|
$this->denyAccessUnlessGranted('read', $entity);
|
||||||
|
|
||||||
|
|
|
@ -187,12 +187,10 @@ class CurrencyController extends BaseAdminController
|
||||||
|
|
||||||
public function deleteCheck(AbstractNamedDBElement $entity): bool
|
public function deleteCheck(AbstractNamedDBElement $entity): bool
|
||||||
{
|
{
|
||||||
if ($entity instanceof Currency) {
|
if (($entity instanceof Currency) && $entity->getPricedetails()->count() > 0) {
|
||||||
if ($entity->getPricedetails()->count() > 0) {
|
$this->addFlash('error', 'entity.delete.must_not_contain_prices');
|
||||||
$this->addFlash('error', 'entity.delete.must_not_contain_prices');
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -82,7 +82,7 @@ class ManufacturerController extends BaseAdminController
|
||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function edit(Manufacturer $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null)
|
public function edit(Manufacturer $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
|
||||||
{
|
{
|
||||||
return $this->_edit($entity, $request, $em, $timestamp);
|
return $this->_edit($entity, $request, $em, $timestamp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ class MeasurementUnitController extends BaseAdminController
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function delete(Request $request, MeasurementUnit $entity, StructuralElementRecursionHelper $recursionHelper)
|
public function delete(Request $request, MeasurementUnit $entity, StructuralElementRecursionHelper $recursionHelper): \Symfony\Component\HttpFoundation\RedirectResponse
|
||||||
{
|
{
|
||||||
return $this->_delete($request, $entity, $recursionHelper);
|
return $this->_delete($request, $entity, $recursionHelper);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ class MeasurementUnitController extends BaseAdminController
|
||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function edit(MeasurementUnit $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null)
|
public function edit(MeasurementUnit $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
|
||||||
{
|
{
|
||||||
return $this->_edit($entity, $request, $em, $timestamp);
|
return $this->_edit($entity, $request, $em, $timestamp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ use App\Services\EntityExporter;
|
||||||
use App\Services\EntityImporter;
|
use App\Services\EntityImporter;
|
||||||
use App\Services\StructuralElementRecursionHelper;
|
use App\Services\StructuralElementRecursionHelper;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
@ -70,7 +71,7 @@ class StorelocationController extends BaseAdminController
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function delete(Request $request, Storelocation $entity, StructuralElementRecursionHelper $recursionHelper)
|
public function delete(Request $request, Storelocation $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
|
||||||
{
|
{
|
||||||
return $this->_delete($request, $entity, $recursionHelper);
|
return $this->_delete($request, $entity, $recursionHelper);
|
||||||
}
|
}
|
||||||
|
@ -81,7 +82,7 @@ class StorelocationController extends BaseAdminController
|
||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function edit(Storelocation $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null)
|
public function edit(Storelocation $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
|
||||||
{
|
{
|
||||||
return $this->_edit($entity, $request, $em, $timestamp);
|
return $this->_edit($entity, $request, $em, $timestamp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ use App\Services\EntityExporter;
|
||||||
use App\Services\EntityImporter;
|
use App\Services\EntityImporter;
|
||||||
use App\Services\StructuralElementRecursionHelper;
|
use App\Services\StructuralElementRecursionHelper;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
@ -71,7 +72,7 @@ class SupplierController extends BaseAdminController
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function delete(Request $request, Supplier $entity, StructuralElementRecursionHelper $recursionHelper)
|
public function delete(Request $request, Supplier $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
|
||||||
{
|
{
|
||||||
return $this->_delete($request, $entity, $recursionHelper);
|
return $this->_delete($request, $entity, $recursionHelper);
|
||||||
}
|
}
|
||||||
|
@ -82,7 +83,7 @@ class SupplierController extends BaseAdminController
|
||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function edit(Supplier $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null)
|
public function edit(Supplier $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
|
||||||
{
|
{
|
||||||
return $this->_edit($entity, $request, $em, $timestamp);
|
return $this->_edit($entity, $request, $em, $timestamp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,12 +114,10 @@ class GroupController extends BaseAdminController
|
||||||
|
|
||||||
public function deleteCheck(AbstractNamedDBElement $entity): bool
|
public function deleteCheck(AbstractNamedDBElement $entity): bool
|
||||||
{
|
{
|
||||||
if ($entity instanceof Group) {
|
if (($entity instanceof Group) && $entity->getUsers()->count() > 0) {
|
||||||
if ($entity->getUsers()->count() > 0) {
|
$this->addFlash('error', 'entity.delete.must_not_contain_users');
|
||||||
$this->addFlash('error', 'entity.delete.must_not_contain_users');
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -34,9 +34,9 @@ use App\Services\LabelSystem\LabelGenerator;
|
||||||
use App\Services\Misc\RangeParser;
|
use App\Services\Misc\RangeParser;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Form\Form;
|
|
||||||
use Symfony\Component\Form\FormError;
|
use Symfony\Component\Form\FormError;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ class LabelController extends AbstractController
|
||||||
* @Route("/dialog", name="label_dialog")
|
* @Route("/dialog", name="label_dialog")
|
||||||
* @Route("/{profile}/dialog", name="label_dialog_profile")
|
* @Route("/{profile}/dialog", name="label_dialog_profile")
|
||||||
*/
|
*/
|
||||||
public function generator(Request $request, ?LabelProfile $profile = null)
|
public function generator(Request $request, ?LabelProfile $profile = null): Response
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('@labels.create_labels');
|
$this->denyAccessUnlessGranted('@labels.create_labels');
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ class TypeaheadController extends AbstractController
|
||||||
*
|
*
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function builtInResources(Request $request, BuiltinAttachmentsFinder $finder)
|
public function builtInResources(Request $request, BuiltinAttachmentsFinder $finder): JsonResponse
|
||||||
{
|
{
|
||||||
$query = $request->get('query');
|
$query = $request->get('query');
|
||||||
$array = $finder->find($query);
|
$array = $finder->find($query);
|
||||||
|
@ -106,7 +106,7 @@ class TypeaheadController extends AbstractController
|
||||||
*
|
*
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function tags(string $query, TagFinder $finder)
|
public function tags(string $query, TagFinder $finder): JsonResponse
|
||||||
{
|
{
|
||||||
$array = $finder->searchTags($query);
|
$array = $finder->searchTags($query);
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ use InvalidArgumentException;
|
||||||
use Omines\DataTablesBundle\DataTableFactory;
|
use Omines\DataTablesBundle\DataTableFactory;
|
||||||
use Symfony\Component\Asset\Packages;
|
use Symfony\Component\Asset\Packages;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
@ -100,7 +101,7 @@ class UserController extends AdminPages\BaseAdminController
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function edit(User $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null)
|
public function edit(User $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
|
||||||
{
|
{
|
||||||
//Handle 2FA disabling
|
//Handle 2FA disabling
|
||||||
|
|
||||||
|
@ -170,7 +171,7 @@ class UserController extends AdminPages\BaseAdminController
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function delete(Request $request, User $entity, StructuralElementRecursionHelper $recursionHelper)
|
public function delete(Request $request, User $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
|
||||||
{
|
{
|
||||||
if (User::ID_ANONYMOUS === $entity->getID()) {
|
if (User::ID_ANONYMOUS === $entity->getID()) {
|
||||||
throw new InvalidArgumentException('You can not delete the anonymous user! It is needed for permission checking without a logged in user');
|
throw new InvalidArgumentException('You can not delete the anonymous user! It is needed for permission checking without a logged in user');
|
||||||
|
|
|
@ -153,7 +153,7 @@ class FetchJoinORMAdapter extends ORMAdapter
|
||||||
$query->setIdentifierPropertyPath($this->mapFieldToPropertyPath($identifier, $aliases));
|
$query->setIdentifierPropertyPath($this->mapFieldToPropertyPath($identifier, $aliases));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getSimpleTotalCount(QueryBuilder $queryBuilder)
|
protected function getSimpleTotalCount(QueryBuilder $queryBuilder): int
|
||||||
{
|
{
|
||||||
/** The paginator count queries can be rather slow, so when query for total count (100ms or longer),
|
/** The paginator count queries can be rather slow, so when query for total count (100ms or longer),
|
||||||
* just return the entity count.
|
* just return the entity count.
|
||||||
|
|
|
@ -191,8 +191,8 @@ class ORMAdapter extends AbstractAdapter
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $builder->getQuery();
|
$q = $builder->getQuery();
|
||||||
$event = new ORMAdapterQueryEvent($query);
|
$event = new ORMAdapterQueryEvent($q);
|
||||||
$state->getDataTable()->getEventDispatcher()->dispatch($event, ORMAdapterEvents::PRE_QUERY);
|
$state->getDataTable()->getEventDispatcher()->dispatch($event, ORMAdapterEvents::PRE_QUERY);
|
||||||
|
|
||||||
foreach ($query->iterate([], $this->hydrationMode) as $result) {
|
foreach ($query->iterate([], $this->hydrationMode) as $result) {
|
||||||
|
@ -301,7 +301,7 @@ class ORMAdapter extends AbstractAdapter
|
||||||
->setDefaults([
|
->setDefaults([
|
||||||
'hydrate' => Query::HYDRATE_OBJECT,
|
'hydrate' => Query::HYDRATE_OBJECT,
|
||||||
'query' => [],
|
'query' => [],
|
||||||
'criteria' => function (Options $options) {
|
'criteria' => static function (Options $options) {
|
||||||
return [new SearchCriteriaProvider()];
|
return [new SearchCriteriaProvider()];
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
@ -324,7 +324,9 @@ class ORMAdapter extends AbstractAdapter
|
||||||
{
|
{
|
||||||
if ($provider instanceof QueryBuilderProcessorInterface) {
|
if ($provider instanceof QueryBuilderProcessorInterface) {
|
||||||
return $provider;
|
return $provider;
|
||||||
} elseif (is_callable($provider)) {
|
}
|
||||||
|
|
||||||
|
if (is_callable($provider)) {
|
||||||
return new class($provider) implements QueryBuilderProcessorInterface {
|
return new class($provider) implements QueryBuilderProcessorInterface {
|
||||||
private $callable;
|
private $callable;
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ class EntityColumn extends AbstractColumn
|
||||||
|
|
||||||
$resolver->setRequired('property');
|
$resolver->setRequired('property');
|
||||||
|
|
||||||
$resolver->setDefault('field', function (Options $option) {
|
$resolver->setDefault('field', static function (Options $option) {
|
||||||
return $option['property'].'.name';
|
return $option['property'].'.name';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ class IconLinkColumn extends AbstractColumn
|
||||||
return $provider;
|
return $provider;
|
||||||
}
|
}
|
||||||
if (is_callable($provider)) {
|
if (is_callable($provider)) {
|
||||||
return call_user_func($provider, $value, $context);
|
return $provider($value, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -91,7 +91,7 @@ class IconLinkColumn extends AbstractColumn
|
||||||
return $provider;
|
return $provider;
|
||||||
}
|
}
|
||||||
if (is_callable($provider)) {
|
if (is_callable($provider)) {
|
||||||
return call_user_func($provider, $value, $context);
|
return $provider($value, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -104,7 +104,7 @@ class IconLinkColumn extends AbstractColumn
|
||||||
return $provider;
|
return $provider;
|
||||||
}
|
}
|
||||||
if (is_callable($provider)) {
|
if (is_callable($provider)) {
|
||||||
return call_user_func($provider, $value, $context);
|
return $provider($value, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -117,7 +117,7 @@ class IconLinkColumn extends AbstractColumn
|
||||||
return $provider;
|
return $provider;
|
||||||
}
|
}
|
||||||
if (is_callable($provider)) {
|
if (is_callable($provider)) {
|
||||||
return call_user_func($provider, $value, $context);
|
return $provider($value, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -102,7 +102,7 @@ class LogDataTable implements DataTableTypeInterface
|
||||||
$optionsResolver->setAllowedTypes('filter_elements', ['array', 'object']);
|
$optionsResolver->setAllowedTypes('filter_elements', ['array', 'object']);
|
||||||
$optionsResolver->setAllowedTypes('mode', 'string');
|
$optionsResolver->setAllowedTypes('mode', 'string');
|
||||||
|
|
||||||
$optionsResolver->setNormalizer('filter_elements', function (Options $options, $value) {
|
$optionsResolver->setNormalizer('filter_elements', static function (Options $options, $value) {
|
||||||
if (!is_array($value)) {
|
if (!is_array($value)) {
|
||||||
return [$value];
|
return [$value];
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ class LogDataTable implements DataTableTypeInterface
|
||||||
|
|
||||||
$dataTable->add('symbol', TextColumn::class, [
|
$dataTable->add('symbol', TextColumn::class, [
|
||||||
'label' => '',
|
'label' => '',
|
||||||
'render' => function ($value, AbstractLogEntry $context) {
|
'render' => static function ($value, AbstractLogEntry $context) {
|
||||||
switch ($context->getLevelString()) {
|
switch ($context->getLevelString()) {
|
||||||
case LogLevel::DEBUG:
|
case LogLevel::DEBUG:
|
||||||
$symbol = 'fa-bug';
|
$symbol = 'fa-bug';
|
||||||
|
@ -191,7 +191,7 @@ class LogDataTable implements DataTableTypeInterface
|
||||||
'label' => $this->translator->trans('log.level'),
|
'label' => $this->translator->trans('log.level'),
|
||||||
'visible' => 'system_log' === $options['mode'],
|
'visible' => 'system_log' === $options['mode'],
|
||||||
'propertyPath' => 'levelString',
|
'propertyPath' => 'levelString',
|
||||||
'render' => function (string $value, AbstractLogEntry $context) {
|
'render' => static function (string $value, AbstractLogEntry $context) {
|
||||||
return $value;
|
return $value;
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -118,7 +118,7 @@ final class PartsDataTable implements DataTableTypeInterface
|
||||||
$optionsResolver->setAllowedTypes('search', ['null', 'string']);
|
$optionsResolver->setAllowedTypes('search', ['null', 'string']);
|
||||||
|
|
||||||
//Configure search options
|
//Configure search options
|
||||||
$optionsResolver->setDefault('search_options', function (OptionsResolver $resolver): void {
|
$optionsResolver->setDefault('search_options', static function (OptionsResolver $resolver): void {
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'name' => true,
|
'name' => true,
|
||||||
'category' => true,
|
'category' => true,
|
||||||
|
|
|
@ -92,7 +92,7 @@ class LabelProfile extends AttachmentContainingDBElement
|
||||||
return $this->comment;
|
return $this->comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setComment(string $new_comment): string
|
public function setComment(string $new_comment): self
|
||||||
{
|
{
|
||||||
$this->comment = $new_comment;
|
$this->comment = $new_comment;
|
||||||
|
|
||||||
|
|
|
@ -93,11 +93,7 @@ class SecurityEventLogEntry extends AbstractLogEntry
|
||||||
public function getEventType(): string
|
public function getEventType(): string
|
||||||
{
|
{
|
||||||
$key = $this->extra['e'];
|
$key = $this->extra['e'];
|
||||||
if (isset(static::SECURITY_TYPE_MAPPING[$key])) {
|
return static::SECURITY_TYPE_MAPPING[$key] ?? 'unkown';
|
||||||
return static::SECURITY_TYPE_MAPPING[$key];
|
|
||||||
}
|
|
||||||
|
|
||||||
return 'unkown';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,7 +41,7 @@ trait ParametersTrait
|
||||||
*
|
*
|
||||||
* @psalm-return Collection<int, PartParameter>
|
* @psalm-return Collection<int, PartParameter>
|
||||||
*/
|
*/
|
||||||
public function getParameters(): \Doctrine\Common\Collections\Collection
|
public function getParameters(): Collection
|
||||||
{
|
{
|
||||||
return $this->parameters;
|
return $this->parameters;
|
||||||
}
|
}
|
||||||
|
|
|
@ -331,7 +331,8 @@ class EventLoggerSubscriber implements EventSubscriber
|
||||||
$old_data = $this->filterFieldRestrictions($entity, $old_data);
|
$old_data = $this->filterFieldRestrictions($entity, $old_data);
|
||||||
|
|
||||||
//Restrict length of string fields, to save memory...
|
//Restrict length of string fields, to save memory...
|
||||||
$old_data = array_map(function ($value) {
|
$old_data = array_map(
|
||||||
|
static function ($value) {
|
||||||
if (is_string($value)) {
|
if (is_string($value)) {
|
||||||
return mb_strimwidth($value, 0, self::MAX_STRING_LENGTH, '...');
|
return mb_strimwidth($value, 0, self::MAX_STRING_LENGTH, '...');
|
||||||
}
|
}
|
||||||
|
@ -350,10 +351,6 @@ class EventLoggerSubscriber implements EventSubscriber
|
||||||
protected function validEntity(object $entity): bool
|
protected function validEntity(object $entity): bool
|
||||||
{
|
{
|
||||||
//Dont log logentries itself!
|
//Dont log logentries itself!
|
||||||
if ($entity instanceof AbstractDBElement && !$entity instanceof AbstractLogEntry) {
|
return $entity instanceof AbstractDBElement && !$entity instanceof AbstractLogEntry;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ final class SecurityEventLoggerSubscriber implements EventSubscriberInterface
|
||||||
$this->eventLogger = $eventLogger;
|
$this->eventLogger = $eventLogger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
SecurityEvents::U2F_ADDED => 'u2f_added',
|
SecurityEvents::U2F_ADDED => 'u2f_added',
|
||||||
|
|
|
@ -71,7 +71,7 @@ final class SetMailFromSubscriber implements EventSubscriberInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// should be the last one to allow header changes by other listeners first
|
// should be the last one to allow header changes by other listeners first
|
||||||
|
|
|
@ -75,7 +75,7 @@ final class SymfonyDebugToolbarSubscriber implements EventSubscriberInterface
|
||||||
*
|
*
|
||||||
* @return array The event names to listen to
|
* @return array The event names to listen to
|
||||||
*/
|
*/
|
||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents(): array
|
||||||
{
|
{
|
||||||
return ['kernel.response' => 'onKernelResponse'];
|
return ['kernel.response' => 'onKernelResponse'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ final class LoginSuccessSubscriber implements EventSubscriberInterface
|
||||||
*
|
*
|
||||||
* @return array The event names to listen to
|
* @return array The event names to listen to
|
||||||
*/
|
*/
|
||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents(): array
|
||||||
{
|
{
|
||||||
return [SecurityEvents::INTERACTIVE_LOGIN => 'onLogin'];
|
return [SecurityEvents::INTERACTIVE_LOGIN => 'onLogin'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ final class LogoutDisabledUserSubscriber implements EventSubscriberInterface
|
||||||
*
|
*
|
||||||
* @return array The event names to listen to
|
* @return array The event names to listen to
|
||||||
*/
|
*/
|
||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents(): array
|
||||||
{
|
{
|
||||||
return [KernelEvents::REQUEST => 'onRequest'];
|
return [KernelEvents::REQUEST => 'onRequest'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,14 +147,10 @@ final class PasswordChangeNeededSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
$tfa_enabled = $user->isU2FAuthEnabled() || $user->isGoogleAuthenticatorEnabled();
|
$tfa_enabled = $user->isU2FAuthEnabled() || $user->isGoogleAuthenticatorEnabled();
|
||||||
|
|
||||||
if (null !== $user->getGroup() && $user->getGroup()->isEnforce2FA() && !$tfa_enabled) {
|
return null !== $user->getGroup() && $user->getGroup()->isEnforce2FA() && !$tfa_enabled;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
KernelEvents::REQUEST => 'redirectToSettingsIfNeeded',
|
KernelEvents::REQUEST => 'redirectToSettingsIfNeeded',
|
||||||
|
|
|
@ -101,7 +101,7 @@ final class SetUserTimezoneSubscriber implements EventSubscriberInterface
|
||||||
*
|
*
|
||||||
* @return array The event names to listen to
|
* @return array The event names to listen to
|
||||||
*/
|
*/
|
||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents(): array
|
||||||
{
|
{
|
||||||
//Set the timezone shortly before executing the controller
|
//Set the timezone shortly before executing the controller
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -45,7 +45,7 @@ class SecurityEvent extends Event
|
||||||
*
|
*
|
||||||
* @return User
|
* @return User
|
||||||
*/
|
*/
|
||||||
public function getTargetUser()
|
public function getTargetUser(): User
|
||||||
{
|
{
|
||||||
return $this->targetUser;
|
return $this->targetUser;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ class AttachmentTypeAdminForm extends BaseEntityAdminForm
|
||||||
|
|
||||||
//Normalize data before writing it to database
|
//Normalize data before writing it to database
|
||||||
$builder->get('filetype_filter')->addViewTransformer(new CallbackTransformer(
|
$builder->get('filetype_filter')->addViewTransformer(new CallbackTransformer(
|
||||||
function ($value) {
|
static function ($value) {
|
||||||
return $value;
|
return $value;
|
||||||
},
|
},
|
||||||
function ($value) {
|
function ($value) {
|
||||||
|
|
|
@ -176,19 +176,18 @@ class AttachmentFormType extends AbstractType
|
||||||
$file_form = $form->get('file');
|
$file_form = $form->get('file');
|
||||||
$file = $file_form->getData();
|
$file = $file_form->getData();
|
||||||
|
|
||||||
if ($attachment instanceof Attachment && $file instanceof UploadedFile && $attachment->getAttachmentType()) {
|
if ($attachment instanceof Attachment && $file instanceof UploadedFile && $attachment->getAttachmentType(
|
||||||
if (!$this->submitHandler->isValidFileExtension($attachment->getAttachmentType(), $file)) {
|
) && !$this->submitHandler->isValidFileExtension($attachment->getAttachmentType(), $file)) {
|
||||||
$event->getForm()->get('file')->addError(
|
$event->getForm()->get('file')->addError(
|
||||||
new FormError($this->translator->trans('validator.file_ext_not_allowed'))
|
new FormError($this->translator->trans('validator.file_ext_not_allowed'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//Check the secure file checkbox, if file is in securefile location
|
//Check the secure file checkbox, if file is in securefile location
|
||||||
$builder->get('secureFile')->addEventListener(
|
$builder->get('secureFile')->addEventListener(
|
||||||
FormEvents::PRE_SET_DATA,
|
FormEvents::PRE_SET_DATA,
|
||||||
function (FormEvent $event): void {
|
static function (FormEvent $event): void {
|
||||||
$attachment = $event->getForm()->getParent()->getData();
|
$attachment = $event->getForm()->getParent()->getData();
|
||||||
if ($attachment instanceof Attachment) {
|
if ($attachment instanceof Attachment) {
|
||||||
$event->setData($attachment->isSecure());
|
$event->setData($attachment->isSecure());
|
||||||
|
|
|
@ -32,7 +32,6 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\Form\FormConfigBuilder;
|
use Symfony\Component\Form\FormConfigBuilder;
|
||||||
use Symfony\Component\Form\FormEvent;
|
use Symfony\Component\Form\FormEvent;
|
||||||
use Symfony\Component\Form\FormEvents;
|
use Symfony\Component\Form\FormEvents;
|
||||||
use Symfony\Component\OptionsResolver\Options;
|
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
|
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ class LabelOptionsType extends AbstractType
|
||||||
'label_options.barcode_type.code93' => 'code93',
|
'label_options.barcode_type.code93' => 'code93',
|
||||||
'label_options.barcode_type.datamatrix' => 'datamatrix',
|
'label_options.barcode_type.datamatrix' => 'datamatrix',
|
||||||
],
|
],
|
||||||
'group_by' => function ($choice, $key, $value) {
|
'group_by' => static function ($choice, $key, $value) {
|
||||||
if (in_array($choice, ['qr', 'datamatrix'], true)) {
|
if (in_array($choice, ['qr', 'datamatrix'], true)) {
|
||||||
return 'label_options.barcode_type.2D';
|
return 'label_options.barcode_type.2D';
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form\Part;
|
namespace App\Form\Part;
|
||||||
|
|
||||||
use App\Entity\Attachments\Attachment;
|
|
||||||
use App\Entity\Attachments\PartAttachment;
|
use App\Entity\Attachments\PartAttachment;
|
||||||
use App\Entity\Parameters\PartParameter;
|
use App\Entity\Parameters\PartParameter;
|
||||||
use App\Entity\Parts\Category;
|
use App\Entity\Parts\Category;
|
||||||
|
|
|
@ -69,11 +69,8 @@ class PermissionGroupType extends AbstractType
|
||||||
if ($permission['group'] !== $options['group_name']) {
|
if ($permission['group'] !== $options['group_name']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} elseif ('*' !== $options['group_name']) {
|
||||||
//Skip perrmissions without groups unless we have this as blanko group
|
continue;
|
||||||
if ('*' !== $options['group_name']) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder->add($key, PermissionType::class, [
|
$builder->add($key, PermissionType::class, [
|
||||||
|
@ -91,7 +88,7 @@ class PermissionGroupType extends AbstractType
|
||||||
{
|
{
|
||||||
parent::configureOptions($resolver);
|
parent::configureOptions($resolver);
|
||||||
|
|
||||||
$resolver->setDefault('group_name', function (Options $options) {
|
$resolver->setDefault('group_name', static function (Options $options) {
|
||||||
return trim($options['name']);
|
return trim($options['name']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ class PermissionType extends AbstractType
|
||||||
{
|
{
|
||||||
parent::configureOptions($resolver);
|
parent::configureOptions($resolver);
|
||||||
|
|
||||||
$resolver->setDefault('perm_name', function (Options $options) {
|
$resolver->setDefault('perm_name', static function (Options $options) {
|
||||||
return $options['name'];
|
return $options['name'];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ class PermissionType extends AbstractType
|
||||||
return $options['name'];
|
return $options['name'];
|
||||||
});
|
});
|
||||||
|
|
||||||
$resolver->setDefault('multi_checkbox', function (Options $options) {
|
$resolver->setDefault('multi_checkbox', static function (Options $options) {
|
||||||
return !$options['disabled'];
|
return !$options['disabled'];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ final class PermissionsMapper implements DataMapperInterface
|
||||||
* @param mixed $viewData View data of the compound form being initialized
|
* @param mixed $viewData View data of the compound form being initialized
|
||||||
* @param FormInterface[]|Traversable $forms A list of {@link FormInterface} instances
|
* @param FormInterface[]|Traversable $forms A list of {@link FormInterface} instances
|
||||||
*/
|
*/
|
||||||
public function mapDataToForms($viewData, $forms): void
|
public function mapDataToForms($viewData, $forms)
|
||||||
{
|
{
|
||||||
foreach ($forms as $form) {
|
foreach ($forms as $form) {
|
||||||
if ($this->inherit) {
|
if ($this->inherit) {
|
||||||
|
@ -119,7 +119,7 @@ final class PermissionsMapper implements DataMapperInterface
|
||||||
* @param mixed $viewData The compound form's view data that get mapped
|
* @param mixed $viewData The compound form's view data that get mapped
|
||||||
* its children model data
|
* its children model data
|
||||||
*/
|
*/
|
||||||
public function mapFormsToData($forms, &$viewData): void
|
public function mapFormsToData($forms, &$viewData) :void
|
||||||
{
|
{
|
||||||
if ($this->inherit) {
|
if ($this->inherit) {
|
||||||
throw new RuntimeException('The permission type is readonly when it is showing read only data!');
|
throw new RuntimeException('The permission type is readonly when it is showing read only data!');
|
||||||
|
|
|
@ -66,7 +66,7 @@ class PermissionsType extends AbstractType
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'show_legend' => true,
|
'show_legend' => true,
|
||||||
'constraints' => function (Options $options) {
|
'constraints' => static function (Options $options) {
|
||||||
if (!$options['disabled']) {
|
if (!$options['disabled']) {
|
||||||
return [new NoLockout()];
|
return [new NoLockout()];
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,6 @@ use App\Entity\UserSystem\User;
|
||||||
use App\Validator\Constraints\ValidGoogleAuthCode;
|
use App\Validator\Constraints\ValidGoogleAuthCode;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ResetType;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
@ -64,7 +63,7 @@ class TFAGoogleSettingsType extends AbstractType
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void {
|
$builder->addEventListener(FormEvents::PRE_SET_DATA, static function (FormEvent $event): void {
|
||||||
$form = $event->getForm();
|
$form = $event->getForm();
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = $event->getData();
|
$user = $event->getData();
|
||||||
|
|
|
@ -65,8 +65,8 @@ class MasterPictureAttachmentType extends AbstractType
|
||||||
'class' => 'selectpicker',
|
'class' => 'selectpicker',
|
||||||
'title' => 'selectpicker.nothing_selected',
|
'title' => 'selectpicker.nothing_selected',
|
||||||
],
|
],
|
||||||
'choice_attr' => function (Options $options) {
|
'choice_attr' => static function (Options $options) {
|
||||||
return function ($choice, $key, $value) use ($options) {
|
return static function ($choice, $key, $value) use ($options) {
|
||||||
/** @var Attachment $choice */
|
/** @var Attachment $choice */
|
||||||
$tmp = ['data-subtext' => $choice->getFilename() ?? 'URL'];
|
$tmp = ['data-subtext' => $choice->getFilename() ?? 'URL'];
|
||||||
|
|
||||||
|
@ -80,8 +80,9 @@ class MasterPictureAttachmentType extends AbstractType
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
'choice_label' => 'name',
|
'choice_label' => 'name',
|
||||||
'choice_loader' => function (Options $options) {
|
'choice_loader' => static function (Options $options) {
|
||||||
return new CallbackChoiceLoader(function () use ($options) {
|
return new CallbackChoiceLoader(
|
||||||
|
static function () use ($options) {
|
||||||
$entity = $options['entity'];
|
$entity = $options['entity'];
|
||||||
if (!$entity instanceof AttachmentContainingDBElement) {
|
if (!$entity instanceof AttachmentContainingDBElement) {
|
||||||
throw new \RuntimeException('$entity must have Attachments! (be of type AttachmentContainingDBElement)');
|
throw new \RuntimeException('$entity must have Attachments! (be of type AttachmentContainingDBElement)');
|
||||||
|
|
|
@ -69,7 +69,7 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'measurement_unit' => null,
|
'measurement_unit' => null,
|
||||||
'show_prefix' => function (Options $options) {
|
'show_prefix' => static function (Options $options) {
|
||||||
if (null !== $options['measurement_unit']) {
|
if (null !== $options['measurement_unit']) {
|
||||||
/** @var MeasurementUnit $unit */
|
/** @var MeasurementUnit $unit */
|
||||||
$unit = $options['measurement_unit'];
|
$unit = $options['measurement_unit'];
|
||||||
|
@ -79,7 +79,7 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
'is_integer' => function (Options $options) {
|
'is_integer' => static function (Options $options) {
|
||||||
if (null !== $options['measurement_unit']) {
|
if (null !== $options['measurement_unit']) {
|
||||||
/** @var MeasurementUnit $unit */
|
/** @var MeasurementUnit $unit */
|
||||||
$unit = $options['measurement_unit'];
|
$unit = $options['measurement_unit'];
|
||||||
|
@ -89,7 +89,7 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
'unit' => function (Options $options) {
|
'unit' => static function (Options $options) {
|
||||||
if (null !== $options['measurement_unit']) {
|
if (null !== $options['measurement_unit']) {
|
||||||
/** @var MeasurementUnit $unit */
|
/** @var MeasurementUnit $unit */
|
||||||
$unit = $options['measurement_unit'];
|
$unit = $options['measurement_unit'];
|
||||||
|
@ -111,7 +111,7 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'min' => 0,
|
'min' => 0,
|
||||||
'max' => '',
|
'max' => '',
|
||||||
'step' => function (Options $options) {
|
'step' => static function (Options $options) {
|
||||||
if (true === $options['is_integer']) {
|
if (true === $options['is_integer']) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
|
||||||
$forms['prefix']->setData(0);
|
$forms['prefix']->setData(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->si_formatter->convertValue((float) $viewData);
|
$data = $this->si_formatter->convertValue((float) $viewData);
|
||||||
|
|
|
@ -44,13 +44,11 @@ namespace App\Form\Type;
|
||||||
|
|
||||||
use App\Entity\Attachments\AttachmentType;
|
use App\Entity\Attachments\AttachmentType;
|
||||||
use App\Entity\Base\AbstractStructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use App\Repository\StructuralDBElementRepository;
|
|
||||||
use App\Services\Trees\NodesListBuilder;
|
use App\Services\Trees\NodesListBuilder;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\CallbackTransformer;
|
use Symfony\Component\Form\CallbackTransformer;
|
||||||
use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader;
|
use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader;
|
||||||
use Symfony\Component\Form\Exception;
|
|
||||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
@ -58,7 +56,6 @@ use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
use Symfony\Component\OptionsResolver\Options;
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Symfony\Component\Validator\Constraints\Choice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides a choice form type similar to EntityType, with the difference, that the tree structure
|
* This class provides a choice form type similar to EntityType, with the difference, that the tree structure
|
||||||
|
@ -117,7 +114,7 @@ class StructuralEntityType extends AbstractType
|
||||||
|
|
||||||
$resolver->setDefault('empty_message', null);
|
$resolver->setDefault('empty_message', null);
|
||||||
|
|
||||||
$resolver->setDefault('attr', function (Options $options) {
|
$resolver->setDefault('attr', static function (Options $options) {
|
||||||
$tmp = [
|
$tmp = [
|
||||||
'class' => 'selectpicker',
|
'class' => 'selectpicker',
|
||||||
'data-live-search' => true,
|
'data-live-search' => true,
|
||||||
|
|
|
@ -49,7 +49,6 @@ use App\Entity\UserSystem\User;
|
||||||
use App\Form\Permissions\PermissionsType;
|
use App\Form\Permissions\PermissionsType;
|
||||||
use App\Form\Type\CurrencyEntityType;
|
use App\Form\Type\CurrencyEntityType;
|
||||||
use App\Form\Type\StructuralEntityType;
|
use App\Form\Type\StructuralEntityType;
|
||||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
@ -174,7 +173,7 @@ class UserAdminForm extends AbstractType
|
||||||
->add('theme', ChoiceType::class, [
|
->add('theme', ChoiceType::class, [
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'choices' => User::AVAILABLE_THEMES,
|
'choices' => User::AVAILABLE_THEMES,
|
||||||
'choice_label' => function ($entity, $key, $value) {
|
'choice_label' => static function ($entity, $key, $value) {
|
||||||
return $value;
|
return $value;
|
||||||
},
|
},
|
||||||
'attr' => [
|
'attr' => [
|
||||||
|
|
|
@ -124,7 +124,7 @@ class UserSettingsType extends AbstractType
|
||||||
],
|
],
|
||||||
'choice_translation_domain' => false,
|
'choice_translation_domain' => false,
|
||||||
'choices' => User::AVAILABLE_THEMES,
|
'choices' => User::AVAILABLE_THEMES,
|
||||||
'choice_label' => function ($entity, $key, $value) {
|
'choice_label' => static function ($entity, $key, $value) {
|
||||||
return $value;
|
return $value;
|
||||||
},
|
},
|
||||||
'placeholder' => 'user_settings.theme.placeholder',
|
'placeholder' => 'user_settings.theme.placeholder',
|
||||||
|
|
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Helpers;
|
namespace App\Helpers;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\File\File;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
@ -62,7 +61,7 @@ class LabelResponse extends Response
|
||||||
/**
|
/**
|
||||||
* Automatically sets the Last-Modified header according the file modification date.
|
* Automatically sets the Last-Modified header according the file modification date.
|
||||||
*/
|
*/
|
||||||
public function setAutoLastModified()
|
public function setAutoLastModified(): LabelResponse
|
||||||
{
|
{
|
||||||
$this->setLastModified(new \DateTime());
|
$this->setLastModified(new \DateTime());
|
||||||
|
|
||||||
|
@ -72,7 +71,7 @@ class LabelResponse extends Response
|
||||||
/**
|
/**
|
||||||
* Automatically sets the ETag header according to the checksum of the file.
|
* Automatically sets the ETag header according to the checksum of the file.
|
||||||
*/
|
*/
|
||||||
public function setAutoEtag()
|
public function setAutoEtag(): LabelResponse
|
||||||
{
|
{
|
||||||
$this->setEtag(base64_encode(hash('sha256', $this->content, true)));
|
$this->setEtag(base64_encode(hash('sha256', $this->content, true)));
|
||||||
|
|
||||||
|
@ -88,7 +87,7 @@ class LabelResponse extends Response
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setContentDisposition($disposition, $filename, $filenameFallback = '')
|
public function setContentDisposition($disposition, $filename, $filenameFallback = ''): self
|
||||||
{
|
{
|
||||||
if ('' === $filenameFallback && (!preg_match('/^[\x20-\x7e]*$/', $filename) || false !== strpos($filename, '%'))) {
|
if ('' === $filenameFallback && (!preg_match('/^[\x20-\x7e]*$/', $filename) || false !== strpos($filename, '%'))) {
|
||||||
$encoding = mb_detect_encoding($filename, null, true) ?: '8bit';
|
$encoding = mb_detect_encoding($filename, null, true) ?: '8bit';
|
||||||
|
|
|
@ -54,7 +54,7 @@ final class StructuralDBElementIterator extends ArrayIterator implements Recursi
|
||||||
parent::__construct($nodes);
|
parent::__construct($nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasChildren()
|
public function hasChildren(): bool
|
||||||
{
|
{
|
||||||
/** @var AbstractStructuralDBElement $element */
|
/** @var AbstractStructuralDBElement $element */
|
||||||
$element = $this->current();
|
$element = $this->current();
|
||||||
|
|
|
@ -55,7 +55,7 @@ final class TreeViewNodeIterator extends ArrayIterator implements RecursiveItera
|
||||||
parent::__construct($nodes);
|
parent::__construct($nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasChildren()
|
public function hasChildren(): bool
|
||||||
{
|
{
|
||||||
/** @var TreeViewNode $element */
|
/** @var TreeViewNode $element */
|
||||||
$element = $this->current();
|
$element = $this->current();
|
||||||
|
|
|
@ -52,7 +52,6 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\Event\PreFlushEventArgs;
|
use Doctrine\ORM\Event\PreFlushEventArgs;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Doctrine\ORM\Mapping\PostLoad;
|
use Doctrine\ORM\Mapping\PostLoad;
|
||||||
use Doctrine\ORM\Mapping\PreUpdate;
|
|
||||||
use function get_class;
|
use function get_class;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use ReflectionClass;
|
use ReflectionClass;
|
||||||
|
@ -162,14 +161,14 @@ class ElementPermissionListener
|
||||||
$property->setAccessible(true);
|
$property->setAccessible(true);
|
||||||
|
|
||||||
//If the user is not allowed to edit or read this property, reset all values.
|
//If the user is not allowed to edit or read this property, reset all values.
|
||||||
|
//Set value to old value, so that there a no change to this property
|
||||||
if ((!$this->isGranted('read', $annotation, $element)
|
if ((!$this->isGranted('read', $annotation, $element)
|
||||||
|| !$this->isGranted('edit', $annotation, $element))) {
|
|| !$this->isGranted('edit', $annotation, $element)) && isset(
|
||||||
//Set value to old value, so that there a no change to this property
|
$old_data[$property->getName()]
|
||||||
if (isset($old_data[$property->getName()])) {
|
)) {
|
||||||
$property->setValue($element, $old_data[$property->getName()]);
|
$property->setValue($element, $old_data[$property->getName()]);
|
||||||
$changed = true;
|
$changed = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($changed) {
|
if ($changed) {
|
||||||
//Schedule for update, so the post update method will be called
|
//Schedule for update, so the post update method will be called
|
||||||
|
@ -184,13 +183,9 @@ class ElementPermissionListener
|
||||||
*
|
*
|
||||||
* @return bool Returns true if the current programm is running from CLI (terminal)
|
* @return bool Returns true if the current programm is running from CLI (terminal)
|
||||||
*/
|
*/
|
||||||
protected function isRunningFromCLI()
|
protected function isRunningFromCLI(): bool
|
||||||
{
|
{
|
||||||
if (empty($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['HTTP_USER_AGENT']) && count($_SERVER['argv']) > 0) {
|
return empty($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['HTTP_USER_AGENT']) && count($_SERVER['argv']) > 0;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -66,7 +66,7 @@ abstract class ExtendedVoter extends Voter
|
||||||
$this->entityManager = $entityManager;
|
$this->entityManager = $entityManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
|
final protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
||||||
{
|
{
|
||||||
$user = $token->getUser();
|
$user = $token->getUser();
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ namespace App\Security\Voter;
|
||||||
|
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Voter that votes on Part entities.
|
* A Voter that votes on Part entities.
|
||||||
|
|
|
@ -76,16 +76,14 @@ class UserVoter extends ExtendedVoter
|
||||||
*/
|
*/
|
||||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||||
{
|
{
|
||||||
if ($subject instanceof User) {
|
//Check if the checked user is the user itself
|
||||||
//Check if the checked user is the user itself
|
if (($subject instanceof User) && $subject->getID() === $user->getID() &&
|
||||||
if ($subject->getID() === $user->getID() &&
|
$this->resolver->isValidOperation('self', $attribute)) {
|
||||||
$this->resolver->isValidOperation('self', $attribute)) {
|
//Then we also need to check the self permission
|
||||||
//Then we also need to check the self permission
|
$tmp = $this->resolver->inherit($user, 'self', $attribute) ?? false;
|
||||||
$tmp = $this->resolver->inherit($user, 'self', $attribute) ?? false;
|
//But if the self value is not allowed then use just the user value:
|
||||||
//But if the self value is not allowed then use just the user value:
|
if ($tmp) {
|
||||||
if ($tmp) {
|
return $tmp;
|
||||||
return $tmp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ class AmountFormatter
|
||||||
*
|
*
|
||||||
* @throws InvalidArgumentException thrown if $value is not numeric
|
* @throws InvalidArgumentException thrown if $value is not numeric
|
||||||
*/
|
*/
|
||||||
public function format($value, ?MeasurementUnit $unit = null, array $options = [])
|
public function format($value, ?MeasurementUnit $unit = null, array $options = []): string
|
||||||
{
|
{
|
||||||
if (!is_numeric($value)) {
|
if (!is_numeric($value)) {
|
||||||
throw new InvalidArgumentException('$value must be an numeric value!');
|
throw new InvalidArgumentException('$value must be an numeric value!');
|
||||||
|
@ -106,7 +106,7 @@ class AmountFormatter
|
||||||
protected function configureOptions(OptionsResolver $resolver): void
|
protected function configureOptions(OptionsResolver $resolver): void
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'show_prefix' => function (Options $options) {
|
'show_prefix' => static function (Options $options) {
|
||||||
if (null !== $options['measurement_unit']) {
|
if (null !== $options['measurement_unit']) {
|
||||||
/** @var MeasurementUnit $unit */
|
/** @var MeasurementUnit $unit */
|
||||||
$unit = $options['measurement_unit'];
|
$unit = $options['measurement_unit'];
|
||||||
|
@ -116,7 +116,7 @@ class AmountFormatter
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
'is_integer' => function (Options $options) {
|
'is_integer' => static function (Options $options) {
|
||||||
if (null !== $options['measurement_unit']) {
|
if (null !== $options['measurement_unit']) {
|
||||||
/** @var MeasurementUnit $unit */
|
/** @var MeasurementUnit $unit */
|
||||||
$unit = $options['measurement_unit'];
|
$unit = $options['measurement_unit'];
|
||||||
|
@ -126,7 +126,7 @@ class AmountFormatter
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
'unit' => function (Options $options) {
|
'unit' => static function (Options $options) {
|
||||||
if (null !== $options['measurement_unit']) {
|
if (null !== $options['measurement_unit']) {
|
||||||
/** @var MeasurementUnit $unit */
|
/** @var MeasurementUnit $unit */
|
||||||
$unit = $options['measurement_unit'];
|
$unit = $options['measurement_unit'];
|
||||||
|
@ -144,7 +144,7 @@ class AmountFormatter
|
||||||
|
|
||||||
$resolver->setAllowedTypes('decimals', 'int');
|
$resolver->setAllowedTypes('decimals', 'int');
|
||||||
|
|
||||||
$resolver->setNormalizer('decimals', function (Options $options, $value) {
|
$resolver->setNormalizer('decimals', static function (Options $options, $value) {
|
||||||
// If the unit is integer based, then dont show any decimals
|
// If the unit is integer based, then dont show any decimals
|
||||||
if ($options['is_integer']) {
|
if ($options['is_integer']) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -48,7 +48,6 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
|
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
|
||||||
use SplFileInfo;
|
use SplFileInfo;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
use Symfony\Component\HttpFoundation\File\File;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This service provides functions to find attachments via an reverse search based on a file.
|
* This service provides functions to find attachments via an reverse search based on a file.
|
||||||
|
|
|
@ -92,7 +92,7 @@ class FileTypeFilterTools
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
$element = trim($element);
|
$element = trim($element);
|
||||||
if (!preg_match('#^\.\w+$#', $element) // .ext is allowed
|
if (!preg_match('#^\.\w+$#', $element) // .ext is allowed
|
||||||
&& !preg_match('#^[-\w.]+\/[-\w.]+#', $element) //Explicit MIME type is allowed
|
&& !preg_match('#^[-\w.]+/[-\w.]+#', $element) //Explicit MIME type is allowed
|
||||||
&& !in_array($element, static::ALLOWED_MIME_PLACEHOLDERS, false)) { //image/* is allowed
|
&& !in_array($element, static::ALLOWED_MIME_PLACEHOLDERS, false)) { //image/* is allowed
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ class FileTypeFilterTools
|
||||||
$element = 'video/*';
|
$element = 'video/*';
|
||||||
} elseif ('audio' === $element || 'audio/' === $element) {
|
} elseif ('audio' === $element || 'audio/' === $element) {
|
||||||
$element = 'audio/*';
|
$element = 'audio/*';
|
||||||
} elseif (!preg_match('#^[-\w.]+\/[-\w.*]+#', $element) && 0 !== strpos($element, '.')) {
|
} elseif (!preg_match('#^[-\w.]+/[-\w.*]+#', $element) && 0 !== strpos($element, '.')) {
|
||||||
//Convert jpg to .jpg
|
//Convert jpg to .jpg
|
||||||
$element = '.'.$element;
|
$element = '.'.$element;
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ class FileTypeFilterTools
|
||||||
$extensions = array_merge($extensions, static::AUDIO_EXTS);
|
$extensions = array_merge($extensions, static::AUDIO_EXTS);
|
||||||
} elseif ('video/*' === $element) {
|
} elseif ('video/*' === $element) {
|
||||||
$extensions = array_merge($extensions, static::VIDEO_EXTS);
|
$extensions = array_merge($extensions, static::VIDEO_EXTS);
|
||||||
} elseif (preg_match('#^[-\w.]+\/[-\w.*]+#', $element)) {
|
} elseif (preg_match('#^[-\w.]+/[-\w.*]+#', $element)) {
|
||||||
$extensions = array_merge($extensions, $this->mimeTypes->getExtensions($element));
|
$extensions = array_merge($extensions, $this->mimeTypes->getExtensions($element));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,9 +59,10 @@ final class CustomEnvVarProcessor implements EnvVarProcessorInterface
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getProvidedTypes()
|
public static function getProvidedTypes(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'validMailDSN' => 'bool',
|
'validMailDSN' => 'bool',
|
||||||
|
|
|
@ -51,13 +51,6 @@ use ReflectionException;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
|
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
|
||||||
use Symfony\Component\Serializer\Encoder\CsvEncoder;
|
|
||||||
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
|
||||||
use Symfony\Component\Serializer\Encoder\XmlEncoder;
|
|
||||||
use Symfony\Component\Serializer\Encoder\YamlEncoder;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
|
||||||
use Symfony\Component\Serializer\Serializer;
|
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
use Symfony\Component\Serializer\SerializerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,7 +159,7 @@ class EntityExporter
|
||||||
$disposition = $response->headers->makeDisposition(
|
$disposition = $response->headers->makeDisposition(
|
||||||
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
|
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
|
||||||
$filename,
|
$filename,
|
||||||
$string = preg_replace('![^'.preg_quote('-').'a-z0-_9\s]+!', '', strtolower($filename))
|
$string = preg_replace('![^'.preg_quote('-','!').'a-z0-_9\s]+!', '', strtolower($filename))
|
||||||
);
|
);
|
||||||
// Set the content disposition
|
// Set the content disposition
|
||||||
$response->headers->set('Content-Disposition', $disposition);
|
$response->headers->set('Content-Disposition', $disposition);
|
||||||
|
|
|
@ -151,7 +151,7 @@ class EntityImporter
|
||||||
$tmp = $this->validator->validate($entity);
|
$tmp = $this->validator->validate($entity);
|
||||||
|
|
||||||
//When no validation error occured, persist entity to database (cascade must be set in entity)
|
//When no validation error occured, persist entity to database (cascade must be set in entity)
|
||||||
if (empty($tmp)) {
|
if ($tmp === null) {
|
||||||
$this->em->persist($entity);
|
$this->em->persist($entity);
|
||||||
} else { //Log validation errors to global log.
|
} else { //Log validation errors to global log.
|
||||||
$errors[$entity->getFullPath()] = $tmp;
|
$errors[$entity->getFullPath()] = $tmp;
|
||||||
|
|
|
@ -58,7 +58,7 @@ class GitVersionInfo
|
||||||
*
|
*
|
||||||
* @return string|null The current git branch name. Null, if this is no Git installation
|
* @return string|null The current git branch name. Null, if this is no Git installation
|
||||||
*/
|
*/
|
||||||
public function getGitBranchName()
|
public function getGitBranchName(): ?string
|
||||||
{
|
{
|
||||||
if (is_file($this->project_dir.'/.git/HEAD')) {
|
if (is_file($this->project_dir.'/.git/HEAD')) {
|
||||||
$git = file($this->project_dir.'/.git/HEAD');
|
$git = file($this->project_dir.'/.git/HEAD');
|
||||||
|
@ -83,7 +83,7 @@ class GitVersionInfo
|
||||||
*
|
*
|
||||||
* @return string|null The hash of the last commit, null If this is no Git installation
|
* @return string|null The hash of the last commit, null If this is no Git installation
|
||||||
*/
|
*/
|
||||||
public function getGitCommitHash(int $length = 7)
|
public function getGitCommitHash(int $length = 7): ?string
|
||||||
{
|
{
|
||||||
$filename = $this->project_dir.'/.git/refs/remotes/origin/'.$this->getGitBranchName();
|
$filename = $this->project_dir.'/.git/refs/remotes/origin/'.$this->getGitBranchName();
|
||||||
if (is_file($filename)) {
|
if (is_file($filename)) {
|
||||||
|
|
|
@ -78,7 +78,7 @@ final class LabelGenerator
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function supports(LabelOptions $options, object $element)
|
public function supports(LabelOptions $options, object $element): bool
|
||||||
{
|
{
|
||||||
$supported_type = $options->getSupportedElement();
|
$supported_type = $options->getSupportedElement();
|
||||||
if (!isset(static::CLASS_SUPPORT_MAPPING[$supported_type])) {
|
if (!isset(static::CLASS_SUPPORT_MAPPING[$supported_type])) {
|
||||||
|
|
|
@ -68,7 +68,7 @@ final class LabelHTMLGenerator
|
||||||
|
|
||||||
$page = 1;
|
$page = 1;
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
if ('twig' === $options->getLinesMode() && isset($sandboxed_twig) && isset($current_user)) {
|
if (isset($sandboxed_twig, $current_user) && 'twig' === $options->getLinesMode()) {
|
||||||
try {
|
try {
|
||||||
$lines = $sandboxed_twig->render(
|
$lines = $sandboxed_twig->render(
|
||||||
'lines',
|
'lines',
|
||||||
|
@ -103,7 +103,7 @@ final class LabelHTMLGenerator
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getPDFTitle(LabelOptions $options, object $element)
|
private function getPDFTitle(LabelOptions $options, object $element): string
|
||||||
{
|
{
|
||||||
if ($element instanceof NamedElementInterface) {
|
if ($element instanceof NamedElementInterface) {
|
||||||
return $this->elementTypeNameGenerator->getTypeNameCombination($element, false);
|
return $this->elementTypeNameGenerator->getTypeNameCombination($element, false);
|
||||||
|
|
|
@ -44,7 +44,7 @@ final class PartLotProvider implements PlaceholderProviderInterface
|
||||||
{
|
{
|
||||||
if ($label_target instanceof PartLot) {
|
if ($label_target instanceof PartLot) {
|
||||||
if ('[[LOT_ID]]' === $placeholder) {
|
if ('[[LOT_ID]]' === $placeholder) {
|
||||||
return $label_target->getID() ?? 'unknown';
|
return (string) ($label_target->getID() ?? 'unknown');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('[[LOT_NAME]]' === $placeholder) {
|
if ('[[LOT_NAME]]' === $placeholder) {
|
||||||
|
|
|
@ -147,13 +147,11 @@ class LogEntryExtraFormatter
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($context instanceof LogWithEventUndoInterface) {
|
if (($context instanceof LogWithEventUndoInterface) && $context->isUndoEvent()) {
|
||||||
if ($context->isUndoEvent()) {
|
if ('undo' === $context->getUndoMode()) {
|
||||||
if ('undo' === $context->getUndoMode()) {
|
$array['log.undo_mode.undo'] = (string) $context->getUndoEventID();
|
||||||
$array['log.undo_mode.undo'] = (string) $context->getUndoEventID();
|
} elseif ('revert' === $context->getUndoMode()) {
|
||||||
} elseif ('revert' === $context->getUndoMode()) {
|
$array['log.undo_mode.revert'] = (string) $context->getUndoEventID();
|
||||||
$array['log.undo_mode.revert'] = (string) $context->getUndoEventID();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +190,7 @@ class LogEntryExtraFormatter
|
||||||
$array['log.collection_deleted.deleted'] = sprintf(
|
$array['log.collection_deleted.deleted'] = sprintf(
|
||||||
'%s: %s (%s)',
|
'%s: %s (%s)',
|
||||||
$this->elementTypeNameGenerator->getLocalizedTypeLabel($context->getDeletedElementClass()),
|
$this->elementTypeNameGenerator->getLocalizedTypeLabel($context->getDeletedElementClass()),
|
||||||
$context->getOldName() ?? $context->getDeletedElementID(),
|
$context->getOldName() ?? (string) $context->getDeletedElementID(),
|
||||||
$context->getCollectionName()
|
$context->getCollectionName()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,11 +152,12 @@ class TimeTravel
|
||||||
foreach ($target_elements as $target_element) {
|
foreach ($target_elements as $target_element) {
|
||||||
if (null !== $target_element && $element->getLastModified() >= $timestamp) {
|
if (null !== $target_element && $element->getLastModified() >= $timestamp) {
|
||||||
//Remove the element from collection, if it did not existed at $timestamp
|
//Remove the element from collection, if it did not existed at $timestamp
|
||||||
if (!$this->repo->getElementExistedAtTimestamp($target_element, $timestamp)) {
|
if (!$this->repo->getElementExistedAtTimestamp(
|
||||||
if ($target_elements instanceof Collection) {
|
$target_element,
|
||||||
|
$timestamp
|
||||||
|
) && $target_elements instanceof Collection) {
|
||||||
$target_elements->removeElement($target_element);
|
$target_elements->removeElement($target_element);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$this->revertEntityToTimestamp($target_element, $timestamp, $reverted_elements);
|
$this->revertEntityToTimestamp($target_element, $timestamp, $reverted_elements);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,11 +184,9 @@ class TimeTravel
|
||||||
|
|
||||||
foreach ($old_data as $field => $data) {
|
foreach ($old_data as $field => $data) {
|
||||||
if ($metadata->hasField($field)) {
|
if ($metadata->hasField($field)) {
|
||||||
if ('big_decimal' === $metadata->getFieldMapping($field)['type']) {
|
//We need to convert the string to a BigDecimal first
|
||||||
//We need to convert the string to a BigDecimal first
|
if (!$data instanceof BigDecimal && ('big_decimal' === $metadata->getFieldMapping($field)['type'])) {
|
||||||
if (!$data instanceof BigDecimal) {
|
$data = BigDecimal::of($data);
|
||||||
$data = BigDecimal::of($data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setField($element, $field, $data);
|
$this->setField($element, $field, $data);
|
||||||
|
|
|
@ -67,7 +67,7 @@ class MoneyFormatter
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function format($value, ?Currency $currency = null, $decimals = 5, bool $show_all_digits = false)
|
public function format($value, ?Currency $currency = null, $decimals = 5, bool $show_all_digits = false): string
|
||||||
{
|
{
|
||||||
$iso_code = $this->base_currency;
|
$iso_code = $this->base_currency;
|
||||||
if (null !== $currency && !empty($currency->getIsoCode())) {
|
if (null !== $currency && !empty($currency->getIsoCode())) {
|
||||||
|
|
|
@ -85,7 +85,7 @@ class PricedetailHelper
|
||||||
} else {
|
} else {
|
||||||
// We have to sort the pricedetails manually
|
// We have to sort the pricedetails manually
|
||||||
$array = $pricedetails->map(
|
$array = $pricedetails->map(
|
||||||
function (Pricedetail $pricedetail) {
|
static function (Pricedetail $pricedetail) {
|
||||||
return $pricedetail->getMinDiscountQuantity();
|
return $pricedetail->getMinDiscountQuantity();
|
||||||
}
|
}
|
||||||
)->toArray();
|
)->toArray();
|
||||||
|
|
|
@ -66,7 +66,7 @@ class TagFinder
|
||||||
*
|
*
|
||||||
* @return string[] an array containing the tags that match the given keyword
|
* @return string[] an array containing the tags that match the given keyword
|
||||||
*/
|
*/
|
||||||
public function searchTags(string $keyword, array $options = [])
|
public function searchTags(string $keyword, array $options = []): array
|
||||||
{
|
{
|
||||||
$results = [];
|
$results = [];
|
||||||
$keyword_regex = '/^'.preg_quote($keyword, '/').'/';
|
$keyword_regex = '/^'.preg_quote($keyword, '/').'/';
|
||||||
|
|
|
@ -124,7 +124,7 @@ class TreeViewGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
//Translate text if text starts with $$
|
//Translate text if text starts with $$
|
||||||
if ('$$' === substr($item->getText(), 0, 2)) {
|
if (strpos($item->getText(), '$$') === 0) {
|
||||||
$item->setText($this->translator->trans(substr($item->getText(), 2)));
|
$item->setText($this->translator->trans(substr($item->getText(), 2)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ class AppExtension extends AbstractExtension
|
||||||
public function getTests()
|
public function getTests()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new TwigTest('instanceof', function ($var, $instance) {
|
new TwigTest('instanceof', static function ($var, $instance) {
|
||||||
return $var instanceof $instance;
|
return $var instanceof $instance;
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
@ -150,7 +150,7 @@ class AppExtension extends AbstractExtension
|
||||||
return $this->entityURLGenerator->getURL($entity, $method);
|
return $this->entityURLGenerator->getURL($entity, $method);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formatCurrency($amount, ?Currency $currency = null, int $decimals = 5)
|
public function formatCurrency($amount, ?Currency $currency = null, int $decimals = 5): string
|
||||||
{
|
{
|
||||||
if ($amount instanceof BigDecimal) {
|
if ($amount instanceof BigDecimal) {
|
||||||
$amount = (string) $amount;
|
$amount = (string) $amount;
|
||||||
|
@ -159,12 +159,12 @@ class AppExtension extends AbstractExtension
|
||||||
return $this->moneyFormatter->format($amount, $currency, $decimals);
|
return $this->moneyFormatter->format($amount, $currency, $decimals);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function siFormat($value, $unit, $decimals = 2, bool $show_all_digits = false)
|
public function siFormat($value, $unit, $decimals = 2, bool $show_all_digits = false): string
|
||||||
{
|
{
|
||||||
return $this->siformatter->format($value, $unit, $decimals, $show_all_digits);
|
return $this->siformatter->format($value, $unit, $decimals);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function amountFormat($value, ?MeasurementUnit $unit, array $options = [])
|
public function amountFormat($value, ?MeasurementUnit $unit, array $options = []): string
|
||||||
{
|
{
|
||||||
return $this->amountFormatter->format($value, $unit, $options);
|
return $this->amountFormatter->format($value, $unit, $options);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ class BarcodeExtension extends AbstractExtension
|
||||||
public function getFilters()
|
public function getFilters()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new TwigFilter('barcodeSVG', function (string $content, string $type = 'QRCODE') {
|
new TwigFilter('barcodeSVG', static function (string $content, string $type = 'QRCODE') {
|
||||||
$barcodeFactory = new Barcode();
|
$barcodeFactory = new Barcode();
|
||||||
$barcode = $barcodeFactory->getBarcodeObj($type, $content);
|
$barcode = $barcodeFactory->getBarcodeObj($type, $content);
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,8 @@ final class InheritanceSecurityPolicy implements SecurityPolicyInterface
|
||||||
{
|
{
|
||||||
$this->allowedMethods = [];
|
$this->allowedMethods = [];
|
||||||
foreach ($methods as $class => $m) {
|
foreach ($methods as $class => $m) {
|
||||||
$this->allowedMethods[$class] = array_map(function ($value) { return strtr($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); }, \is_array($m) ? $m : [$m]);
|
$this->allowedMethods[$class] = array_map(
|
||||||
|
static function ($value) { return strtr($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); }, \is_array($m) ? $m : [$m]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ final class TypeLabelExtension extends AbstractExtension
|
||||||
$this->nameGenerator = $elementTypeNameGenerator;
|
$this->nameGenerator = $elementTypeNameGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFunctions()
|
public function getFunctions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new TwigFunction('elementType', [$this->nameGenerator, 'getLocalizedTypeLabel']),
|
new TwigFunction('elementType', [$this->nameGenerator, 'getLocalizedTypeLabel']),
|
||||||
|
|
|
@ -88,12 +88,14 @@ class NoLockoutValidator extends ConstraintValidator
|
||||||
$user = $this->entityManager->getRepository(User::class)->getAnonymousUser();
|
$user = $this->entityManager->getRepository(User::class)->getAnonymousUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user instanceof User) {
|
//Check if we the change_permission permission has changed from allow to disallow
|
||||||
//Check if we the change_permission permission has changed from allow to disallow
|
if (($user instanceof User) && false === ($this->resolver->inherit(
|
||||||
if (false === ($this->resolver->inherit($user, 'users', 'edit_permissions') ?? false)) {
|
$user,
|
||||||
$this->context->addViolation($constraint->message);
|
'users',
|
||||||
}
|
'edit_permissions'
|
||||||
}
|
) ?? false)) {
|
||||||
|
$this->context->addViolation($constraint->message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,9 +60,4 @@ class NoneOfItsChildren extends Constraint
|
||||||
* @var string The message used if it is tried to use one of the children for as parent
|
* @var string The message used if it is tried to use one of the children for as parent
|
||||||
*/
|
*/
|
||||||
public $children_message = 'validator.noneofitschild.children';
|
public $children_message = 'validator.noneofitschild.children';
|
||||||
|
|
||||||
public function validatedBy()
|
|
||||||
{
|
|
||||||
return parent::validatedBy(); // TODO: Change the autogenerated stub
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ class SelectableValidator extends ConstraintValidator
|
||||||
* Checks if the passed value is valid.
|
* Checks if the passed value is valid.
|
||||||
*
|
*
|
||||||
* @param mixed $value The value that should be validated
|
* @param mixed $value The value that should be validated
|
||||||
* @param \Symfony\Component\Validator\Constraint $constraint The constraint for the validation
|
* @param Constraint $constraint The constraint for the validation
|
||||||
*/
|
*/
|
||||||
public function validate($value, Constraint $constraint): void
|
public function validate($value, Constraint $constraint): void
|
||||||
{
|
{
|
||||||
|
|
|
@ -104,20 +104,18 @@ class ValidPartLotValidator extends ConstraintValidator
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check for onlyExisting
|
//Check for onlyExisting
|
||||||
if ($value->getStorageLocation()->isLimitToExistingParts()) {
|
if ($value->getStorageLocation()->isLimitToExistingParts() && !$parts->contains($value->getPart())) {
|
||||||
if (!$parts->contains($value->getPart())) {
|
$this->context->buildViolation('validator.part_lot.only_existing')
|
||||||
$this->context->buildViolation('validator.part_lot.only_existing')
|
->atPath('storage_location')->addViolation();
|
||||||
->atPath('storage_location')->addViolation();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check for only single part
|
//Check for only single part
|
||||||
if ($value->getStorageLocation()->isOnlySinglePart()) {
|
if ($value->getStorageLocation()->isOnlySinglePart() && ($parts->count() > 0) && !$parts->contains(
|
||||||
if (($parts->count() > 0) && !$parts->contains($value->getPart())) {
|
$value->getPart()
|
||||||
|
)) {
|
||||||
$this->context->buildViolation('validator.part_lot.single_part')
|
$this->context->buildViolation('validator.part_lot.single_part')
|
||||||
->atPath('storage_location')->addViolation();
|
->atPath('storage_location')->addViolation();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ class RedirectControllerTest extends WebTestCase
|
||||||
$this->userRepo = $this->em->getRepository(User::class);
|
$this->userRepo = $this->em->getRepository(User::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function urlMatchDataProvider()
|
public function urlMatchDataProvider(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['/', true],
|
['/', true],
|
||||||
|
@ -99,7 +99,7 @@ class RedirectControllerTest extends WebTestCase
|
||||||
$this->assertSame($expect_redirect, $response->isRedirect());
|
$this->assertSame($expect_redirect, $response->isRedirect());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function urlAddLocaleDataProvider()
|
public function urlAddLocaleDataProvider(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
//User locale, original target, redirect target
|
//User locale, original target, redirect target
|
||||||
|
|
|
@ -57,11 +57,11 @@ class PasswordChangeNeededSubscriberTest extends TestCase
|
||||||
|
|
||||||
//A user without a group must not redirect
|
//A user without a group must not redirect
|
||||||
$user->setGroup(null);
|
$user->setGroup(null);
|
||||||
$this->assertFalse(\App\EventSubscriber\UserSystem\PasswordChangeNeededSubscriber::TFARedirectNeeded($user));
|
$this->assertFalse(PasswordChangeNeededSubscriber::TFARedirectNeeded($user));
|
||||||
|
|
||||||
//When the group does not enforce the redirect the user must not be redirected
|
//When the group does not enforce the redirect the user must not be redirected
|
||||||
$user->setGroup($group);
|
$user->setGroup($group);
|
||||||
$this->assertFalse(\App\EventSubscriber\UserSystem\PasswordChangeNeededSubscriber::TFARedirectNeeded($user));
|
$this->assertFalse(PasswordChangeNeededSubscriber::TFARedirectNeeded($user));
|
||||||
|
|
||||||
//The user must be redirected if the group enforces 2FA and it does not have a method
|
//The user must be redirected if the group enforces 2FA and it does not have a method
|
||||||
$group->setEnforce2FA(true);
|
$group->setEnforce2FA(true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue