1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-10 14:51:06 +01:00

Fix some Editor issues

Summary: The property is called 'actor', not 'user'. Extend from Phobject to catch this class of error automatically. Upgrade a couple of getActor() to requireActor().

Test Plan: Created new users.

Reviewers: btrahan, vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D3776
This commit is contained in:
epriestley 2012-10-22 16:25:31 -07:00
parent cef6605b75
commit c679b78270
2 changed files with 10 additions and 8 deletions

View file

@ -75,7 +75,7 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
}
$log = PhabricatorUserLog::newLog(
$this->getActor(),
$this->requireActor(),
$user,
PhabricatorUserLog::ACTION_CREATE);
$log->setNewValue($email->getAddress());
@ -97,7 +97,6 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
throw new Exception("User has not been created yet!");
}
$actor = $this->requireActor();
$user->openTransaction();
$user->save();
if ($email) {
@ -105,7 +104,7 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
}
$log = PhabricatorUserLog::newLog(
$actor,
$this->requireActor(),
$user,
PhabricatorUserLog::ACTION_EDIT);
$log->save();
@ -134,7 +133,7 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
$user->save();
$log = PhabricatorUserLog::newLog(
$this->getActor(),
$this->requireActor(),
$user,
PhabricatorUserLog::ACTION_CHANGE_PASSWORD);
$log->save();

View file

@ -16,18 +16,20 @@
* limitations under the License.
*/
abstract class PhabricatorEditor {
abstract class PhabricatorEditor extends Phobject {
private $actor;
private $excludeMailRecipientPHIDs = array();
final public function setActor(PhabricatorUser $user) {
$this->user = $user;
final public function setActor(PhabricatorUser $actor) {
$this->actor = $actor;
return $this;
}
final protected function getActor() {
return $this->user;
return $this->actor;
}
final protected function requireActor() {
$actor = $this->getActor();
if (!$actor) {
@ -40,6 +42,7 @@ abstract class PhabricatorEditor {
$this->excludeMailRecipientPHIDs = $phids;
return $this;
}
final protected function getExcludeMailRecipientPHIDs() {
return $this->excludeMailRecipientPHIDs;
}