class TMGMTLocalTaskItem in Translation Management Tool 7
Entity class for the local task item entity.
Hierarchy
- class \Entity implements EntityInterface
- class \TMGMTLocalTaskItem
Expanded class hierarchy of TMGMTLocalTaskItem
Related topics
1 string reference to 'TMGMTLocalTaskItem'
- tmgmt_local_entity_info in translators/
tmgmt_local/ tmgmt_local.module - Implements hook_entity_info().
File
- translators/
tmgmt_local/ entity/ tmgmt_local.entity.task_item.inc, line 13
View source
class TMGMTLocalTaskItem extends Entity {
/**
* Translation local task item identifier.
*
* @var int
*/
public $tltiid;
/**
* The task identifier.
*
* @var int
*/
public $tltid;
/**
* Translation job item.
*
* @var int
*/
public $tjiid;
/**
* Current status of the task.
*
* @var int
*/
public $status;
/**
* Translated data and data item status.
*
* @var array
*/
public $data = array();
/**
* Counter for all untranslated data items.
*
* @var integer
*/
public $count_untranslated = 0;
/**
* Counter for all translated data items.
*
* @var integer
*/
public $count_translated = 0;
/**
* Counter for all completed data items.
*
* @var integer
*/
public $count_completed = 0;
/**
* {@inheritdoc}
*/
public function __construct(array $values = array(), $entity_type = 'tmgmt_local_task_item') {
parent::__construct($values, $entity_type);
}
/*
* {@inheritdoc}
*/
public function defaultUri() {
return array(
'path' => 'translate/' . $this->tltid . '/item/' . $this->tltiid,
);
}
/**
* {@inheritdoc}
*/
protected function defaultLabel() {
if ($job_item = $this
->getJobItem()) {
return $job_item
->label();
}
return t('Missing job item');
}
/**
* Returns the translation task.
*
* @return TMGMTLocalTask
*/
public function getTask() {
return entity_load_single('tmgmt_local_task', $this->tltid);
}
/**
* Returns the translation job item.
*
* @return TMGMTJobItem
*/
public function getJobItem() {
return entity_load_single('tmgmt_job_item', $this->tjiid);
}
/**
* {@inheritdoc}
*/
public function buildContent($view_mode = 'full', $langcode = NULL) {
$content = drupal_get_form('tmgmt_local_translation_form', $this);
return entity_get_controller($this->entityType)
->buildContent($this, $view_mode, $langcode, $content);
}
/**
* Returns TRUE if the local task is pending.
*
* @return bool
* TRUE if the local task item is untranslated.
*/
public function isPending() {
return $this->status == TMGMT_LOCAL_TASK_ITEM_STATUS_PENDING;
}
/**
* Returns TRUE if the local task is translated (fully translated).
*
* @return bool
* TRUE if the local task item is translated.
*/
public function isCompleted() {
return $this->status == TMGMT_LOCAL_TASK_ITEM_STATUS_COMPLETED;
}
/**
* Rreturns TRUE if the local task is closed (translated and accepted).
*
* @return bool
* TRUE if the local task item is translated and accepted.
*/
public function isClosed() {
return $this->status == TMGMT_LOCAL_TASK_ITEM_STATUS_CLOSED;
}
/**
* Sets the task item status to completed.
*/
public function completed() {
$this->status = TMGMT_LOCAL_TASK_ITEM_STATUS_COMPLETED;
}
/**
* Sets the task item status to closed.
*/
public function closed() {
$this->status = TMGMT_LOCAL_TASK_ITEM_STATUS_CLOSED;
}
/**
* Updates the values for a specific substructure in the data array.
*
* The values are either set or updated but never deleted.
*
* @param $key
* Key pointing to the item the values should be applied.
* The key can be either be an array containing the keys of a nested array
* hierarchy path or a string with '][' or '|' as delimiter.
* @param $values
* Nested array of values to set.
*/
public function updateData($key, $values = array()) {
foreach ($values as $index => $value) {
// In order to preserve existing values, we can not aplly the values array
// at once. We need to apply each containing value on its own.
// If $value is an array we need to advance the hierarchy level.
if (is_array($value)) {
$this
->updateData(array_merge(tmgmt_ensure_keys_array($key), array(
$index,
)), $value);
}
else {
drupal_array_set_nested_value($this->data, array_merge(tmgmt_ensure_keys_array($key), array(
$index,
)), $value);
}
}
}
/**
* Array of translations.
*
* The structure is similar to the form API in the way that it is a possibly
* nested array with the following properties whose presence indicate that the
* current element is a text that might need to be translated.
*
* - #text: The translated text of the corresponding entry in the job item.
* - #status: The status of the translation.
*
* The key can be an alphanumeric string.
*
* @param array $key
* If present, only the subarray identified by key is returned.
* @param string $index
* Optional index of an attribute below $key.
*
* @return array
* A structured data array.
*/
public function getData(array $key = array(), $index = NULL) {
if (empty($key)) {
return $this->data;
}
if ($index) {
$key = array_merge($key, array(
$index,
));
}
return drupal_array_get_nested_value($this->data, $key);
}
/**
* Count of all translated data items.
*
* @return
* Translated count
*/
public function getCountTranslated() {
return $this->count_translated;
}
/**
* Count of all untranslated data items.
*
* @return
* Translated count
*/
public function getCountUntranslated() {
return $this->count_untranslated;
}
/**
* Count of all completed data items.
*
* @return
* Translated count
*/
public function getCountCompleted() {
return $this->count_completed;
}
}
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:: |
public | function |
Permanently saves 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. | |
TMGMTLocalTaskItem:: |
public | property | Counter for all completed data items. | |
TMGMTLocalTaskItem:: |
public | property | Counter for all translated data items. | |
TMGMTLocalTaskItem:: |
public | property | Counter for all untranslated data items. | |
TMGMTLocalTaskItem:: |
public | property | Translated data and data item status. | |
TMGMTLocalTaskItem:: |
public | property | Current status of the task. | |
TMGMTLocalTaskItem:: |
public | property | Translation job item. | |
TMGMTLocalTaskItem:: |
public | property | The task identifier. | |
TMGMTLocalTaskItem:: |
public | property | Translation local task item identifier. | |
TMGMTLocalTaskItem:: |
public | function |
Builds a structured array representing the entity's content. Overrides Entity:: |
|
TMGMTLocalTaskItem:: |
public | function | Sets the task item status to closed. | |
TMGMTLocalTaskItem:: |
public | function | Sets the task item status to completed. | |
TMGMTLocalTaskItem:: |
protected | function |
Defines the entity label if the 'entity_class_label' callback is used. Overrides Entity:: |
|
TMGMTLocalTaskItem:: |
public | function |
Override this in order to implement a custom default URI and specify
'entity_class_uri' as 'uri callback' hook_entity_info(). Overrides Entity:: |
|
TMGMTLocalTaskItem:: |
public | function | Count of all completed data items. | |
TMGMTLocalTaskItem:: |
public | function | Count of all translated data items. | |
TMGMTLocalTaskItem:: |
public | function | Count of all untranslated data items. | |
TMGMTLocalTaskItem:: |
public | function | Array of translations. | |
TMGMTLocalTaskItem:: |
public | function | Returns the translation job item. | |
TMGMTLocalTaskItem:: |
public | function | Returns the translation task. | |
TMGMTLocalTaskItem:: |
public | function | Rreturns TRUE if the local task is closed (translated and accepted). | |
TMGMTLocalTaskItem:: |
public | function | Returns TRUE if the local task is translated (fully translated). | |
TMGMTLocalTaskItem:: |
public | function | Returns TRUE if the local task is pending. | |
TMGMTLocalTaskItem:: |
public | function | Updates the values for a specific substructure in the data array. | |
TMGMTLocalTaskItem:: |
public | function |
Overrides Entity:: |