function RealisticDummyContentEntityBase::__construct in Realistic Dummy Content 7
Constructor.
Parameters
$entity: The entity object.
$type: The entity type of the object, for example user or node.
$filter: If set, only certain fields will be considered when manipulating the object. This can be useful, for example for users, because two separate manipulations need to be performed, depending on whether hook_user_insert() or hook_user_presave(). Both hooks need to modify only certain properties and fields, but taken together the entire object can be manipulated. The filter is an associative array which can contain no key (all fields and properties should be manipulated), the include key (fields included are the only ones to be manipulated, or the exclude key (all fields except those included are the ones to be manipulated).
realistic_dummy_content_api_user_insert() defines the array ('exclude' => array(picture)) whereas realistic_dummy_content_api_user_presave() defines the array ('include' => array(picture)). Therefore taken together these two hooks manipulate the entire user object, but in two phases.
File
- api/
includes/ RealisticDummyContentEntityBase.inc, line 47 - Define RealisticDummyContentEntityBase autoload class.
Class
- RealisticDummyContentEntityBase
- Generic entity manipulator.
Code
function __construct($entity, $type, $filter = array()) {
$this->entity = $entity;
$this->hash = md5(serialize($entity));
$this->type = $type;
$this->filter = $filter;
}