class RedhenOrg in RedHen CRM 7
The class used for group entities.
Hierarchy
- class \Entity implements EntityInterface
- class \RedhenOrg
Expanded class hierarchy of RedhenOrg
1 string reference to 'RedhenOrg'
- redhen_org_entity_info in modules/
redhen_org/ redhen_org.module - Implements hook_entity_info().
File
- modules/
redhen_org/ lib/ redhen_org.entity.inc, line 10 - Redhen Group entity classes
View source
class RedhenOrg extends Entity {
// @codingStandardsIgnoreStart
public $label = '', $org_id = NULL, $primary_contact_id = NULL, $author_uid = NULL, $redhen_state = REDHEN_STATE_ACTIVE, $type = '', $created = '', $updated = '';
// @codingStandardsIgnoreEnd
/**
* Override parent constructor.
*/
public function __construct(array $values = array()) {
global $user;
parent::__construct($values, 'redhen_org');
// New organization. is_new might not be set so check for id.
if (!$this->org_id) {
$this->author_uid = $user->uid;
$this->redhen_state = REDHEN_STATE_ACTIVE;
$this->created = REQUEST_TIME;
}
}
/**
* Override buildContent() to add organization properties.
*/
public function buildContent($view_mode = 'full', $langcode = NULL) {
$wrapper = entity_metadata_wrapper('redhen_org', $this);
$primary_contact = $wrapper->primary_contact
->value();
$content['redhen_state'] = array(
'#theme' => 'redhen_property_field',
'#label' => t('State'),
'#items' => array(
array(
'#markup' => $this->redhen_state == REDHEN_STATE_ACTIVE ? t('Active') : t('Inactive'),
),
),
'#classes' => 'field field-label-inline clearfix',
);
if (isset($primary_contact->contact_id)) {
$contact_array = $primary_contact
->view('teaser');
$content['primary_contact'] = array(
'#theme' => 'fieldset',
'#title' => t('Primary Contact'),
'#children' => drupal_render($contact_array),
);
}
return entity_get_controller($this->entityType)
->buildContent($this, $view_mode, $langcode, $content);
}
/**
* Permanently saves the entity.
*
* @return bool
* Returns FALSE if entity was not saved.
*/
public function save() {
$this->updated = REQUEST_TIME;
return parent::save();
}
/**
* Set the primary contact for an organization.
*
* @param RedhenContact $contact
* The RedhenContact to use as the primary contact
*
* @return bool
* Return FALSE if we are unable to set the primary contact
*/
public function setPrimaryContact(RedhenContact $contact) {
// @TODO Check that $contact has a relationship with $this.
$this->primary_contact_id = $contact->contact_id;
return $this
->save();
}
/**
* Set the redhen_state for an organization.
*
* @param string $state
* The REDHEN_STATE_* value to use.
*/
public function setState($state) {
$this->redhen_state = $state;
return $this
->save();
}
/**
* Specifies the default label, which is picked up by label() by default.
*/
protected function defaultLabel() {
$type = redhen_org_get_types($this->type);
return $this->label . ' (' . $type->label . ')';
}
/**
* Specify URI.
*/
protected function defaultUri() {
return array(
'path' => 'redhen/org/' . $this
->internalIdentifier(),
);
}
}
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:: |
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:: |
public | function |
Returns the label of the entity. 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. | |
RedhenOrg:: |
public | property | ||
RedhenOrg:: |
public | function |
Override buildContent() to add organization properties. Overrides Entity:: |
|
RedhenOrg:: |
protected | function |
Specifies the default label, which is picked up by label() by default. Overrides Entity:: |
|
RedhenOrg:: |
protected | function |
Specify URI. Overrides Entity:: |
|
RedhenOrg:: |
public | function |
Permanently saves the entity. Overrides Entity:: |
|
RedhenOrg:: |
public | function | Set the primary contact for an organization. | |
RedhenOrg:: |
public | function | Set the redhen_state for an organization. | |
RedhenOrg:: |
public | function |
Override parent constructor. Overrides Entity:: |