apply rector rules

This commit is contained in:
2025-10-30 01:20:52 +01:00
parent 7a790d43ec
commit 14d65fa931
91 changed files with 306 additions and 571 deletions

View File

@@ -34,7 +34,6 @@ class ConfigureOpenstackObjectStorageCommand extends Command
$this->tempUrlKey = $config['temp_url_key'];
$this->basePath = $config['temp_url_base_path'];
parent::__construct();
}
protected function configure()

View File

@@ -15,27 +15,19 @@ use Chill\DocStoreBundle\AsyncUpload\TempUrlGeneratorInterface;
use Chill\DocStoreBundle\Entity\StoredObject;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
/**
* This class extends the AbstractExtension class and provides Twig filter functions for generating URLs for asynchronous
* file uploads.
*/
class AsyncUploadExtension extends AbstractExtension
class AsyncUploadExtension
{
public function __construct(
private readonly TempUrlGeneratorInterface $tempUrlGenerator,
private readonly UrlGeneratorInterface $routingUrlGenerator,
) {}
public function getFilters()
{
return [
new TwigFilter('file_url', $this->computeSignedUrl(...)),
new TwigFilter('generate_url', $this->computeGenerateUrl(...)),
];
}
#[\Twig\Attribute\AsTwigFilter('file_url')]
public function computeSignedUrl(StoredObject|string $file, string $method = 'GET', ?int $expiresDelay = null): string
{
if ($file instanceof StoredObject) {
@@ -47,6 +39,7 @@ class AsyncUploadExtension extends AbstractExtension
return $this->tempUrlGenerator->generate($method, $object_name, $expiresDelay)->url;
}
#[\Twig\Attribute\AsTwigFilter('generate_url')]
public function computeGenerateUrl(StoredObject|string $file, string $method = 'GET', ?int $expiresDelay = null): string
{
if ($file instanceof StoredObject) {

View File

@@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry;
* @method AccompanyingCourseDocument|null findOneBy(array $criteria, array $orderBy = null)
* @method AccompanyingCourseDocument[] findAll()
* @method AccompanyingCourseDocument[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\DocStoreBundle\Entity\AccompanyingCourseDocument>
*/
class AccompanyingCourseDocumentRepository extends ServiceEntityRepository
{

View File

@@ -17,6 +17,8 @@ use Doctrine\Persistence\ManagerRegistry;
/**
* @template-extends ServiceEntityRepository<StoredObjectPointInTime>
*
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\DocStoreBundle\Entity\StoredObjectPointInTime>
*/
class StoredObjectPointInTimeRepository extends ServiceEntityRepository
{

View File

@@ -31,7 +31,7 @@ final class AsyncUploadVoter extends Voter
return self::GENERATE_SIGNATURE === $attribute && $subject instanceof SignedUrl;
}
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
{
/** @var SignedUrl $subject */
if (!in_array($subject->method, ['POST', 'GET', 'HEAD', 'PUT'], true)) {

View File

@@ -41,7 +41,7 @@ class StoredObjectVoter extends Voter
&& $subject instanceof StoredObject;
}
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
{
/** @var StoredObject $subject */
$attributeAsEnum = StoredObjectRoleEnum::from($attribute);