* @author Jérôme Billiras */ class BackOfficePath extends BaseModule { /** @var string Translation domain */ const MESSAGE_DOMAIN = 'backofficepath'; /** @var string Default admin path */ const DEFAULT_THELIA_PREFIX = 'admin'; /** @var string Configuration key for new path */ const CONFIG_PATH = 'back_office_path'; /** @var string Configuration key for using default path */ const CONFIG_USE_DEFAULT_PATH = 'back_office_path_default_enabled'; /** @var string Request attribute key to determine if custom admin path is in use */ const IS_CUSTOM_ADMIN_PATH = 'is_custom_admin_path'; public function preActivation(ConnectionInterface $con = null) { $prefix = ConfigQuery::read(self::CONFIG_PATH); if ($prefix === null) { ConfigQuery::write(self::CONFIG_PATH, '', false, true); } $enabled = ConfigQuery::read(self::CONFIG_USE_DEFAULT_PATH, null); if ($enabled === null) { ConfigQuery::write(self::CONFIG_USE_DEFAULT_PATH, true, false, true); } return true; } /** * Replace url in content * * @param string $content * @param string $oldPrefix * @param string $newPrefix * * @return string Content with replaced urls */ public static function replaceUrl($content, $oldPrefix, $newPrefix) { $replacedUrl = preg_replace( '#(.*?)/' . preg_quote($oldPrefix, '#') . '(.*?)#', '$1/' . $newPrefix . '$2', $content ); return $replacedUrl; } }