function _publication_date_published_at_setter in Publication Date 7.2
Publication date setter for hook_entity_property_info_alter()
Parameters
object $entity: The entity object.
string $name: The name of the published_at field.
string $value: The timestamp to set as this entity's publication date.
1 string reference to '_publication_date_published_at_setter'
File
- ./
publication_date.module, line 351 - Add a field to nodes containing the publication date.
Code
function _publication_date_published_at_setter(&$entity, $name, $value = NULL) {
// If a valid timestamp is provided then set it as the publication date.
if ($value !== NULL && is_int($value)) {
$entity->published_at = $value;
$entity->published_at_or_now = $value;
$entity->published_at_or_changed = $value;
$entity->published_at_or_created = $value;
}
elseif ($value === NULL && $entity->status) {
$entity->published_at = REQUEST_TIME;
$entity->published_at_or_now = REQUEST_TIME;
$entity->published_at_or_changed = REQUEST_TIME;
$entity->published_at_or_created = REQUEST_TIME;
}
elseif ($value === NULL) {
$entity->published_at = NULL;
$entity->published_at_or_now = REQUEST_TIME;
$entity->published_at_or_changed = $entity->changed;
$entity->published_at_or_created = $entity->created;
}
}