1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-25 14:08:19 +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( $log = PhabricatorUserLog::newLog(
$this->getActor(), $this->requireActor(),
$user, $user,
PhabricatorUserLog::ACTION_CREATE); PhabricatorUserLog::ACTION_CREATE);
$log->setNewValue($email->getAddress()); $log->setNewValue($email->getAddress());
@ -97,7 +97,6 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
throw new Exception("User has not been created yet!"); throw new Exception("User has not been created yet!");
} }
$actor = $this->requireActor();
$user->openTransaction(); $user->openTransaction();
$user->save(); $user->save();
if ($email) { if ($email) {
@ -105,7 +104,7 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
} }
$log = PhabricatorUserLog::newLog( $log = PhabricatorUserLog::newLog(
$actor, $this->requireActor(),
$user, $user,
PhabricatorUserLog::ACTION_EDIT); PhabricatorUserLog::ACTION_EDIT);
$log->save(); $log->save();
@ -134,7 +133,7 @@ final class PhabricatorUserEditor extends PhabricatorEditor {
$user->save(); $user->save();
$log = PhabricatorUserLog::newLog( $log = PhabricatorUserLog::newLog(
$this->getActor(), $this->requireActor(),
$user, $user,
PhabricatorUserLog::ACTION_CHANGE_PASSWORD); PhabricatorUserLog::ACTION_CHANGE_PASSWORD);
$log->save(); $log->save();

View file

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