For my AppBundle (THE APPLICATION ITSELF, NOT A REUSABLE BUNDLE) I have a configuration parameter that is a path.
I'd like to be sure the path ends with a /.
In this moment I have a method in the entity that uses this path (yes is an entity and not a controller) adjust the configuration parameter with a code like this:
public function buildLogoFolder($folder)
{
// Replace the placeholder with the current Entity's URL
$folder = str_replace('{entity_domain}', $this->getDomain()->getCanonical(), $folder);
$folder = rtrim(ltrim($folder, '/'), '/') . '/';
return $folder;
}
As the $folder parameter comes from the config.yml file I'd like to move outside of the entity this adjustment.
I think I should use a solution similar to the one suggested here, that is the use of the DependencyInjection component.
I think the process is very similar to the loading of a configuration file for a new bundle as explained in the Symfony's documentation but I'm not sure on how to proceed.
Is there someone who can put me on the right way?
I'd like to automate the process. I want read the folder configuration parameter value and then adjust it with the method I wrote above.
I want to be sure that the folder parameter configured ever ends with a trailing slash, also if the developer didn't write it in the configuration.
So, If the developer write something like path/to/folder the resulting configuration parameter is automatically adjusted to path/to/folder/.
/?folderparameter (question updated to be more precise)