mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 05:20:56 +01:00
Conduit: user.find
This commit is contained in:
parent
9f026d7892
commit
2bea542920
10 changed files with 155 additions and 33 deletions
|
@ -20,6 +20,7 @@ phutil_register_library_map(array(
|
||||||
'AphrontFileResponse' => 'aphront/response/file',
|
'AphrontFileResponse' => 'aphront/response/file',
|
||||||
'AphrontFormControl' => 'view/form/control/base',
|
'AphrontFormControl' => 'view/form/control/base',
|
||||||
'AphrontFormFileControl' => 'view/form/control/file',
|
'AphrontFormFileControl' => 'view/form/control/file',
|
||||||
|
'AphrontFormMarkupControl' => 'view/form/control/markup',
|
||||||
'AphrontFormSelectControl' => 'view/form/control/select',
|
'AphrontFormSelectControl' => 'view/form/control/select',
|
||||||
'AphrontFormStaticControl' => 'view/form/control/static',
|
'AphrontFormStaticControl' => 'view/form/control/static',
|
||||||
'AphrontFormSubmitControl' => 'view/form/control/submit',
|
'AphrontFormSubmitControl' => 'view/form/control/submit',
|
||||||
|
@ -50,6 +51,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitAPI_conduit_connect_Method' => 'applications/conduit/method/conduit/connect',
|
'ConduitAPI_conduit_connect_Method' => 'applications/conduit/method/conduit/connect',
|
||||||
'ConduitAPI_differential_creatediff_Method' => 'applications/conduit/method/differential/creatediff',
|
'ConduitAPI_differential_creatediff_Method' => 'applications/conduit/method/differential/creatediff',
|
||||||
'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/upload',
|
'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/upload',
|
||||||
|
'ConduitAPI_user_find_Method' => 'applications/conduit/method/user/find',
|
||||||
'ConduitException' => 'applications/conduit/protocol/exception',
|
'ConduitException' => 'applications/conduit/protocol/exception',
|
||||||
'DifferentialAction' => 'applications/differential/constants/action',
|
'DifferentialAction' => 'applications/differential/constants/action',
|
||||||
'DifferentialChangeType' => 'applications/differential/constants/changetype',
|
'DifferentialChangeType' => 'applications/differential/constants/changetype',
|
||||||
|
@ -129,6 +131,7 @@ phutil_register_library_map(array(
|
||||||
'AphrontFileResponse' => 'AphrontResponse',
|
'AphrontFileResponse' => 'AphrontResponse',
|
||||||
'AphrontFormControl' => 'AphrontView',
|
'AphrontFormControl' => 'AphrontView',
|
||||||
'AphrontFormFileControl' => 'AphrontFormControl',
|
'AphrontFormFileControl' => 'AphrontFormControl',
|
||||||
|
'AphrontFormMarkupControl' => 'AphrontFormControl',
|
||||||
'AphrontFormSelectControl' => 'AphrontFormControl',
|
'AphrontFormSelectControl' => 'AphrontFormControl',
|
||||||
'AphrontFormStaticControl' => 'AphrontFormControl',
|
'AphrontFormStaticControl' => 'AphrontFormControl',
|
||||||
'AphrontFormSubmitControl' => 'AphrontFormControl',
|
'AphrontFormSubmitControl' => 'AphrontFormControl',
|
||||||
|
@ -152,6 +155,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitAPI_conduit_connect_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_conduit_connect_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_differential_creatediff_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_differential_creatediff_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod',
|
||||||
|
'ConduitAPI_user_find_Method' => 'ConduitAPIMethod',
|
||||||
'DifferentialChangeset' => 'DifferentialDAO',
|
'DifferentialChangeset' => 'DifferentialDAO',
|
||||||
'DifferentialDAO' => 'PhabricatorLiskDAO',
|
'DifferentialDAO' => 'PhabricatorLiskDAO',
|
||||||
'DifferentialDiff' => 'DifferentialDAO',
|
'DifferentialDiff' => 'DifferentialDAO',
|
||||||
|
|
|
@ -59,15 +59,13 @@ class PhabricatorConduitConsoleController
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormStaticControl())
|
id(new AphrontFormStaticControl())
|
||||||
->setLabel('Description')
|
->setLabel('Description')
|
||||||
->setValue(
|
->setValue($method_object->getMethodDescription()))
|
||||||
phutil_escape_html($method_object->getMethodDescription())))
|
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormStaticControl())
|
id(new AphrontFormStaticControl())
|
||||||
->setLabel('Returns')
|
->setLabel('Returns')
|
||||||
->setValue(
|
->setValue($method_object->defineReturnType()))
|
||||||
phutil_escape_html($method_object->defineReturnType())))
|
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormStaticControl())
|
id(new AphrontFormMarkupControl())
|
||||||
->setLabel('Errors')
|
->setLabel('Errors')
|
||||||
->setValue($error_description))
|
->setValue($error_description))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ConduitAPI_user_find_Method extends ConduitAPIMethod {
|
||||||
|
|
||||||
|
public function getMethodDescription() {
|
||||||
|
return "Find user PHIDs which correspond to provided user aliases. ".
|
||||||
|
"Returns NULL for aliases which do have any corresponding PHIDs.";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defineParamTypes() {
|
||||||
|
return array(
|
||||||
|
'aliases' => 'required nonempty list<string>'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defineReturnType() {
|
||||||
|
return 'nonempty dict<string, phid>';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defineErrorTypes() {
|
||||||
|
return array(
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(ConduitAPIRequest $request) {
|
||||||
|
$users = id(new PhabricatorUser())->loadAllWhere(
|
||||||
|
'username in (%Ls)',
|
||||||
|
$request->getValue('aliases'));
|
||||||
|
|
||||||
|
return mpull($users, 'getPHID', 'getUsername');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
15
src/applications/conduit/method/user/find/__init__.php
Normal file
15
src/applications/conduit/method/user/find/__init__.php
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/conduit/method/base');
|
||||||
|
phutil_require_module('phabricator', 'applications/people/storage/user');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('ConduitAPI_user_find_Method.php');
|
|
@ -30,6 +30,8 @@ class DifferentialChangeset extends DifferentialDAO {
|
||||||
protected $addLines;
|
protected $addLines;
|
||||||
protected $delLines;
|
protected $delLines;
|
||||||
|
|
||||||
|
private $unsavedHunks = array();
|
||||||
|
|
||||||
protected function getConfiguration() {
|
protected function getConfiguration() {
|
||||||
return array(
|
return array(
|
||||||
self::CONFIG_SERIALIZATION => array(
|
self::CONFIG_SERIALIZATION => array(
|
||||||
|
@ -60,27 +62,11 @@ class DifferentialChangeset extends DifferentialDAO {
|
||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addHunk(DifferentialHunk $hunk) {
|
public function addUnsavedHunk(DifferentialHunk $hunk) {
|
||||||
if (!isset($this->_hunks)) {
|
$this->unsavedHunks[] = $hunk;
|
||||||
$this->_hunks = array();
|
|
||||||
}
|
|
||||||
$this->_hunks[] = $hunk;
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function attachHunks(array $hunks) {
|
|
||||||
$this->_hunks = $hunks;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHunks() {
|
|
||||||
if (!isset($this->_hunks)) {
|
|
||||||
throw new Exception("You must load hunks before accessing them.");
|
|
||||||
}
|
|
||||||
return $this->_hunks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function loadHunks() {
|
public function loadHunks() {
|
||||||
if (!$this->getID()) {
|
if (!$this->getID()) {
|
||||||
return array();
|
return array();
|
||||||
|
@ -90,15 +76,26 @@ class DifferentialChangeset extends DifferentialDAO {
|
||||||
$this->getID());
|
$this->getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function save() {
|
||||||
|
// TODO: Sort out transactions
|
||||||
|
// $this->openTransaction();
|
||||||
|
$ret = parent::save();
|
||||||
|
foreach ($this->unsavedHunks as $hunk) {
|
||||||
|
$hunk->setChangesetID($this->getID());
|
||||||
|
$hunk->save();
|
||||||
|
}
|
||||||
|
// $this->saveTransaction();
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
$this->openTransaction();
|
// $this->openTransaction();
|
||||||
foreach ($this->loadHunks() as $hunk) {
|
foreach ($this->loadHunks() as $hunk) {
|
||||||
$hunk->delete();
|
$hunk->delete();
|
||||||
}
|
}
|
||||||
$this->_hunks = array();
|
$this->_hunks = array();
|
||||||
$ret = parent::delete();
|
$ret = parent::delete();
|
||||||
$this->saveTransaction();
|
// $this->saveTransaction();
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,13 @@ class DifferentialDiff extends DifferentialDAO {
|
||||||
protected $arcanistProject;
|
protected $arcanistProject;
|
||||||
protected $creationMethod;
|
protected $creationMethod;
|
||||||
|
|
||||||
|
private $unsavedChangesets = array();
|
||||||
|
|
||||||
|
public function addUnsavedChangeset(DifferentialChangeset $changeset) {
|
||||||
|
$this->unsavedChangesets[] = $changeset;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function loadChangesets() {
|
public function loadChangesets() {
|
||||||
if (!$this->getID()) {
|
if (!$this->getID()) {
|
||||||
return array();
|
return array();
|
||||||
|
@ -48,13 +55,25 @@ class DifferentialDiff extends DifferentialDAO {
|
||||||
$this->getID());
|
$this->getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function save() {
|
||||||
|
// TODO: sort out transactions
|
||||||
|
// $this->openTransaction();
|
||||||
|
$ret = parent::save();
|
||||||
|
foreach ($this->unsavedChangesets as $changeset) {
|
||||||
|
// $changeset->setDiffID($this->getID());
|
||||||
|
// $changeset->save();
|
||||||
|
}
|
||||||
|
// $this->saveTransaction();
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
$this->openTransaction();
|
// $this->openTransaction();
|
||||||
foreach ($this->loadChangesets() as $changeset) {
|
foreach ($this->loadChangesets() as $changeset) {
|
||||||
$changeset->delete();
|
$changeset->delete();
|
||||||
}
|
}
|
||||||
$ret = parent::delete();
|
$ret = parent::delete();
|
||||||
$this->saveTransaction();
|
// $this->saveTransaction();
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,21 +86,19 @@ class DifferentialDiff extends DifferentialDAO {
|
||||||
$add_lines = 0;
|
$add_lines = 0;
|
||||||
$del_lines = 0;
|
$del_lines = 0;
|
||||||
foreach ($change->getHunks() as $hunk) {
|
foreach ($change->getHunks() as $hunk) {
|
||||||
$dhunk = new Hunk();
|
$dhunk = new DifferentialHunk();
|
||||||
$dhunk->setOldOffset($hunk->getOldOffset());
|
$dhunk->setOldOffset($hunk->getOldOffset());
|
||||||
$dhunk->setOldLen($hunk->getOldLength());
|
$dhunk->setOldLen($hunk->getOldLength());
|
||||||
$dhunk->setNewOffset($hunk->getNewOffset());
|
$dhunk->setNewOffset($hunk->getNewOffset());
|
||||||
$dhunk->setNewLen($hunk->getNewLength());
|
$dhunk->setNewLen($hunk->getNewLength());
|
||||||
$dhunk->setChanges($hunk->getCorpus());
|
$dhunk->setChanges($hunk->getCorpus());
|
||||||
$changeset->addHunk($dhunk);
|
$changeset->addUnsavedHunk($dhunk);
|
||||||
$add_lines += $hunk->getAddLines();
|
$add_lines += $hunk->getAddLines();
|
||||||
$del_lines += $hunk->getDelLines();
|
$del_lines += $hunk->getDelLines();
|
||||||
$lines += $add_lines + $del_lines;
|
$lines += $add_lines + $del_lines;
|
||||||
}
|
}
|
||||||
$changeset->setHunkCount(count($change->getHunks()));
|
|
||||||
|
|
||||||
$changeset->setOldFile($change->getOldPath());
|
$changeset->setOldFile($change->getOldPath());
|
||||||
$changeset->setNewFile($change->getCurrentPath());
|
|
||||||
$changeset->setFilename($change->getCurrentPath());
|
$changeset->setFilename($change->getCurrentPath());
|
||||||
$changeset->setChangeType($change->getType());
|
$changeset->setChangeType($change->getType());
|
||||||
|
|
||||||
|
@ -93,7 +110,7 @@ class DifferentialDiff extends DifferentialDAO {
|
||||||
$changeset->setAddLines($add_lines);
|
$changeset->setAddLines($add_lines);
|
||||||
$changeset->setDelLines($del_lines);
|
$changeset->setDelLines($del_lines);
|
||||||
|
|
||||||
$diff->addChangeset($changeset);
|
$diff->addUnsavedChangeset($changeset);
|
||||||
}
|
}
|
||||||
$diff->setLineCount($lines);
|
$diff->setLineCount($lines);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'applications/differential/storage/base');
|
phutil_require_module('phabricator', 'applications/differential/storage/base');
|
||||||
phutil_require_module('phabricator', 'applications/differential/storage/changeset');
|
phutil_require_module('phabricator', 'applications/differential/storage/changeset');
|
||||||
|
phutil_require_module('phabricator', 'applications/differential/storage/hunk');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'utils');
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
|
@ -534,7 +534,7 @@ abstract class LiskDAO {
|
||||||
if (!isset($properties)) {
|
if (!isset($properties)) {
|
||||||
$class = new ReflectionClass(get_class($this));
|
$class = new ReflectionClass(get_class($this));
|
||||||
$properties = array();
|
$properties = array();
|
||||||
foreach ($class->getProperties() as $p) {
|
foreach ($class->getProperties(ReflectionProperty::IS_PROTECTED) as $p) {
|
||||||
$properties[strtolower($p->getName())] = $p->getName();
|
$properties[strtolower($p->getName())] = $p->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
29
src/view/form/control/markup/AphrontFormMarkupControl.php
Executable file
29
src/view/form/control/markup/AphrontFormMarkupControl.php
Executable file
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class AphrontFormMarkupControl extends AphrontFormControl {
|
||||||
|
|
||||||
|
protected function getCustomControlClass() {
|
||||||
|
return 'aphront-form-control-markup';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function renderInput() {
|
||||||
|
return $this->getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
12
src/view/form/control/markup/__init__.php
Normal file
12
src/view/form/control/markup/__init__.php
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'view/form/control/base');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('AphrontFormMarkupControl.php');
|
Loading…
Reference in a new issue