public function CerFieldChainHandler::__construct in Corresponding Entity References 7.3
File
- includes/
CerFieldChainHandler.inc, line 34 - Contains the CerFieldChainHandler object.
Class
- CerFieldChainHandler
- @class Wraps around every CerFieldHandler object in a chain. In any given chain, there could be many entities that need to be processed -- think about multi-value field collections embedded within other multi-value field collections, and you…
Code
public function __construct(CerFieldChain $chain, EntityDrupalWrapper $entity) {
$this->chain = $chain;
$this->entity = $entity;
$chain
->__wakeup();
$chain
->seek($entity->cer->depth
->value());
$field = $chain
->current();
// If the field has a child, there could be extensive recusion here. So we'll need
// to iterate over the entire chain recursively -- luckily, SPL provides the
// RecursiveIteratorIterator class for this purpose. But if there are no children,
// we don't need to recurse; the only handler we'll need to load is the current
// field's, for the current entity.
if ($field
->child()) {
$this->handlers = new RecursiveIteratorIterator(new CerEndPointIterator($field, $entity));
}
else {
// Wrap the handler in an array, just to normalize things internally.
$this->handlers = array(
$field
->getHandler($entity),
);
}
}