Skip to content

Commit

Permalink
Merge pull request #12 from leanormandon/feat/allow_2_words_item_types
Browse files Browse the repository at this point in the history
Allow images from item type with 2 words (ex HeaderHighlights)
  • Loading branch information
zawaze committed May 14, 2024
2 parents b41e9bc + 0098e55 commit fc3c477
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Config/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>1.2.6</version>
<version>1.2.7</version>
<authors>
<author>
<name></name>
Expand Down
9 changes: 8 additions & 1 deletion Controller/Front/LegacyImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,16 @@ public function getImageInformation(
);
}

private function getSnakeFromCamelCase($camelCase): string
{
$pattern = '/(?<=\\w)(?=[A-Z])|(?<=[a-z])(?=[0-9])/';
$snakeCase = preg_replace($pattern, '_', $camelCase);
return strtolower($snakeCase);
}

private function getSourceFilePath($itemType, $imageId)
{
$tableMapClass = PropelResolver::getTableMapByTableName($itemType);
$tableMapClass = PropelResolver::getTableMapByTableName($this->getSnakeFromCamelCase($itemType));
$tableMap = new $tableMapClass();

/** @var ModelCriteria $queryClass */
Expand Down

0 comments on commit fc3c477

Please sign in to comment.