class FacebookPublicationEntity in Facebook Autopost 7
The class used for Facebook publication entities.
Hierarchy
- class \Entity implements EntityInterface
- class \FacebookPublicationEntity
Expanded class hierarchy of FacebookPublicationEntity
1 string reference to 'FacebookPublicationEntity'
- fb_autopost_entity_entity_info in fb_autopost_entity/
fb_autopost_entity.module - Implements hook_entity_info().
File
- fb_autopost_entity/
fb_autopost_entity.module, line 387 - Module implementation file
View source
class FacebookPublicationEntity extends Entity {
/**
* The Facebook publication id.
*
* @var integer
*/
public $fbpid;
/**
* The name of the Facebook publication type.
*
* @var string
*/
public $type;
/**
* The Facebook publication label.
*
* @var string
*/
public $label;
/**
* The user id of the Facebook publication owner.
*
* @var integer
*/
public $uid;
/**
* The Unix timestamp when the Facebook publication was created.
*
* @var integer
*/
public $created;
/**
* The Unix timestamp when the Facebook publication was most recently saved.
*
* @var integer
*/
public $changed;
/**
* The ID string returned from Facebook on publication.
*
* @var string
*/
public $facebook_id;
/**
* Entity constructor.
*/
public function __construct($values = array()) {
if (isset($values['user'])) {
$this
->setUser($values['user']);
unset($values['user']);
}
if (isset($values['type']) && is_object($values['type'])) {
$values['type'] = $values['type']->type;
}
if (!isset($values['label']) && isset($values['type']) && ($type = facebook_publication_get_types($values['type']))) {
// Initialize the label with the type label, so newly created publications
// have that as interim label.
$values['label'] = $type->label;
}
parent::__construct($values, 'facebook_publication');
}
/**
* Returns the user owning this Facebook publication.
*/
public function user() {
return user_load($this->uid);
}
/**
* Sets a new user owning this Facebook publication.
*
* @param object $account
* The user account object or the user account id (uid).
*/
public function setUser($account) {
$this->uid = is_object($account) ? $account->uid : $account;
}
/**
* Gets the associated Facebook publication type object.
*
* @return FacebookPublicationTypeEntity
* Returns the type entity.
*/
public function type() {
return facebook_publication_get_types($this->type);
}
/**
* Gets the associated facebook_id.
*
* @return string
* String representing the Facebook ID.
*/
public function facebookid() {
return $this->facebook_id;
}
/**
* Returns the full url() for the Facebook publication.
*/
public function url() {
$uri = $this
->uri();
return url($uri['path'], $uri);
}
/**
* Returns the drupal path to this Facebook publication.
*/
public function path() {
$uri = $this
->uri();
return $uri['path'];
}
/**
* Gets the default URI for the publication.
*/
public function defaultUri() {
return array(
// TODO: Define this URL in hook_menu.
'path' => 'facebook-publication/' . $this->fbpid,
);
}
/**
* Build entity content based on $view_mode and $lagcode.
*/
public function buildContent($view_mode = 'full', $langcode = NULL) {
$content = array();
// Assume newly create objects are still empty.
if (!empty($this->is_new)) {
$content['empty']['#markup'] = '<em class="facebook-pulbication-no-data">' . t('There is no Facebook publication data yet.') . '</em>';
}
return entity_get_controller($this->entityType)
->buildContent($this, $view_mode, $langcode, $content);
}
/**
* Save the entity.
*/
public function save() {
// Care about setting created and changed values. But do not automatically
// set a created values for already existing Facebook publications.
if (empty($this->created) && (!empty($this->is_new) || !$this->fbpid)) {
$this->created = REQUEST_TIME;
}
$this->changed = REQUEST_TIME;
parent::save();
}
/**
* Get the property names out of the field names associated to this entity.
*
* @param array $field_names
* A numeric array containing the field names to translate.
*
* @return array
* A keyed array with field name => property name.
*/
public function getFieldProperties($field_names = NULL) {
if (empty($field_names)) {
// Get all the field names associated with this entity bundle.
$field_names = array_keys(field_info_instances('facebook_publication', $publication->type));
}
$output = array();
foreach ($field_names as $field_name) {
// Remove 'field_facebook_' prefix from field names.
$output[$field_name] = substr($field_name, strlen('field_facebook_'));
}
// Allow other modules to alter this default behavior.
drupal_alter('field_property_data', $output);
return $output;
}
}
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:: |
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. | |
FacebookPublicationEntity:: |
public | property | The Unix timestamp when the Facebook publication was most recently saved. | |
FacebookPublicationEntity:: |
public | property | The Unix timestamp when the Facebook publication was created. | |
FacebookPublicationEntity:: |
public | property | The ID string returned from Facebook on publication. | |
FacebookPublicationEntity:: |
public | property | The Facebook publication id. | |
FacebookPublicationEntity:: |
public | property | The Facebook publication label. | |
FacebookPublicationEntity:: |
public | property | The name of the Facebook publication type. | |
FacebookPublicationEntity:: |
public | property | The user id of the Facebook publication owner. | |
FacebookPublicationEntity:: |
public | function |
Build entity content based on $view_mode and $lagcode. Overrides Entity:: |
|
FacebookPublicationEntity:: |
public | function |
Gets the default URI for the publication. Overrides Entity:: |
|
FacebookPublicationEntity:: |
public | function | Gets the associated facebook_id. | |
FacebookPublicationEntity:: |
public | function | Get the property names out of the field names associated to this entity. | |
FacebookPublicationEntity:: |
public | function | Returns the drupal path to this Facebook publication. | |
FacebookPublicationEntity:: |
public | function |
Save the entity. Overrides Entity:: |
|
FacebookPublicationEntity:: |
public | function | Sets a new user owning this Facebook publication. | |
FacebookPublicationEntity:: |
public | function | Gets the associated Facebook publication type object. | |
FacebookPublicationEntity:: |
public | function | Returns the full url() for the Facebook publication. | |
FacebookPublicationEntity:: |
public | function | Returns the user owning this Facebook publication. | |
FacebookPublicationEntity:: |
public | function |
Entity constructor. Overrides Entity:: |