1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-21 22:32:41 +01:00

Key Value Store for ManiphestTask

Test Plan: Look at a task detail. Some dummy attributes are automatically added in ManiphestTaskDetailController.
Reviewed By: epriestley

Differential Revision: 730
This commit is contained in:
hunterbridges 2011-07-25 17:34:56 -05:00 committed by epriestley
parent e00fae8436
commit aeae33b7d6
8 changed files with 93 additions and 1 deletions

3
.gitignore vendored
View file

@ -8,3 +8,6 @@
*#
*~
*.swp
# NetBeans project files
/nbproject/

View file

@ -0,0 +1,9 @@
create table phabricator_maniphest.maniphest_taskauxiliarystorage
(id int unsigned not null auto_increment primary key,
taskPHID varchar(64) binary not null,
name varchar(255) not null,
value varchar(255) not null,
unique key (taskPHID,name),
dateCreated int unsigned not null,
dateModified int unsigned not null)
ENGINE = InnoDB;

View file

@ -268,6 +268,7 @@ phutil_register_library_map(array(
'ManiphestDAO' => 'applications/maniphest/storage/base',
'ManiphestReplyHandler' => 'applications/maniphest/replyhandler',
'ManiphestTask' => 'applications/maniphest/storage/task',
'ManiphestTaskAuxiliaryStorage' => 'applications/maniphest/storage/auxiliary',
'ManiphestTaskDescriptionChangeController' => 'applications/maniphest/controller/descriptionchange',
'ManiphestTaskDetailController' => 'applications/maniphest/controller/taskdetail',
'ManiphestTaskEditController' => 'applications/maniphest/controller/taskedit',
@ -826,6 +827,7 @@ phutil_register_library_map(array(
'ManiphestDAO' => 'PhabricatorLiskDAO',
'ManiphestReplyHandler' => 'PhabricatorMailReplyHandler',
'ManiphestTask' => 'ManiphestDAO',
'ManiphestTaskAuxiliaryStorage' => 'ManiphestDAO',
'ManiphestTaskDescriptionChangeController' => 'ManiphestController',
'ManiphestTaskDetailController' => 'ManiphestController',
'ManiphestTaskEditController' => 'ManiphestController',

View file

@ -141,7 +141,6 @@ class ManiphestTaskDetailController extends ManiphestController {
}
}
$dict['Description'] =
'<div class="maniphest-task-description">'.
'<div class="phabricator-remarkup">'.

View file

@ -0,0 +1,28 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group maniphest
*/
class ManiphestTaskAuxiliaryStorage extends ManiphestDAO {
protected $taskPHID;
protected $name;
protected $value;
}

View file

@ -0,0 +1,12 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'applications/maniphest/storage/base');
phutil_require_source('ManiphestTaskAuxiliaryStorage.php');

View file

@ -83,6 +83,44 @@ class ManiphestTask extends ManiphestDAO {
return $this;
}
public function setAuxiliaryAttribute($key, $val) {
$this->removeAuxiliaryAttribute($key);
$attribute = new ManiphestTaskAuxiliaryStorage();
$attribute->setTaskPHID($this->phid);
$attribute->setName($key);
$attribute->setValue($val);
$attribute->save();
}
public function loadAuxiliaryAttribute($key) {
$attribute = id(new ManiphestTaskAuxiliaryStorage())->loadOneWhere(
'taskPHID = %s AND name = %s',
$this->getPHID(),
$key);
return $attribute;
}
public function removeAuxiliaryAttribute($key) {
$attribute = id(new ManiphestTaskAuxiliaryStorage())->loadOneWhere(
'taskPHID = %s AND name = %s',
$this->getPHID(),
$key);
if ($attribute) {
$attribute->delete();
}
}
public function loadAuxiliaryAttributes() {
$attributes = id(new ManiphestTaskAuxiliaryStorage())->loadAllWhere(
'taskPHID = %s',
$this->getPHID());
return $attributes;
}
public function save() {
if (!$this->mailKey) {
$this->mailKey = sha1(Filesystem::readRandomBytes(20));

View file

@ -6,6 +6,7 @@
phutil_require_module('phabricator', 'applications/maniphest/storage/auxiliary');
phutil_require_module('phabricator', 'applications/maniphest/storage/base');
phutil_require_module('phabricator', 'applications/maniphest/storage/subscriber');
phutil_require_module('phabricator', 'applications/maniphest/storage/taskproject');