class RedhenNote in RedHen CRM 7
The class used for note entities.
Hierarchy
- class \Entity implements EntityInterface
- class \RedhenNote
Expanded class hierarchy of RedhenNote
1 string reference to 'RedhenNote'
- redhen_note_entity_info in modules/
redhen_note/ redhen_note.module - Implements hook_entity_info().
File
- modules/
redhen_note/ lib/ redhen_note.entity.inc, line 10 - Redhen Group entity classes
View source
class RedhenNote extends Entity {
public $note_id = NULL, $author_uid = NULL, $type = '', $created = '', $updated = '';
public function __construct(array $values = array()) {
parent::__construct($values, 'redhen_note');
// New note. is_new might not be set so check for id
if (!$this->note_id) {
global $user;
$this->created = REQUEST_TIME;
$this->author_uid = $user->uid;
}
}
/**
* Override buildContent() to add note properties.
*/
public function buildContent($view_mode = 'full', $langcode = NULL) {
$wrapper = entity_metadata_wrapper('redhen_note', $this);
$author = $wrapper->author
->value();
$content['author'] = array(
'#theme' => 'redhen_property_field',
'#label' => t('Author'),
'#items' => array(
array(
'#markup' => $author->name,
),
),
'#classes' => 'field field-label-inline clearfix',
);
$content['created'] = array(
'#theme' => 'redhen_property_field',
'#label' => t('Created'),
'#items' => array(
array(
'#markup' => redhen_format_date($this->created),
),
),
'#classes' => 'field field-label-inline clearfix',
);
return entity_get_controller($this->entityType)
->buildContent($this, $view_mode, $langcode, $content);
}
/**
* Override label() to add note label.
*/
public function label() {
$wrapper = entity_metadata_wrapper('redhen_note', $this);
$entity = $wrapper->entity
->value();
// Don't sanitize here as this function should produce unsanitized output.
return t('Note !id on !label', array(
'!id' => $this->note_id,
'!label' => entity_label($wrapper->entity_type
->value(), $wrapper->entity),
));
}
/**
* Permanently saves the entity.
*
* @return bool
* Returns FALSE if entity was not saved.
*/
public function save() {
$this->updated = REQUEST_TIME;
return parent::save();
}
/**
* Specifify URI
*/
protected function defaultUri() {
switch ($this->entity_type) {
case 'redhen_contact':
$path = 'contact';
break;
case 'redhen_org':
$path = 'org';
break;
}
return array(
'path' => 'redhen/' . $path . '/' . $this->entity_id . '/note/' . $this->note_id . '/view',
);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Entity:: |
protected | property | 1 | |
Entity:: |
protected | property | ||
Entity:: |
protected | property | ||
Entity:: |
protected | property | ||
Entity:: |
protected | property | ||
Entity:: |
public | function |
Returns the bundle of the entity. Overrides EntityInterface:: |
|
Entity:: |
protected | function | Defines the entity label if the 'entity_class_label' callback is used. | 1 |
Entity:: |
public | function |
Permanently deletes the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the info of the type of the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the type of the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Exports the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Gets the raw, translated value of a property or field. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Checks if the entity has a certain exportable status. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the entity identifier, i.e. the entities name or numeric id. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the internal, numeric identifier. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Checks whether the entity is the default revision. Overrides EntityInterface:: |
|
Entity:: |
protected | function | Set up the object instance on construction or unserializiation. | |
Entity:: |
public | function |
Returns the uri of the entity just as entity_uri(). Overrides EntityInterface:: |
|
Entity:: |
public | function |
Generate an array for rendering the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the EntityMetadataWrapper of the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function | Magic method to only serialize what's necessary. | |
Entity:: |
public | function | Magic method to invoke setUp() on unserialization. | |
RedhenNote:: |
public | property | ||
RedhenNote:: |
public | function |
Override buildContent() to add note properties. Overrides Entity:: |
|
RedhenNote:: |
protected | function |
Specifify URI Overrides Entity:: |
|
RedhenNote:: |
public | function |
Override label() to add note label. Overrides Entity:: |
|
RedhenNote:: |
public | function |
Permanently saves the entity. Overrides Entity:: |
|
RedhenNote:: |
public | function |
Overrides Entity:: |