Skip to content

Commit 85d7f24

Browse files
committed
MC-41838: Simplify paths
1 parent 4bbc110 commit 85d7f24

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

AdobeStockImage/Model/Storage/Save.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
class Save
2424
{
2525
private const IMAGE_FILE_NAME_PATTERN = '#\.(jpg|jpeg|gif|png)$# i';
26-
private const MAX_LENGTH = 255;
2726

2827
/**
2928
* @var Filesystem
@@ -39,6 +38,7 @@ class Save
3938
* @var IsPathExcludedInterface
4039
*/
4140
private $isPathExcluded;
41+
private $maxFileLength;
4242

4343
/**
4444
* @param Filesystem $filesystem
@@ -48,11 +48,13 @@ class Save
4848
public function __construct(
4949
Filesystem $filesystem,
5050
Https $driver,
51-
IsPathExcludedInterface $isPathExcluded
51+
IsPathExcludedInterface $isPathExcluded,
52+
$maxFileLength
5253
) {
5354
$this->filesystem = $filesystem;
5455
$this->driver = $driver;
5556
$this->isPathExcluded = $isPathExcluded;
57+
$this->maxFileLength = $maxFileLength;
5658
}
5759

5860
/**
@@ -67,10 +69,10 @@ public function __construct(
6769
*/
6870
public function execute(string $imageUrl, string $destinationPath, bool $allowOverwrite = false): void
6971
{
70-
$maxFilenameLength = self::MAX_LENGTH;
72+
$maxFilenameLength = $this->maxFileLength;
7173

7274
if (strlen($destinationPath) > $maxFilenameLength) {
73-
throw new \LengthException(
75+
throw new \InputException(
7476
__('Destination Path is too long; must be %1 characters or less', $maxFilenameLength)
7577
);
7678
}

AdobeStockImage/etc/di.xml

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

0 commit comments

Comments
 (0)