Skip to content

Commit af34f82

Browse files
committed
MC-41844: Passing config from DI
1 parent d9da575 commit af34f82

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

AdobeStockImage/Model/Storage/Save.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
*/
2222
class Save
2323
{
24-
private const MAX_LENGTH = 255;
25-
2624
/**
2725
* @var Filesystem
2826
*/
@@ -33,15 +31,20 @@ class Save
3331
*/
3432
private $driver;
3533

34+
private $maxFileLength;
35+
3636
/**
3737
* Storage constructor.
3838
* @param Filesystem $filesystem
3939
* @param Https $driver
40+
* @param $maxFileLength
4041
*/
4142
public function __construct(
4243
Filesystem $filesystem,
43-
Https $driver
44+
Https $driver,
45+
$maxFileLength
4446
) {
47+
$this->maxFileLength = $maxFileLength;
4548
$this->filesystem = $filesystem;
4649
$this->driver = $driver;
4750
}
@@ -59,11 +62,9 @@ public function __construct(
5962
public function execute(string $imageUrl, string $destinationPath = '') : string
6063
{
6164
$mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);
62-
$maxFilenameLength = self::MAX_LENGTH;
63-
64-
if (strlen($destinationPath) > $maxFilenameLength) {
65+
if (strlen($destinationPath) > $this->maxFileLength) {
6566
throw new InputException(
66-
__('Destination path is too long; must be %1 characters or less', $maxFilenameLength)
67+
__('Destination path is too long; must be %1 characters or less', $this->maxFileLength)
6768
);
6869
}
6970

AdobeStockImage/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<type name="Magento\AdobeStockImage\Model\Storage\Save">
3838
<arguments>
3939
<argument name="driver" xsi:type="object">Magento\Framework\Filesystem\Driver\Https</argument>
40+
<argument name="maxFileLength" xsi:type="number">255</argument>
4041
</arguments>
4142
</type>
4243
<type name="Magento\AdobeStockImage\Model\GetRelatedImages">

0 commit comments

Comments
 (0)