This repository has been archived by the owner on May 3, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EZP-26617: Made PlatformUI js & hbt extractors usable on any bundle
- Loading branch information
1 parent
7e4df7b
commit 892a31d
Showing
8 changed files
with
68 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
namespace EzSystems\PlatformUIBundle\Translation; | ||
|
||
use Symfony\Component\Translation\Extractor\AbstractFileExtractor; | ||
|
||
abstract class PlatformUIExtractor extends AbstractFileExtractor | ||
{ | ||
private $pathSuffix = 'Resources/views'; | ||
|
||
/** | ||
* Updates the resource by replacing the path to templates (Resource/views) | ||
* with the path handled by the extractor. | ||
* | ||
* @param string $resource | ||
* @param string $path The path 'Resources/views' should be replaced with | ||
*/ | ||
protected function updateResource(&$resource, $path) | ||
{ | ||
if (is_string($resource) && strpos($resource, $this->pathSuffix) !== null) { | ||
$resource = $this->replacePath($resource, $path); | ||
} elseif (is_array($resource)) { | ||
$resource = array_map( | ||
function ($value) use ($path) { | ||
if (is_string($value) && strpos($value, $this->pathSuffix) !== null) { | ||
return $this->replacePath($value, $path); | ||
} else { | ||
return $value; | ||
} | ||
}, | ||
$resource | ||
); | ||
} | ||
} | ||
|
||
/** | ||
* @param string $in | ||
* @param string $path | ||
* @return string | ||
*/ | ||
private function replacePath(&$in, $path) | ||
{ | ||
return str_replace($this->pathSuffix, $path, $in); | ||
} | ||
} |