public function RealisticDummyContentEntityBase::__construct in Realistic Dummy Content 7.2
Same name and namespace in other branches
- 8.2 api/src/includes/RealisticDummyContentEntityBase.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentEntityBase::__construct()
- 3.x api/src/includes/RealisticDummyContentEntityBase.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentEntityBase::__construct()
Constructor.
Parameters
object $entity: The entity object.
string $type: The entity type of the object, for example user or node.
array $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.
Throws
\Exception
File
- api/
src/ includes/ RealisticDummyContentEntityBase.php, line 46
Class
- RealisticDummyContentEntityBase
- Generic entity manipulator.
Namespace
Drupal\realistic_dummy_content_api\includesCode
public function __construct($entity, $type, $filter = array()) {
realistic_dummy_content_api_argcheck(array(
'is_object',
'realistic_dummy_content_api_argcheck_entitytype',
));
$this->entity = $entity;
$this->hash = md5(serialize($entity));
$this->type = $type;
$this->filter = $filter;
}