Page MenuHomePhorge

PhabricatorUnlockEngine.php
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

PhabricatorUnlockEngine.php

<?php
abstract class PhabricatorUnlockEngine
extends Phobject {
final public static function newUnlockEngineForObject($object) {
if (!($object instanceof PhabricatorApplicationTransactionInterface)) {
throw new Exception(
pht(
'Object ("%s") does not implement interface "%s", so this type '.
'of object can not be unlocked.',
phutil_describe_type($object),
'PhabricatorApplicationTransactionInterface'));
}
return new PhabricatorDefaultUnlockEngine();
}
public function newUnlockViewTransactions($object, $user) {
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
if (!$this->canApplyTransactionType($object, $type_view)) {
throw new Exception(
pht(
'Object view policy can not be unlocked because this object '.
'does not have a mutable view policy.'));
}
return array(
$this->newTransaction($object)
->setTransactionType($type_view)
->setNewValue($user->getPHID()),
);
}
public function newUnlockEditTransactions($object, $user) {
$type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY;
if (!$this->canApplyTransactionType($object, $type_edit)) {
throw new Exception(
pht(
'Object edit policy can not be unlocked because this object '.
'does not have a mutable edit policy.'));
}
return array(
$this->newTransaction($object)
->setTransactionType($type_edit)
->setNewValue($user->getPHID()),
);
}
public function newUnlockOwnerTransactions($object, $user) {
throw new Exception(
pht(
'Object owner can not be unlocked: the unlocking engine ("%s") for '.
'this object does not implement an owner unlocking mechanism.',
get_class($this)));
}
final protected function canApplyTransactionType($object, $type) {
$xaction_types = $object->getApplicationTransactionEditor()
->getTransactionTypesForObject($object);
$xaction_types = array_fuse($xaction_types);
return isset($xaction_types[$type]);
}
final protected function newTransaction($object) {
return $object->getApplicationTransactionTemplate();
}
}

File Metadata

Mime Type
text/x-php
Expires
Mon, May 12, 1:09 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
122644
Default Alt Text
PhabricatorUnlockEngine.php (2 KB)

Event Timeline