Feature #8258

call initializeObject() also after Reconstitution

Added by Sebastian Kurfuerst over 11 years ago. Updated almost 11 years ago.

Status:
Resolved
Priority:
Should have
Category:
Object
Start date:
2010-06-15
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
Complexity:

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.


Files

flow3-8258.patch (9.05 KB) flow3-8258.patch first version Sebastian Kurfuerst, 2010-06-15 18:36
#1

Updated by Sebastian Kurfuerst over 11 years ago

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 over 11 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 over 11 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 over 11 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 over 11 years ago

  • Status changed from Accepted to Resolved
  • % Done changed from 0 to 100

Applied in changeset r4517.

Also available in: Atom PDF