Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/project/conduit/ProjectCreateConduitAPIMethod.php b/src/applications/project/conduit/ProjectCreateConduitAPIMethod.php
index 47be6aa3f9..a209fd9a40 100644
--- a/src/applications/project/conduit/ProjectCreateConduitAPIMethod.php
+++ b/src/applications/project/conduit/ProjectCreateConduitAPIMethod.php
@@ -1,60 +1,81 @@
<?php
final class ProjectCreateConduitAPIMethod extends ProjectConduitAPIMethod {
public function getAPIMethodName() {
return 'project.create';
}
public function getMethodDescription() {
return pht('Create a project.');
}
protected function defineParamTypes() {
return array(
'name' => 'required string',
'members' => 'optional list<phid>',
+ 'icon' => 'optional string',
+ 'color' => 'optional string',
+ 'tags' => 'optional list<string>',
);
}
protected function defineReturnType() {
return 'dict';
}
protected function execute(ConduitAPIRequest $request) {
$user = $request->getUser();
$this->requireApplicationCapability(
ProjectCreateProjectsCapability::CAPABILITY,
$user);
$project = PhabricatorProject::initializeNewProject($user);
$type_name = PhabricatorProjectTransaction::TYPE_NAME;
$members = $request->getValue('members');
$xactions = array();
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType($type_name)
->setNewValue($request->getValue('name'));
+ if ($request->getValue('icon')) {
+ $xactions[] = id(new PhabricatorProjectTransaction())
+ ->setTransactionType(PhabricatorProjectTransaction::TYPE_ICON)
+ ->setNewValue($request->getValue('icon'));
+ }
+
+ if ($request->getValue('color')) {
+ $xactions[] = id(new PhabricatorProjectTransaction())
+ ->setTransactionType(PhabricatorProjectTransaction::TYPE_COLOR)
+ ->setNewValue($request->getValue('color'));
+ }
+
+ if ($request->getValue('tags')) {
+ $xactions[] = id(new PhabricatorProjectTransaction())
+ ->setTransactionType(PhabricatorProjectTransaction::TYPE_SLUGS)
+ ->setNewValue($request->getValue('tags'));
+ }
+
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
->setMetadataValue(
'edge:type',
PhabricatorProjectProjectHasMemberEdgeType::EDGECONST)
->setNewValue(
array(
'+' => array_fuse($members),
));
$editor = id(new PhabricatorProjectTransactionEditor())
->setActor($user)
->setContinueOnNoEffect(true)
->setContentSourceFromConduitRequest($request);
$editor->applyTransactions($project, $xactions);
return $this->buildProjectInfoDictionary($project);
}
}
diff --git a/src/applications/project/conduit/ProjectQueryConduitAPIMethod.php b/src/applications/project/conduit/ProjectQueryConduitAPIMethod.php
index f65578e349..3d059d064d 100644
--- a/src/applications/project/conduit/ProjectQueryConduitAPIMethod.php
+++ b/src/applications/project/conduit/ProjectQueryConduitAPIMethod.php
@@ -1,114 +1,132 @@
<?php
final class ProjectQueryConduitAPIMethod extends ProjectConduitAPIMethod {
public function getAPIMethodName() {
return 'project.query';
}
public function getMethodDescription() {
return pht('Execute searches for Projects.');
}
protected function defineParamTypes() {
$statuses = array(
PhabricatorProjectQuery::STATUS_ANY,
PhabricatorProjectQuery::STATUS_OPEN,
PhabricatorProjectQuery::STATUS_CLOSED,
PhabricatorProjectQuery::STATUS_ACTIVE,
PhabricatorProjectQuery::STATUS_ARCHIVED,
);
$status_const = $this->formatStringConstants($statuses);
return array(
'ids' => 'optional list<int>',
'names' => 'optional list<string>',
'phids' => 'optional list<phid>',
'slugs' => 'optional list<string>',
+ 'icons' => 'optional list<string>',
+ 'colors' => 'optional list<string>',
'status' => 'optional '.$status_const,
'members' => 'optional list<phid>',
'limit' => 'optional int',
'offset' => 'optional int',
);
}
protected function defineReturnType() {
return 'list';
}
protected function execute(ConduitAPIRequest $request) {
$query = new PhabricatorProjectQuery();
$query->setViewer($request->getUser());
$query->needMembers(true);
$query->needSlugs(true);
$ids = $request->getValue('ids');
if ($ids) {
$query->withIDs($ids);
}
$names = $request->getValue('names');
if ($names) {
$query->withNames($names);
}
$status = $request->getValue('status');
if ($status) {
$query->withStatus($status);
}
$phids = $request->getValue('phids');
if ($phids) {
$query->withPHIDs($phids);
}
$slugs = $request->getValue('slugs');
if ($slugs) {
$query->withSlugs($slugs);
}
+ $request->getValue('icons');
+ if ($request->getValue('icons')) {
+ $icons = array();
+ // the internal 'fa-' prefix is a detail hidden from api clients
+ // but needs to pre prepended to the values in the icons array:
+ foreach ($request->getValue('icons') as $value) {
+ $icons[] = 'fa-'.$value;
+ }
+ $query->withIcons($icons);
+ }
+
+ $colors = $request->getValue('colors');
+ if ($colors) {
+ $query->withColors($colors);
+ }
+
$members = $request->getValue('members');
if ($members) {
$query->withMemberPHIDs($members);
}
$limit = $request->getValue('limit');
if ($limit) {
$query->setLimit($limit);
}
$offset = $request->getValue('offset');
if ($offset) {
$query->setOffset($offset);
}
$pager = $this->newPager($request);
$results = $query->executeWithCursorPager($pager);
$projects = $this->buildProjectInfoDictionaries($results);
// TODO: This is pretty hideous.
$slug_map = array();
if ($slugs) {
foreach ($slugs as $slug) {
$normal = rtrim(PhabricatorSlug::normalize($slug), '/');
foreach ($projects as $project) {
if (in_array($normal, $project['slugs'])) {
$slug_map[$slug] = $project['phid'];
}
}
}
}
$result = array(
'data' => $projects,
'slugMap' => $slug_map,
);
return $this->addPagerResults($result, $pager);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Dec 2, 11:53 AM (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
431863
Default Alt Text
(6 KB)

Event Timeline