vendor/vich/uploader-bundle/src/Templating/Helper/UploaderHelper.php line 39

Open in your IDE?
  1. <?php
  2. namespace Vich\UploaderBundle\Templating\Helper;
  3. use Vich\UploaderBundle\Storage\StorageInterface;
  4. /**
  5.  * UploaderHelper.
  6.  *
  7.  * @author Dustin Dobervich <ddobervich@gmail.com>
  8.  */
  9. class UploaderHelper
  10. {
  11.     /**
  12.      * @var StorageInterface
  13.      */
  14.     protected $storage;
  15.     public function __construct(StorageInterface $storage)
  16.     {
  17.         $this->storage $storage;
  18.     }
  19.     public function getName(): string
  20.     {
  21.         return 'vich_uploader';
  22.     }
  23.     /**
  24.      * Gets the public path for the file associated with the
  25.      * object.
  26.      *
  27.      * @param object|array $obj       The object
  28.      * @param string|null  $fieldName The field name
  29.      * @param string|null  $className The object's class. Mandatory if $obj can't be used to determine it
  30.      *
  31.      * @return string|null The public asset path or null if file not stored
  32.      */
  33.     public function asset($obj, ?string $fieldName null, ?string $className null)
  34.     {
  35.         return $this->storage->resolveUri($obj$fieldName$className);
  36.     }
  37. }