Bug #6928
ObjectContainerBuilder does not work for factory setups
Status: | Closed | Start date: | ||
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | - | % Done: | 0% |
|
Category: | Object | |||
Target version: | TYPO3 Flow Base Distribution - 1.0 alpha 11 | |||
PHP Version: | Complexity: | |||
Has patch: | Affected Flow version: |
Description
When configuring argument injection with a factory object and no name/classname the object container builder throws an exception (after fixing the first symptom), which is:
Notice: Undefined index: name in /.../Object/Configuration/ConfigurationBuilder.php line 162
The line causing this reads as follows:
static protected function parseArgumentOfTypeObject($argumentName, $objectNameOrConfiguration, $configurationSourceHint) { if (is_array($objectNameOrConfiguration)) { $objectName = $objectNameOrConfiguration['name'];
The Objects.yaml used:
F3\SwiftMailer\Mailer: arguments: 1: object: factoryObjectName: F3\SwiftMailer\TransportFactory arguments: 1: setting: SwiftMailer.transport.type 2: setting: SwiftMailer.transport.options
Setting a classname there is not an option, as it would not be registered anyway. For property injection the case of a missing object name is handled on ConfigurationBuilder by those lines in parsePropertyOfTypeObject
:
if (isset($objectNameOrConfiguration['name'])) { $objectName = $objectNameOrConfiguration['name']; unset($objectNameOrConfiguration['name']); } else { $objectName = NULL; }
Adding this to parseArgumentOfTypeObject
does the trick, but then we come to the error in the object builder:
Notice: Undefined index: in /.../Object/Container/ObjectContainerBuilder.php line 280
The line causing this reads as follows:
if ($argumentValue instanceof \F3\FLOW3\Object\Configuration\Configuration) { $argumentValueObjectName = $argumentValue->getObjectName(); if ($this->objectConfigurations[$argumentValueObjectName]->getScope() === \F3\FLOW3\Object\Configuration\Configuration::SCOPE_PROTOTYPE) { $assignments[] = $assignmentPrologue . '$this->getPrototype(\'' . $argumentValueObjectName . '\', array(' . $this->buildMethodParametersCode($argumentValue->getArguments()) . '))';
The bottom line is: using a factory with no object/class name does not work (anymore), neither for property nor argument injection.
Associated revisions
[+BUGFIX] FLOW3 (Configuration): getConfiguration() now returns settings for all packages if asked to do so, fixes #6967.
[+BUGFIX] FLOW3 (Object): Interfaces with no known implementation but a factory can be used now, fixes #6968, relates to #6928.
[~TASK] FLOW3 (Utility): In environment we no longer prohibit access to to $_SERVER, this makes use of third party code easier.
History
#1 Updated by Karsten Dambekalns over 5 years ago
- Status changed from Accepted to New
- Assigned To deleted (
Karsten Dambekalns) - Start date deleted (
2010-03-19)
Postponing as it can be gotten to work with a marker interface and some YAML magic. Needs to be discussed.
#2 Updated by Robert Lemke about 5 years ago
- Status changed from New to Needs Feedback
- Priority changed from Must have to Should have
- Target version set to 1.0 alpha 11
#3 Updated by Karsten Dambekalns almost 5 years ago
- Status changed from Needs Feedback to Closed
Closing, as the problem has not surfaced again so far. And in cases like these, adding an interface to allow for type hints makes sense, so the "workaround" actually looks like a good idea.