public function FieldByClassEnhancer::enhance in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony-cmf/routing/Enhancer/FieldByClassEnhancer.php \Symfony\Cmf\Component\Routing\Enhancer\FieldByClassEnhancer::enhance()
If the source field is instance of one of the entries in the map, target is set to the value of that map entry.
Overrides RouteEnhancerInterface::enhance
File
- vendor/
symfony-cmf/ routing/ Enhancer/ FieldByClassEnhancer.php, line 60
Class
- FieldByClassEnhancer
- This enhancer sets a field if not yet existing from the class of an object in another field.
Namespace
Symfony\Cmf\Component\Routing\EnhancerCode
public function enhance(array $defaults, Request $request) {
if (isset($defaults[$this->target])) {
// no need to do anything
return $defaults;
}
if (!isset($defaults[$this->source])) {
return $defaults;
}
// we need to loop over the array and do instanceof in case the content
// class extends the specified class
// i.e. phpcr-odm generates proxy class for the content.
foreach ($this->map as $class => $value) {
if ($defaults[$this->source] instanceof $class) {
// found a matching entry in the map
$defaults[$this->target] = $value;
return $defaults;
}
}
return $defaults;
}