Add generateUrlFromPattern method for admin preview
This commit is contained in:
@@ -415,6 +415,31 @@ class UrlPatternManager
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate URL from a specific pattern string (for preview)
|
||||
*
|
||||
* @param string $entityType
|
||||
* @param int $idEntity
|
||||
* @param int $idLang
|
||||
* @param string $pattern Pattern string to use
|
||||
* @return string|null
|
||||
*/
|
||||
public function generateUrlFromPattern($entityType, $idEntity, $idLang, $pattern)
|
||||
{
|
||||
$entityData = $this->getEntityData($entityType, $idEntity, $idLang);
|
||||
if (!$entityData) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$patternConfig = $this->getPattern($entityType) ?: [];
|
||||
$patternConfig['pattern'] = $pattern;
|
||||
|
||||
$url = $this->replacePlaceholders($pattern, $entityData, $patternConfig);
|
||||
$url = $this->applyUrlFormatting($url, $entityType, $patternConfig);
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get entity data for placeholder replacement
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user