Merge pull-request #1583

This commit is contained in:
Frederic Guillot
2015-12-30 16:43:53 +01:00
2 changed files with 27 additions and 1 deletions

View File

@@ -95,4 +95,27 @@ abstract class Metadata extends Base
return ! in_array(false, $results, true); return ! in_array(false, $results, true);
} }
/**
* Remove a metadata
*
* @access public
* @param integer $entity_id
* @param string $name
* @return bool
*/
public function remove($entity_id, $name)
{
$this->db->startTransaction();
if (! $this->db->table(static::TABLE)->eq($this->getEntityKey(), $entity_id)->eq('name', $name)->remove()) {
$this->db->cancelTransaction();
return false;
}
$this->db->closeTransaction();
return true;
}
} }

View File

@@ -7,7 +7,7 @@ Metadata are custom fields, it's a key/value table.
For example your plugin can store external information for a task or new settings for a project. For example your plugin can store external information for a task or new settings for a project.
Basically that allow you to extend the default fields without having to create new tables. Basically that allow you to extend the default fields without having to create new tables.
Attach metadata to tasks Attach metadata to tasks and remove them
------------------------ ------------------------
```php ```php
@@ -23,6 +23,9 @@ $this->taskMetadata->exists($task_id, 'my_plugin_variable');
// Create or update metadata for the task // Create or update metadata for the task
$this->taskMetadata->save($task_id, ['my_plugin_variable' => 'something']); $this->taskMetadata->save($task_id, ['my_plugin_variable' => 'something']);
// Remove a metadata from a project
$this->projectMetadata->remove($project_id, my_plugin_variable);
``` ```
Metadata types Metadata types