vendor/oneup/uploader-bundle/src/Templating/Helper/UploaderHelper.php line 22

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Oneup\UploaderBundle\Templating\Helper;
  4. use Symfony\Component\Routing\RouterInterface;
  5. class UploaderHelper
  6. {
  7.     public function __construct(protected RouterInterface $router, protected array $maxsize)
  8.     {
  9.     }
  10.     public function getName(): string
  11.     {
  12.         return 'oneup_uploader';
  13.     }
  14.     public function endpoint(string $key): string
  15.     {
  16.         return $this->router->generate(sprintf('_uploader_upload_%s'$key));
  17.     }
  18.     public function progress(string $key): string
  19.     {
  20.         return $this->router->generate(sprintf('_uploader_progress_%s'$key));
  21.     }
  22.     public function cancel(string $key): string
  23.     {
  24.         return $this->router->generate(sprintf('_uploader_cancel_%s'$key));
  25.     }
  26.     public function uploadKey(): string
  27.     {
  28.         return (string) \ini_get('session.upload_progress.name');
  29.     }
  30.     public function maxSize(string $key): int
  31.     {
  32.         if (!\array_key_exists($key$this->maxsize)) {
  33.             throw new \InvalidArgumentException('No such mapping found to get maxsize for.');
  34.         }
  35.         return $this->maxsize[$key];
  36.     }
  37. }