Inject Settings from other packages

Hello everyone!

I’m using a “top level” package “Framework” (Neos Flow 6.3.0), which contains functions usable for all other packages.

Currently I’m building a FileUploadService in the Framework package. However, which file type, which file size etc is allowed is stored in the package related configuration yaml files of the other packages.

In Framework I have to inject the settings from the other packages. Using the following code, I’m just getting the setttings of the Framework package:

     * @var array
     * @Flow\InjectConfiguration()
    protected $fileUploadSettings;

Something like

     * @var array
     * @Flow\InjectConfiguration(package="ALL")
    protected $fileUploadSettings;

would be nice.

Until now, I’m fetching all the settings via signal/slot. Is there a more elegant way?

Thank you!


if i understand correctly you dont just want the all the settings of package a or b but ALL the settings… ?

you can just simply ask the ConfigurationManager and call the getConfiguration(‘settings’) (or similar, look up the code ^^)

maybe even objects.yaml could help, by specifing that settings should be used for a certain property, but not accessing a specific path like: propertyA: settings: ""

or use object yaml with the ConfigurationManager as factory … see Inject Settings from other packages - #9 by Marc

You can get the configuration via package key and path like so:

               * Setting from current package 
               * @var string
               * @Flow\InjectConfiguration("")
              protected $name;

               * Setting from "SomeOther.Package" package 
               * @var string
               * @Flow\InjectConfiguration(path="email", package="SomeOther.Package")
              protected $emailAddress;

see: Object Framework — Flow Framework dev-master documentation

Dear Marc!

Thank you very much for your prompt reply. "you dont just want the all the settings of package a or b but ALL the settings… " Yes, you’re right. In the worst case Framework package doesn’t know, which other packages are installed.

Following your suggestions, I tried the following:

 * @var ConfigurationManager
 * @Flow\Inject
protected $configurationManager;

    $settings = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_PROCESSING_TYPE_SETTINGS);

    echo "<pre>";
    echo "</pre>"; die;

$settings is an empty array :frowning: Any idea what I missed?

Again thank you very much for your help!

Dear Martin,

thank you very much for your help. How to inject settings of a specific package I know. However, in the worst case the Framework package does not know, wich other packages are installed. Therefore, I’m looking for a more generic way…

The ./flow configuartion:show command does pretty much what you want in lines 69-73 flow-development-collection/ConfigurationCommandController.php at 8.3 · neos/flow-development-collection · GitHub

Martin, you’re great. Thank you! I used the wrong constant. Now it’s working:

    $settings = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS);
1 Like

aaand you dont need the first line :wink:

i played a bit around :wink: you probably know that flow will automaticaly inject the current packages settings, if you have a injectSettings method right Configuration — Flow Framework dev-master documentation?

you can have the same for all settings - it might be a bit over engineered but here we go:

namespace Foo\Bar;

class Lol
    public function injectAllSettings(array $settings)
        // global settings

    public function injectSettings(array $settings)
        // local package settings
        factoryObjectName: Neos\Flow\Configuration\ConfigurationManager
        factoryMethodName: getConfiguration
            value: "%Neos\\Flow\\Configuration\\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS%"

tested it works :stuck_out_tongue: - merry christmas!