Skip to content

Commit 1415e5a

Browse files
committed
#27536: Added public method for retrieving search patterns from configuration
1 parent 2b7e6a5 commit 1415e5a

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

app/code/Magento/MediaContent/Model/Content/Config.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
*/
1515
class Config
1616
{
17+
private const XML_PATH_SEARCH_PATTERNS = 'search/patterns';
18+
1719
/**
1820
* @var DataInterface
1921
*/
@@ -38,4 +40,14 @@ public function get($key = null, $default = null)
3840
{
3941
return $this->data->get($key, $default);
4042
}
43+
44+
/**
45+
* Retrieve search regexp patterns for finding media asset paths within content
46+
*
47+
* @return array
48+
*/
49+
public function getSearchPatterns(): array
50+
{
51+
return $this->get(self::XML_PATH_SEARCH_PATTERNS);
52+
}
4153
}

app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
*/
1919
class ExtractAssetsFromContent implements ExtractAssetsFromContentInterface
2020
{
21-
private const XML_PATH_SEARCH_PATTERNS = 'search/patterns';
22-
2321
/**
2422
* @var Config
2523
*/
@@ -57,7 +55,7 @@ public function execute(string $content): array
5755
{
5856
$paths = [];
5957

60-
foreach ($this->config->get(self::XML_PATH_SEARCH_PATTERNS) as $pattern) {
58+
foreach ($this->config->getSearchPatterns() as $pattern) {
6159
if (empty($pattern)) {
6260
continue;
6361
}

0 commit comments

Comments
 (0)