Bug #61995

Extbase: Overwriting objects by TS not working in CommandController?

Added by Vitoandre D'Oria about 5 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Extbase
Target version:
Start date:
2014-10-01
Due date:
% Done:

0%

TYPO3 Version:
6.2
PHP Version:
5.3
Tags:
Complexity:
medium
Is Regression:
No
Sprint Focus:

Description

plugin.tx_ext {
    objects {
        TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface {
            className = MY\Ext\Configuration\ConfigurationManager
        }
        TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager {
            className = MY\Ext\Configuration\BackendConfigurationManager
        }
    }
}
module.tx_ext < plugin.tx_ext

    MyCommand($pid) {
        $this->configurationManager = $this->objectManager->get('\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface');
        $this->configurationManager->setCurrentPageId($pid);
    }

I also got the following questions:
1.) Why aren't we able to change the pid in BE? For Tasks its possible to obtain a pid but since you initially set this value we are not able to just do $_POST['id'] = $pid; afterwards. Neither we are able to overwrite the pid.

2.) Documentation of this objects Syntax is not existing? I just found some old config.tx_extbase example blogs and the code here: https://review.typo3.org/#/c/16855/4/Classes/Core/Bootstrap.php makes no sense (at least to me).
Why $classNameWithDot ???

From \TYPO3\CMS\Extbase\Object\Container\Container i would guess i have to overwrite the interface instead the concrete class!? Does this make a difference (in both cases its not working for me)?:


    /**
     * register a classname that should be used if a dependency is required.
     * e.g. used to define default class for a interface
     *
     * @param string $className
     * @param string $alternativeClassName
     */
    public function registerImplementation($className, $alternativeClassName) {
        $this->alternativeImplementation[$className] = $alternativeClassName;
    }

Hope someone explains that feature or points me to a wiki? page that isn't completely outdated. I also wouldn't mind it if the source code was better documented e.g. samples like the one given here :-)

ps. does this feature also have a official name? Searching for className, objects TypoScript isn't that great.


Related issues

Duplicates TYPO3 Core - Bug #60296: Task executor ignores full framework configuration Closed 2014-07-14
Duplicates TYPO3 Core - Bug #60381: Local object configuration ignored in CLI context New 2014-07-18

History

#1 Updated by Vitoandre D'Oria about 5 years ago

I am using now a workaround which involves $this->configurationManager->setConfiguration(). Should i feel guilty while using this function?

Sets the specified raw configuration coming from the outside. Note that this is a low level method and only makes sense to be used by Extbase internally.

I simply placed the TS on the first page:

    plugin.tx_my.persistence.perstoragePid = 1,2,3

    plugin.tx_my.language.0.storagePid < plugin.tx_my.persistence.perstoragePid
    plugin.tx_my.language.0.storagePid := addToList(4)

    plugin.tx_my.language.1.storagePid < plugin.tx_my.persistence.perstoragePid
    plugin.tx_my.language.1.storagePid := addToList(5)

and got the following TS at the plugin page:

    plugin.tx_my.persistence.storagePid < plugin.tx_my.settings.language.0.storagePid
    [globalVar = GP:L = 1]
    plugin.tx_my.persistence.storagePid < plugin.tx_my.settings.language.1.storagePid
    [global]

With this TS its possible to have different storagePids in FE and in BE simply traverse the language array
and overwrite $frameworkConfiguration['persistence']['storagePid'] by using $this->configurationManager->setConfiguration($frameworkConfiguration);
Of course you could also give your CommandController a sys_language_uid and process that one only.

I really like this approach. Also regarding setConfiguration() i am currently using this for a proxy plugin that forwards the request to individual controllers. The controllers won't have their own TS loaded nor a correct storagePid set. But setConfiguration() allows me to set the individual configuration.

Again i think that's a nice approach and thus wonder if that function should really only be used for internal calls.

I also wonder why it's not the default behaviour when someone forwards a request (to load the appropriate Framework)

Edit: The reason for split storagePid's lies in the language overlay (no L=1 page without L=0) limitations of TYPO3. We are using 2 sysFolders both sys_language_uid=0 to distinguish between different translations and thus need them split in order to find the requested language records.

#2 Updated by Mathias Brodala almost 5 years ago

  • Status changed from New to Resolved

#3 Updated by Benni Mack about 1 year ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF