Path: blob/master/src/applications/diffusion/conduit/DiffusionGetLintMessagesConduitAPIMethod.php
12242 views
<?php12final class DiffusionGetLintMessagesConduitAPIMethod3extends DiffusionConduitAPIMethod {45public function getAPIMethodName() {6return 'diffusion.getlintmessages';7}89public function getMethodStatus() {10return self::METHOD_STATUS_UNSTABLE;11}1213public function getMethodDescription() {14return pht('Get lint messages for existing code.');15}1617protected function defineParamTypes() {18return array(19'repositoryPHID' => 'required phid',20'branch' => 'required string',21'commit' => 'optional string',22'files' => 'required list<string>',23);24}2526protected function defineReturnType() {27return 'list<dict>';28}2930protected function execute(ConduitAPIRequest $request) {31$viewer = $request->getUser();3233$repository_phid = $request->getValue('repositoryPHID');34$repository = id(new PhabricatorRepositoryQuery())35->setViewer($viewer)36->withPHIDs(array($repository_phid))37->executeOne();3839if (!$repository) {40throw new Exception(41pht('No repository exists with PHID "%s".', $repository_phid));42}4344$branch_name = $request->getValue('branch');45if ($branch_name == '') {46$repository = id(new PhabricatorRepositoryQuery())47->setViewer($request->getUser())48->withIDs(array($repository->getID()))49->executeOne();50$branch_name = $repository->getDefaultArcanistBranch();51}5253$branch = id(new PhabricatorRepositoryBranch())->loadOneWhere(54'repositoryID = %d AND name = %s',55$repository->getID(),56$branch_name);57if (!$branch || !$branch->getLintCommit()) {58return array();59}6061$lint_messages = queryfx_all(62$branch->establishConnection('r'),63'SELECT path, line, code FROM %T WHERE branchID = %d AND path IN (%Ls)',64PhabricatorRepository::TABLE_LINTMESSAGE,65$branch->getID(),66$request->getValue('files'));6768// TODO: Compare commit identifiers of individual files like in69// DiffusionBrowseFileController::loadLintMessages().7071return $lint_messages;72}7374}757677