|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * Copyright 2011 Facebook, Inc. |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +/** |
| 20 | + * @group conduit |
| 21 | + */ |
| 22 | +class ConduitAPI_arcanist_projectinfo_Method |
| 23 | + extends ConduitAPI_arcanist_Method { |
| 24 | + |
| 25 | + public function getMethodDescription() { |
| 26 | + return "Get information about Arcanist projects."; |
| 27 | + } |
| 28 | + |
| 29 | + public function defineParamTypes() { |
| 30 | + return array( |
| 31 | + 'name' => 'required string', |
| 32 | + ); |
| 33 | + } |
| 34 | + |
| 35 | + public function defineReturnType() { |
| 36 | + return 'nonempty dict'; |
| 37 | + } |
| 38 | + |
| 39 | + public function defineErrorTypes() { |
| 40 | + return array( |
| 41 | + 'ERR-BAD-ARCANIST-PROJECT' => 'No such project exists.', |
| 42 | + ); |
| 43 | + } |
| 44 | + |
| 45 | + protected function execute(ConduitAPIRequest $request) { |
| 46 | + $name = $request->getValue('name'); |
| 47 | + |
| 48 | + $project = id(new PhabricatorRepositoryArcanistProject())->loadOneWhere( |
| 49 | + 'name = %s', |
| 50 | + $name); |
| 51 | + |
| 52 | + if (!$project) { |
| 53 | + throw new ConduitException('ERR-BAD-ARCANIST-PROJECT'); |
| 54 | + } |
| 55 | + |
| 56 | + $repository = $project->loadRepository(); |
| 57 | + |
| 58 | + $repository_phid = null; |
| 59 | + $tracked = false; |
| 60 | + if ($repository) { |
| 61 | + $repository_phid = $repository->getPHID(); |
| 62 | + $tracked = $repository->isTracked(); |
| 63 | + } |
| 64 | + |
| 65 | + return array( |
| 66 | + 'name' => $project->getName(), |
| 67 | + 'phid' => $project->getPHID(), |
| 68 | + 'repositoryPHID' => $repository_phid, |
| 69 | + 'tracked' => $tracked, |
| 70 | + ); |
| 71 | + } |
| 72 | + |
| 73 | +} |
0 commit comments