Feature #3588
Support value objects in the Object Factory
| Status: | Accepted | Start date: | ||
|---|---|---|---|---|
| Priority: | Should have | Due date: | ||
| Assigned To: | Robert Lemke | % Done: | 0% |
|
| Category: | Object | |||
| Target version: | - | Estimated time: | 12.00 hours | |
| PHP Version: | Complexity: | |||
| Has patch: |
Description
The Object Factory should have special support for value objects.
Value objects are in fact a mixture of protoype and singleton - although multiple instances of a class may exist, we should only create one instance with the same constructor arguments. The Object Factory (and Object Manager) should return an existing value object if a new one with exactly the same arguments (properties) is requested.
Related issues
History
#1 Updated by Robert Lemke about 6 years ago
- Target version changed from 1.0 alpha 2 to 283
#2 Updated by Robert Lemke about 6 years ago
- Target version changed from 283 to 1.0 alpha 3
#3 Updated by Robert Lemke about 6 years ago
- Target version changed from 1.0 alpha 3 to 1.0 alpha 4
#4 Updated by Robert Lemke almost 6 years ago
- Target version deleted (
1.0 alpha 4)
#5 Updated by Karsten Dambekalns over 5 years ago
- Target version set to 1.0 alpha 8
#6 Updated by Robert Lemke over 5 years ago
- Status changed from New to Accepted
- Priority changed from Could have to Should have
- Start date deleted (
2009-06-05) - Estimated time set to 12.00
- value objects are immutable because they must not have setters
- values are passed through the constructor
- calculate hash over constructor arguments + object name and use them in the registry / unit of works
- what about arrays / objects as parameters?
#7 Updated by Robert Lemke over 5 years ago
/**
* After returning advice, generates the value hash for the object
*
* @param \F3\FLOW3\AOP\JoinPointInterface $joinPoint The current join point
* @return void
* @afterreturning classTaggedWith(valueobject) && method(.*->__construct())
* @author Karsten Dambekalns <karsten@typo3.org>
*/
public function generateValueHash(\F3\FLOW3\AOP\JoinPointInterface $joinPoint) {
$proxy = $joinPoint->getProxy();
$hashSource = '';
foreach (array_keys($this->reflectionService->getClassSchema($joinPoint->getClassName())->getProperties()) as $propertyName) {
if (is_array($proxy->FLOW3_AOP_Proxy_getProperty($propertyName))) {
$hashSource .= serialize($proxy->FLOW3_AOP_Proxy_getProperty($propertyName));
} elseif (!is_object($proxy->FLOW3_AOP_Proxy_getProperty($propertyName))) {
$hashSource .= $proxy->FLOW3_AOP_Proxy_getProperty($propertyName);
} elseif (property_exists($proxy->FLOW3_AOP_Proxy_getProperty($propertyName), 'FLOW3_Persistence_Entity_UUID')) {
$hashSource .= $proxy->FLOW3_AOP_Proxy_getProperty($propertyName)->FLOW3_Persistence_Entity_UUID;
} elseif (property_exists($proxy->FLOW3_AOP_Proxy_getProperty($propertyName), 'FLOW3_Persistence_ValueObject_Hash')) {
$hashSource .= $proxy->FLOW3_AOP_Proxy_getProperty($propertyName)->FLOW3_Persistence_Entity_UUID;
}
}
$proxy->FLOW3_Persistence_ValueObject_Hash = sha1($hashSource);
}
#8 Updated by Robert Lemke over 5 years ago
- Target version changed from 1.0 alpha 8 to 1.0 alpha 9
#9 Updated by Robert Lemke about 5 years ago
- Target version deleted (
1.0 alpha 9)