mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-01-15 05:41:25 +00:00
apply rector rules
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user