mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-03 20:22:46 +01:00
3f56ca681f
Summary: Fixes T404. Ref T2575. Allows default to be set for any field. Date defaults are interpreted by `strtotime()`. Other defaults are interpreted as expected. Test Plan: - Created a string custom field with default value "Orange". - Created a date custom field with a fixed default value (my birthday). - Created a date custom field with a relative default value ("today 4:59 PM"). - Created/edited tasks with these fields, verified everything behaved sensibly. Reviewers: hach-que, btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T404, T2575 Differential Revision: https://secure.phabricator.com/D5282
44 lines
1 KiB
PHP
44 lines
1 KiB
PHP
<?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';
|
|
return PhabricatorEnv::newObjectFromConfig($key);
|
|
}
|
|
|
|
public function loadFields(ManiphestTask $task, PhabricatorUser $viewer) {
|
|
$aux_fields = $this->getAuxiliaryFieldSpecifications();
|
|
if (!$aux_fields) {
|
|
return array();
|
|
}
|
|
|
|
$task->loadAndAttachAuxiliaryAttributes();
|
|
|
|
foreach ($aux_fields as $aux) {
|
|
$aux->setUser($viewer);
|
|
$aux->setTask($task);
|
|
|
|
// 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));
|
|
}
|
|
}
|
|
|
|
return $aux_fields;
|
|
}
|
|
|
|
}
|