Merge branch 'master' into log_detail_page

This commit is contained in:
Jan Böhmer 2023-04-29 22:46:38 +02:00
commit 4c6ceab8e8
291 changed files with 1994 additions and 1621 deletions

View file

@ -140,7 +140,7 @@ class AttachmentManager
}
/**
* Returns a human readable version of the attachment file size.
* Returns a human-readable version of the attachment file size.
* For external attachments, null is returned.
*
* @param int $decimals The number of decimals numbers that should be printed

View file

@ -30,7 +30,7 @@ use SplFileInfo;
use Symfony\Component\Filesystem\Filesystem;
/**
* This service provides functions to find attachments via an reverse search based on a file.
* This service provides functions to find attachments via a reverse search based on a file.
*/
class AttachmentReverseSearch
{
@ -53,7 +53,7 @@ class AttachmentReverseSearch
*
* @param SplFileInfo $file The file for which is searched
*
* @return Attachment[] an list of attachments that use the given file
* @return Attachment[] a list of attachments that use the given file
*/
public function findAttachmentsByFile(SplFileInfo $file): array
{
@ -75,11 +75,11 @@ class AttachmentReverseSearch
* @param SplFileInfo $file The file that should be removed
* @param int $threshold the threshold used, to determine if a file should be deleted or not
*
* @return bool True, if the file was delete. False if not.
* @return bool True, if the file was deleted. False if not.
*/
public function deleteIfNotUsed(SplFileInfo $file, int $threshold = 1): bool
{
/* When the file is used more then $threshold times, don't delete it */
/* When the file is used more than $threshold times, don't delete it */
if (count($this->findAttachmentsByFile($file)) > $threshold) {
return false;
}

View file

@ -108,7 +108,7 @@ class AttachmentSubmitHandler
*/
public function isValidFileExtension(AttachmentType $attachment_type, UploadedFile $uploadedFile): bool
{
//Only validate if the attachment type has specified an filetype filter:
//Only validate if the attachment type has specified a filetype filter:
if (empty($attachment_type->getFiletypeFilter())) {
return true;
}
@ -121,10 +121,10 @@ class AttachmentSubmitHandler
/**
* Generates a filename for the given attachment and extension.
* The filename contains a random id, so every time this function is called you get an unique name.
* The filename contains a random id, so every time this function is called you get a unique name.
*
* @param Attachment $attachment The attachment that should be used for generating an attachment
* @param string $extension The extension that the new file should have (must only contain chars allowed in pathes)
* @param string $extension The extension that the new file should have (must only contain chars allowed in paths)
*
* @return string the new filename
*/
@ -136,7 +136,7 @@ class AttachmentSubmitHandler
$extension
);
//Use the (sanatized) attachment name as an filename part
//Use the (sanatized) attachment name as a filename part
$safeName = transliterator_transliterate(
'Any-Latin; Latin-ASCII; [^A-Za-z0-9_] remove; Lower()',
$attachment->getName()
@ -177,12 +177,12 @@ class AttachmentSubmitHandler
}
/**
* Handle the submit of an attachment form.
* Handle submission of an attachment form.
* This function will move the uploaded file or download the URL file to server, if needed.
*
* @param Attachment $attachment the attachment that should be used for handling
* @param UploadedFile|null $file If given, that file will be moved to the right location
* @param array $options The options to use with the upload. Here you can specify that an URL should be downloaded,
* @param array $options The options to use with the upload. Here you can specify that a URL should be downloaded,
* or an file should be moved to a secure location.
*
* @return Attachment The attachment with the new filename (same instance as passed $attachment)
@ -219,7 +219,7 @@ class AttachmentSubmitHandler
}
/**
* Rename attachments with an unsafe extension (meaning files which would be runned by a to a safe one.
* Rename attachments with an unsafe extension (meaning files which would be run by a to a safe one).
* @param Attachment $attachment
* @return Attachment
*/
@ -261,7 +261,7 @@ class AttachmentSubmitHandler
$resolver->setDefaults([
//If no preview image was set yet, the new uploaded file will become the preview image
'become_preview_if_empty' => true,
//When an URL is given download the URL
//When a URL is given download the URL
'download_url' => false,
'secure_attachment' => false,
]);
@ -357,17 +357,17 @@ class AttachmentSubmitHandler
//File download should be finished here, so determine the new filename and extension
$headers = $response->getHeaders();
//Try to determine an filename
//Try to determine a filename
$filename = '';
//If an content disposition header was set try to extract the filename out of it
//If a content disposition header was set try to extract the filename out of it
if (isset($headers['content-disposition'])) {
$tmp = [];
preg_match('/[^;\\n=]*=([\'\"])*(.*)(?(1)\1|)/', $headers['content-disposition'][0], $tmp);
$filename = $tmp[2];
}
//If we dont know filename yet, try to determine it out of url
//If we don't know filename yet, try to determine it out of url
if ('' === $filename) {
$filename = basename(parse_url($url, PHP_URL_PATH));
}
@ -375,7 +375,7 @@ class AttachmentSubmitHandler
//Set original file
$attachment->setFilename($filename);
//Check if we have a extension given
//Check if we have an extension given
$pathinfo = pathinfo($filename);
if (!empty($pathinfo['extension'])) {
$new_ext = $pathinfo['extension'];
@ -443,11 +443,13 @@ class AttachmentSubmitHandler
];
if (ctype_digit((string) $maxSize)) {
return (int) $maxSize;
} elseif (preg_match('/^(\d++)('.implode('|', array_keys($factors)).')$/i', $maxSize, $matches)) {
return (((int) $matches[1]) * $factors[strtolower($matches[2])]);
} else {
throw new RuntimeException(sprintf('"%s" is not a valid maximum size.', $maxSize));
}
if (preg_match('/^(\d++)('.implode('|', array_keys($factors)).')$/i', $maxSize, $matches)) {
return (((int) $matches[1]) * $factors[strtolower($matches[2])]);
}
throw new RuntimeException(sprintf('"%s" is not a valid maximum size.', $maxSize));
}
/*

View file

@ -25,12 +25,7 @@ namespace App\Services\Attachments;
use App\Entity\Attachments\Attachment;
use InvalidArgumentException;
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
use Liip\ImagineBundle\Service\FilterService;
use Psr\Log\LoggerInterface;
use RuntimeException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\UrlHelper;
use Symfony\Component\Routing\Generator\UrlGenerator;
use function strlen;
use Symfony\Component\Asset\Packages;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
@ -62,7 +57,7 @@ class AttachmentURLGenerator
}
/**
* Converts the absolute file path to a version relative to the public folder, that can be passed to asset
* Converts the absolute file path to a version relative to the public folder, that can be passed to the
* Asset Component functions.
*
* @param string $absolute_path the absolute path that should be converted
@ -82,7 +77,7 @@ class AttachmentURLGenerator
$public_path = $this->public_path;
}
//Our absolute path must begin with public path or we can not use it for asset pathes.
//Our absolute path must begin with public path, or we can not use it for asset pathes.
if (0 !== strpos($absolute_path, $public_path)) {
return null;
}
@ -92,7 +87,7 @@ class AttachmentURLGenerator
}
/**
* Converts a placeholder path to a path to a image path.
* Converts a placeholder path to a path to an image path.
*
* @param string $placeholder_path the placeholder path that should be converted
*/
@ -125,7 +120,7 @@ class AttachmentURLGenerator
}
/**
* Returns a URL to an thumbnail of the attachment file.
* Returns a URL to a thumbnail of the attachment file.
* @return string|null The URL or null if the attachment file is not existing
*/
public function getThumbnailURL(Attachment $attachment, string $filter_name = 'thumbnail_sm'): ?string
@ -160,7 +155,7 @@ class AttachmentURLGenerator
//So we remove the schema manually
return preg_replace('/^https?:/', '', $tmp);
} catch (\Imagine\Exception\RuntimeException $e) {
//If the filter fails, we can not serve the thumbnail and fall back to the original image and log an warning
//If the filter fails, we can not serve the thumbnail and fall back to the original image and log a warning
$this->logger->warning('Could not open thumbnail for attachment with ID ' . $attachment->getID() . ': ' . $e->getMessage());
return $this->assets->getUrl($asset_path);
}

View file

@ -29,7 +29,7 @@ use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\Cache\ItemInterface;
/**
* An servive that helps working with filetype filters (based on the format <input type=file> accept uses.
* A service that helps to work with filetype filters (based on the format <input type=file> accept uses).
* See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Unique_file_type_specifiers for
* more details.
*/

View file

@ -80,7 +80,7 @@ class ElementTypeNameGenerator
}
/**
* Gets an localized label for the type of the entity.
* Gets a localized label for the type of the entity.
* A part element becomes "Part" ("Bauteil" in german) and a category object becomes "Category".
* Useful when the type should be shown to user.
* Throws an exception if the class is not supported.
@ -95,7 +95,7 @@ class ElementTypeNameGenerator
{
$class = is_string($entity) ? $entity : get_class($entity);
//Check if we have an direct array entry for our entity class, then we can use it
//Check if we have a direct array entry for our entity class, then we can use it
if (isset($this->mapping[$class])) {
return $this->mapping[$class];
}

View file

@ -23,13 +23,12 @@ declare(strict_types=1);
namespace App\Services\Formatters;
use App\Entity\Parts\MeasurementUnit;
use App\Services\Formatters\SIFormatter;
use InvalidArgumentException;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* This service formats an part amout using a Measurement Unit.
* This service formats a part amount using a Measurement Unit.
*/
class AmountFormatter
{
@ -77,7 +76,7 @@ class AmountFormatter
//Otherwise just output it
if (!empty($options['unit'])) {
$format_string = '%.'.$options['decimals'].'f '.$options['unit'];
} else { //Dont add space after number if no unit was specified
} else { //Don't add space after number if no unit was specified
$format_string = '%.'.$options['decimals'].'f';
}
@ -127,7 +126,7 @@ class AmountFormatter
$resolver->setAllowedTypes('decimals', 'int');
$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 don't show any decimals
if ($options['is_integer']) {
return 0;
}

View file

@ -25,7 +25,7 @@ namespace App\Services\Formatters;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* This class allows you to convert markdown text to HTML.
* This class allows you to convert Markdown text to HTML.
*/
class MarkdownParser
{
@ -40,7 +40,7 @@ class MarkdownParser
* Mark the markdown for rendering.
* The rendering of markdown is done on client side.
*
* @param string $markdown the markdown text that should be parsed to html
* @param string $markdown the Markdown text that should be parsed to html
* @param bool $inline_mode When true, p blocks will have no margins behind them
*
* @return string the markdown in a version that can be parsed on client side

View file

@ -38,7 +38,7 @@ class MoneyFormatter
}
/**
* Format the the given value in the given currency.
* Format the given value in the given currency.
*
* @param string|float $value the value that should be formatted
* @param Currency|null $currency The currency that should be used for formatting. If null the global one is used

View file

@ -45,7 +45,7 @@ class SIFormatter
*
* @param int $magnitude the magnitude for which the prefix should be determined
*
* @return array A array, containing the divisor in first element, and the prefix symbol in second. For example, [1000, "k"].
* @return array An array, containing the divisor in first element, and the prefix symbol in second. For example, [1000, "k"].
*/
public function getPrefixByMagnitude(int $magnitude): array
{

View file

@ -26,8 +26,6 @@ use InvalidArgumentException;
use League\Csv\Reader;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
class BOMImporter
{
@ -114,7 +112,7 @@ class BOMImporter
foreach ($csv->getRecords() as $offset => $entry) {
//Translate the german field names to english
$entry = array_combine(array_map(function ($key) {
$entry = array_combine(array_map(static function ($key) {
return self::MAP_KICAD_PCB_FIELDS[$key] ?? $key;
}, array_keys($entry)), $entry);

View file

@ -24,7 +24,6 @@ namespace App\Services\ImportExportSystem;
use App\Entity\Base\AbstractNamedDBElement;
use Symfony\Component\OptionsResolver\OptionsResolver;
use function in_array;
use InvalidArgumentException;
use function is_array;
use ReflectionClass;
@ -75,7 +74,6 @@ class EntityExporter
}
//Ensure that all entities are of type AbstractNamedDBElement
$entity_type = null;
foreach ($entities as $entity) {
if (!$entity instanceof AbstractNamedDBElement) {
throw new InvalidArgumentException('All entities must be of type AbstractNamedDBElement!');

View file

@ -50,7 +50,7 @@ trait PKImportHelperTrait
*/
protected function convertAttachmentDataToEntity(array $attachment_row, string $target_class, string $type): Attachment
{
//By default we use the cached version
//By default, we use the cached version
if (!$this->import_attachment_type) {
//Get the import attachment type
$this->import_attachment_type = $this->em->getRepository(AttachmentType::class)->findOneBy([
@ -103,7 +103,7 @@ trait PKImportHelperTrait
/**
* Imports the attachments from the given data
* @param array $data The PartKeepr database
* @param string $table_name The table name for the attachments (if it contain "image", it will be treated as an image)
* @param string $table_name The table name for the attachments (if it contains "image", it will be treated as an image)
* @param string $target_class The target class (e.g. Part)
* @param string $target_id_field The field name where the target ID is stored
* @param string $attachment_class The attachment class (e.g. PartAttachment)

View file

@ -30,7 +30,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
/**
* This service is used to other non mandatory data from a PartKeepr export.
* This service is used to other non-mandatory data from a PartKeepr export.
* You have to import the datastructures and parts first to use project import!
*/
class PKOptionalImporter

View file

@ -41,13 +41,12 @@ declare(strict_types=1);
namespace App\Services\LabelSystem;
use App\Entity\Base\AbstractDBElement;
use App\Entity\Base\AbstractStructuralDBElement;
use App\Entity\LabelSystem\LabelOptions;
use App\Services\LabelSystem\Barcodes\BarcodeContentGenerator;
use Com\Tecnick\Barcode\Barcode;
use InvalidArgumentException;
use PhpParser\Node\Stmt\Label;
use Symfony\Component\Mime\MimeTypes;
use Twig\Extra\Html\HtmlExtension;
final class BarcodeGenerator
{
@ -125,7 +124,7 @@ final class BarcodeGenerator
return $bobj->getSvgCode();
}
public function getContent(LabelOptions $options, object $target): ?string
public function getContent(LabelOptions $options, AbstractDBElement $target): ?string
{
switch ($options->getBarcodeType()) {
case 'qr':

View file

@ -106,7 +106,7 @@ final class LabelGenerator
}
/**
* Converts width and height given in mm to an size array, that can be used by DOMPDF for page size.
* Converts width and height given in mm to a size array, that can be used by DOMPDF for page size.
*
* @param float $width The width of the paper
* @param float $height The height of the paper

View file

@ -70,7 +70,7 @@ final class LabelProfileDropdownHelper
$repo = $this->entityManager->getRepository(LabelProfile::class);
return $this->cache->get($key, function (ItemInterface $item) use ($repo, $type, $secure_class_name) {
// Invalidate when groups, a element with the class or the user changes
// Invalidate when groups, an element with the class or the user changes
$item->tag(['groups', 'tree_treeview', $this->keyGenerator->generateKey(), $secure_class_name]);
return $repo->getDropdownProfiles($type);

View file

@ -21,7 +21,6 @@
namespace App\Services\LabelSystem\PlaceholderProviders;
use App\Entity\LabelSystem\LabelOptions;
use App\Entity\LabelSystem\LabelProfile;
use App\Services\LabelSystem\BarcodeGenerator;
use App\Services\LabelSystem\Barcodes\BarcodeContentGenerator;

View file

@ -45,7 +45,6 @@ use App\Entity\UserSystem\User;
use DateTime;
use IntlDateFormatter;
use Locale;
use Symfony\Component\Routing\Generator\UrlGenerator;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Security;

View file

@ -101,12 +101,12 @@ class EventLogger
return true;
}
//If the normal log function does not added the log entry, we just do nothing
//If the normal log function does not get added to the log entry, we just do nothing
return false;
}
/**
* Adds the given log entry to the Log, if the entry fullfills the global configured criterias and flush afterwards.
* Adds the given log entry to the Log, if the entry fulfills the global configured criteria and flush afterward.
*
* @return bool returns true, if the event was added to log
*/
@ -129,12 +129,12 @@ class EventLogger
$blacklist = $blacklist ?? $this->blacklist;
$whitelist = $whitelist ?? $this->whitelist;
//Dont add the entry if it does not reach the minimum level
//Don't add the entry if it does not reach the minimum level
if ($logEntry->getLevel() > $minimum_log_level) {
return false;
}
//Check if the event type is black listed
//Check if the event type is blacklisted
if (!empty($blacklist) && $this->isObjectClassInArray($logEntry, $blacklist)) {
return false;
}
@ -144,7 +144,7 @@ class EventLogger
return false;
}
// By default all things should be added
// By default, all things should be added
return true;
}

View file

@ -91,7 +91,7 @@ class EventUndoHelper
}
/**
* Clear the currently the set undone event.
* Clear the currently set undone event.
*/
public function clearUndoneEvent(): void
{
@ -99,7 +99,7 @@ class EventUndoHelper
}
/**
* Check if a event is undone.
* Check if an event is undone.
*/
public function isUndo(): bool
{

View file

@ -58,7 +58,7 @@ class LogEntryExtraFormatter
}
/**
* Return an user viewable representation of the extra data in a log entry, styled for console output.
* Return a user viewable representation of the extra data in a log entry, styled for console output.
*/
public function formatConsole(AbstractLogEntry $logEntry): string
{
@ -81,7 +81,7 @@ class LogEntryExtraFormatter
}
/**
* Return a HTML formatted string containing a user viewable form of the Extra data.
* Return an HTML formatted string containing a user viewable form of the Extra data.
*/
public function format(AbstractLogEntry $context): string
{

View file

@ -35,10 +35,8 @@ use Brick\Math\BigDecimal;
use DateTime;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\ORM\Mapping\MappingException;
use DoctrineExtensions\Query\Mysql\Date;
use Exception;
use InvalidArgumentException;
use ReflectionClass;
@ -138,7 +136,7 @@ class TimeTravel
continue;
}
//Revert many to one association (one element in property)
//Revert many-to-one association (one element in property)
if (
ClassMetadataInfo::MANY_TO_ONE === $mapping['type']
|| ClassMetadataInfo::ONE_TO_ONE === $mapping['type']
@ -158,7 +156,7 @@ class TimeTravel
}
foreach ($target_elements as $target_element) {
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 exist at $timestamp
if (!$this->repo->getElementExistedAtTimestamp(
$target_element,
$timestamp

View file

@ -93,7 +93,7 @@ class ParameterExtractor
[, $name, $value] = $matches;
$value = trim($value);
//Dont allow empty names or values (these are a sign of an invalid extracted string)
//Don't allow empty names or values (these are a sign of an invalid extracted string)
if (empty($name) || empty($value)) {
return null;
}

View file

@ -3,7 +3,6 @@
namespace App\Services\Parts;
use App\Entity\LogSystem\PartStockChangedLogEntry;
use App\Entity\Parts\Part;
use App\Entity\Parts\PartLot;
use App\Services\LogSystem\EventCommentHelper;
use App\Services\LogSystem\EventLogger;

View file

@ -153,13 +153,13 @@ class PricedetailHelper
foreach ($orderdetails as $orderdetail) {
$pricedetail = $orderdetail->findPriceForQty($amount);
//When we dont have informations about this amount, ignore it
//When we don't have information about this amount, ignore it
if (null === $pricedetail) {
continue;
}
$converted = $this->convertMoneyToCurrency($pricedetail->getPricePerUnit(), $pricedetail->getCurrency(), $currency);
//Ignore price informations that can not be converted to base currency.
//Ignore price information that can not be converted to base currency.
if (null !== $converted) {
$avg = $avg->plus($converted);
++$count;

View file

@ -79,7 +79,7 @@ class ProjectBuildHelper
}
/**
* Checks if the given project can be build with the current stock.
* Checks if the given project can be built with the current stock.
* This means that the maximum buildable count is greater or equal than the requested $number_of_projects
* @param Project $project
* @parm int $number_of_builds
@ -91,7 +91,7 @@ class ProjectBuildHelper
}
/**
* Check if the given BOM entry can be build with the current stock.
* Check if the given BOM entry can be built with the current stock.
* This means that the maximum buildable count is greater or equal than the requested $number_of_projects
* @param ProjectBOMEntry $bom_entry
* @param int $number_of_builds
@ -137,7 +137,7 @@ class ProjectBuildHelper
/**
* Withdraw the parts from the stock using the given ProjectBuildRequest and create the build parts entries, if needed.
* The ProjectBuildRequest has to be validated before!!
* You have to flush changes to DB afterwards
* You have to flush changes to DB afterward
* @param ProjectBuildRequest $buildRequest
* @return void
*/

View file

@ -93,7 +93,7 @@ class StatisticsHelper
}
/**
* Returns the number of all parts which have price informations.
* Returns the number of all parts which have price information.
*
* @throws NoResultException
* @throws NonUniqueResultException
@ -147,7 +147,7 @@ class StatisticsHelper
}
/**
* Gets the count of all external (only containing an URL) attachments.
* Gets the count of all external (only containing a URL) attachments.
*
* @throws NoResultException
* @throws NonUniqueResultException
@ -158,7 +158,7 @@ class StatisticsHelper
}
/**
* Gets the count of all attachments where the user uploaded an file.
* Gets the count of all attachments where the user uploaded a file.
*
* @throws NoResultException
* @throws NonUniqueResultException

View file

@ -59,7 +59,7 @@ class TagFinder
$options = $resolver->resolve($options);
//If the keyword is too short we will get to much results, which takes too much time...
//If the keyword is too short we will get too much results, which takes too much time...
if (mb_strlen($keyword) < $options['min_keyword_length']) {
return [];
}

View file

@ -81,7 +81,7 @@ final class PermissionExtractor implements ExtractorInterface
}
/**
* Sets the prefix that should be used for new found messages.
* Sets the prefix that should be used for new-found messages.
*
* @param string $prefix The prefix
*/

View file

@ -62,7 +62,7 @@ class NodesListBuilder
$key = 'list_'.$this->keyGenerator->generateKey().'_'.$secure_class_name.$parent_id;
return $this->cache->get($key, function (ItemInterface $item) use ($class_name, $parent, $secure_class_name) {
// Invalidate when groups, a element with the class or the user changes
// Invalidate when groups, an element with the class or the user changes
$item->tag(['groups', 'tree_list', $this->keyGenerator->generateKey(), $secure_class_name]);
/** @var StructuralDBElementRepository $repo */
$repo = $this->em->getRepository($class_name);

View file

@ -35,7 +35,7 @@ class StructuralElementRecursionHelper
}
/**
* Executes an function (callable) recursivly for $element and every of its children.
* Executes a function (callable) recursivly for $element and every of its children.
*
* @param AbstractStructuralDBElement $element The element on which the func should be executed
* @param callable $func The function which should be executed for each element.

View file

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace App\Services\Trees;
use App\Entity\Attachments\AttachmentType;
use App\Entity\Attachments\PartAttachment;
use App\Entity\ProjectSystem\Project;
use App\Entity\LabelSystem\LabelProfile;
use App\Entity\Parts\Category;
@ -46,7 +45,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
/**
* This Service generates the tree structure for the tools.
* Whenever you change something here, you has to clear the cache, because the results are cached for performance reasons.
* Whenever you change something here, you have to clear the cache, because the results are cached for performance reasons.
*/
class ToolsTreeBuilder
{
@ -71,7 +70,7 @@ class ToolsTreeBuilder
}
/**
* Generates the tree for the tools menu.
* Generates the tree for the tools' menu.
* The result is cached.
*
* @return TreeViewNode[] the array containing all Nodes for the tools menu

View file

@ -33,10 +33,8 @@ use App\Entity\Parts\Storelocation;
use App\Entity\Parts\Supplier;
use App\Helpers\Trees\TreeViewNode;
use App\Helpers\Trees\TreeViewNodeIterator;
use App\Helpers\Trees\TreeViewNodeState;
use App\Repository\StructuralDBElementRepository;
use App\Services\EntityURLGenerator;
use App\Services\Formatters\MarkdownParser;
use App\Services\UserSystem\UserCacheKeyGenerator;
use Doctrine\ORM\EntityManagerInterface;
use InvalidArgumentException;
@ -49,14 +47,14 @@ use function count;
class TreeViewGenerator
{
protected $urlGenerator;
protected $em;
protected $cache;
protected $keyGenerator;
protected $translator;
protected EntityURLGenerator $urlGenerator;
protected EntityManagerInterface $em;
protected TagAwareCacheInterface $cache;
protected UserCacheKeyGenerator $keyGenerator;
protected TranslatorInterface $translator;
protected $rootNodeExpandedByDefault;
protected $rootNodeEnabled;
protected bool $rootNodeExpandedByDefault;
protected bool $rootNodeEnabled;
public function __construct(EntityURLGenerator $URLGenerator, EntityManagerInterface $em,
TagAwareCacheInterface $treeCache, UserCacheKeyGenerator $keyGenerator, TranslatorInterface $translator, bool $rootNodeExpandedByDefault, bool $rootNodeEnabled)
@ -211,7 +209,7 @@ class TreeViewGenerator
/** @var StructuralDBElementRepository $repo */
$repo = $this->em->getRepository($class);
//If we just want a part of a tree, dont cache it
//If we just want a part of a tree, don't cache it
if (null !== $parent) {
return $repo->getGenericNodeTree($parent);
}
@ -220,7 +218,7 @@ class TreeViewGenerator
$key = 'treeview_'.$this->keyGenerator->generateKey().'_'.$secure_class_name;
return $this->cache->get($key, function (ItemInterface $item) use ($repo, $parent, $secure_class_name) {
// Invalidate when groups, a element with the class or the user changes
// Invalidate when groups, an element with the class or the user changes
$item->tag(['groups', 'tree_treeview', $this->keyGenerator->generateKey(), $secure_class_name]);
return $repo->getGenericNodeTree($parent);

View file

@ -114,7 +114,7 @@ class PermissionManager
/** @var Group $parent */
$parent = $user->getGroup();
while (null !== $parent) { //The top group, has parent == null
//Check if our current element gives a info about disallow/allow
//Check if our current element gives an info about disallow/allow
$allowed = $this->dontInherit($parent, $permission, $operation);
if (null !== $allowed) {
return $allowed;
@ -123,7 +123,7 @@ class PermissionManager
$parent = $parent->getParent();
}
return null; //The inherited value is never resolved. Should be treat as false, in Voters.
return null; //The inherited value is never resolved. Should be treated as false, in Voters.
}
/**
@ -150,7 +150,7 @@ class PermissionManager
/**
* Lists the names of all operations that is supported for the given permission.
*
* If the Permission is not existing at all, a exception is thrown.
* If the Permission is not existing at all, an exception is thrown.
*
* This function is useful for the support() function of the voters.
*
@ -203,7 +203,6 @@ class PermissionManager
{
//If we have changed anything on the permission structure due to the alsoSet value, this becomes true, so we
//redo the whole process, to ensure that all alsoSet values are set recursively.
$anything_changed = false;
do {
$anything_changed = false; //Reset the variable for the next iteration

View file

@ -48,7 +48,7 @@ class PermissionPresetsHelper
*/
public function applyPreset(HasPermissionsInterface $perm_holder, string $preset_name): HasPermissionsInterface
{
//We need to reset the permission data first (afterwards all values are inherit)
//We need to reset the permission data first (afterward all values are inherit)
$perm_holder->getPermissions()->resetPermissions();
switch($preset_name) {

View file

@ -36,11 +36,7 @@ class PermissionSchemaUpdater
{
$perm_data = $holder->getPermissions();
if ($perm_data->getSchemaVersion() < PermissionData::CURRENT_SCHEMA_VERSION) {
return true;
}
return false;
return $perm_data->getSchemaVersion() < PermissionData::CURRENT_SCHEMA_VERSION;
}
/**

View file

@ -26,7 +26,7 @@ use Exception;
use RuntimeException;
/**
* This class generates random backup codes for two factor authentication.
* This class generates random backup codes for two-factor authentication.
*/
class BackupCodeGenerator
{

View file

@ -25,7 +25,7 @@ namespace App\Services\UserSystem\TFA;
use App\Entity\UserSystem\User;
/**
* This services offers methods to manage backup codes for two factor authentication.
* This services offers methods to manage backup codes for two-factor authentication.
*/
class BackupCodeManager
{
@ -38,7 +38,7 @@ class BackupCodeManager
/**
* Enable backup codes for the given user, by generating a set of backup codes.
* If the backup codes were already enabled before, they a.
* If the backup codes were already enabled before, nothing happens.
*/
public function enableBackupCodes(User $user): void
{
@ -48,7 +48,7 @@ class BackupCodeManager
}
/**
* Disable (remove) the backup codes when no other 2 factor authentication methods are enabled.
* Disable (remove) the backup codes when no other two-factor authentication methods are enabled.
*/
public function disableBackupCodesIfUnused(User $user): void
{