Feature #8258
call initializeObject() also after Reconstitution
Status: | Resolved | Start date: | 2010-06-15 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | Sebastian Kurfuerst | % Done: | 100% |
|
Category: | Object | |||
Target version: | TYPO3 Flow Base Distribution - 1.0 alpha 10 | |||
PHP Version: | Complexity: | |||
Has patch: |
Description
for some cases, it makes sense to call the initializer method (initializeObject()) also after reconstituting an object, and re-injecting its dependencies -- so one can set up calculated properties where a dependency is needed for calculation.
We agreed to pass a parameter (constant) to initializeObject, so one can determine if it is the "NEW" or the "RECONSTITUTE"-case.
TODO: also Documentation must be updated.
Associated revisions
[!!!][+FEATURE] FLOW3 (Object): The lifecycle initialization method (typically initializeObject()) is now also called after recreating an object (f.e. when it is recreated from persistent storage). Additionally, initializeObject() now gets a parameter to determine if creation or recreation took place. Resolves #8258.
History
#1 Updated by Sebastian Kurfuerst about 5 years ago
- File flow3-8258.patch added
This is the first version of the Object Container which calls initializeObject also after reconstitution.
Comments are of course highly welcome!
#2 Updated by Karsten Dambekalns about 5 years ago
- Category set to Object
The methods buildLifecycleInitializationCommand() and buildLifecycleReconstitutionCommand() differ only in the used constant. Better use only one and pass the constant as parameter, no?
#3 Updated by Robert Lemke about 5 years ago
- Target version set to 1.0 alpha 10
Generally fine but please consider the following changes:
- (Karsten's comment) The methods buildLifecycleInitializationCommand() and buildLifecycleReconstitutionCommand() differ only in the used constant. Better use only one and pass the constant as parameter, no?
- It's a bit ugly, but maybe more meaningful: How about naming the constants "INITIALIZATIONCAUSE_CREATED" and "INITIALIZATIONCAUSE_RECREATED" respectively?
- As a further optimization step you can use the value of the constant directly when building the static object container code because it's just a cache file anyway and not supposed to be read by humans:
$command = "\n\t\t\$o->$lifecycleInitializationMethodName(" . \F3\FLOW3\Object\Container\ObjectContainerInterface::OBJECT_RECONSTITUTED . ");";
#4 Updated by Sebastian Kurfuerst about 5 years ago
Hey Robert,
- (Karsten's comment) The methods buildLifecycleInitializationCommand() and buildLifecycleReconstitutionCommand() differ only in the used constant. Better use only one and pass the constant as parameter, no?
Yep.
- It's a bit ugly, but maybe more meaningful: How about naming the constants "INITIALIZATIONCAUSE_CREATED" and "INITIALIZATIONCAUSE_RECREATED" respectively?
Then I would suggest INITIALIZATIONCAUSE_CREATED and INITIALIZATIONCAUSE_RECONSTITUTED; would this be better as "recreate"? Is the place for the constants correct?
- As a further optimization step you can use the value of the constant directly when building the static object container code because it's just a cache file anyway and not supposed to be read by humans:
Will do.
Greets,
Sebastian
#5 Updated by Sebastian Kurfuerst about 5 years ago
- Status changed from Accepted to Resolved
- % Done changed from 0 to 100
Applied in changeset r4517.