2011-08-05 18:44:43 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group maniphest
|
|
|
|
*/
|
|
|
|
abstract class ManiphestTaskExtensions {
|
|
|
|
|
|
|
|
final public function __construct() {
|
|
|
|
// <empty>
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract public function getAuxiliaryFieldSpecifications();
|
|
|
|
|
|
|
|
|
|
|
|
final public static function newExtensions() {
|
|
|
|
$key = 'maniphest.custom-task-extensions-class';
|
2012-03-21 22:48:58 +01:00
|
|
|
return PhabricatorEnv::newObjectFromConfig($key);
|
2011-08-05 18:44:43 +02:00
|
|
|
}
|
|
|
|
|
2013-03-08 02:22:36 +01:00
|
|
|
public function loadFields(ManiphestTask $task, PhabricatorUser $viewer) {
|
|
|
|
$aux_fields = $this->getAuxiliaryFieldSpecifications();
|
|
|
|
if (!$aux_fields) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
$task->loadAndAttachAuxiliaryAttributes();
|
2013-03-08 02:23:30 +01:00
|
|
|
|
2013-03-08 02:22:36 +01:00
|
|
|
foreach ($aux_fields as $aux) {
|
|
|
|
$aux->setUser($viewer);
|
|
|
|
$aux->setTask($task);
|
|
|
|
|
2013-03-08 02:23:30 +01:00
|
|
|
// If we're creating a new task, we don't bother loading any stored data.
|
|
|
|
// This allows any defaults configured by the Extensions object to
|
|
|
|
// survive.
|
|
|
|
if ($task->getID()) {
|
|
|
|
$key = $aux->getAuxiliaryKey();
|
|
|
|
$aux->setValueFromStorage($task->getAuxiliaryAttribute($key));
|
|
|
|
}
|
2013-03-08 02:22:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return $aux_fields;
|
|
|
|
}
|
|
|
|
|
2011-08-05 18:44:43 +02:00
|
|
|
}
|