[TYPO3-mvc] Settings inside a Validator

Bastian Waidelich bastian at typo3.org
Thu Feb 24 14:46:16 CET 2011


Peter Bücker wrote:

Hi Peter,

>> what is a good approach to get access to all TS-Settings in
>> Model-Validator?

> I use a dedicated settings service for this: http://pastie.org/1602063.

Nice one!
Two annotations though:
1. You might want to fetch the settings only if needed instead of doing 
this in the inject method:
protected $settings = NULL;
[...]
public function getSettings() {
   if ($this->settings === NULL) {
      $this->settings = 
$this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS);
   }
   return $this->settings;
}

2. The getByPath method does almost the same as 
Tx_Extbase_Reflection_ObjectAccess::getPropertyPath()


BTW: you should think twice about referring to extension settings in 
your validator / domain models. Usually you want to configure them from 
"the outside" in order to reduce the dependencies and to keep the parts 
reusable.
Thats by the way a reason, why settings are not in all objects by default.

Best,
Bastian


More information about the TYPO3-project-typo3v4mvc mailing list