Differential D21540 Diff 51273 src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Show First 20 Lines • Show All 1,383 Lines • ▼ Show 20 Lines | final public function applyTransactions( | ||||
$this->publishableTransactions = $xactions; | $this->publishableTransactions = $xactions; | ||||
if (!$this->parentEditor) { | if (!$this->parentEditor) { | ||||
$this->queuePublishing(); | $this->queuePublishing(); | ||||
} | } | ||||
return $xactions; | return $xactions; | ||||
} | } | ||||
final private function queuePublishing() { | private function queuePublishing() { | ||||
$object = $this->publishableObject; | $object = $this->publishableObject; | ||||
$xactions = $this->publishableTransactions; | $xactions = $this->publishableTransactions; | ||||
if (!$object) { | if (!$object) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Editor method "queuePublishing()" was called, but no publishable '. | 'Editor method "queuePublishing()" was called, but no publishable '. | ||||
'object is present. This Editor is not ready to publish.')); | 'object is present. This Editor is not ready to publish.')); | ||||
▲ Show 20 Lines • Show All 2,801 Lines • ▼ Show 20 Lines | /* -( Workers )------------------------------------------------------------ */ | ||||
* Convert the editor state to a serializable dictionary which can be passed | * Convert the editor state to a serializable dictionary which can be passed | ||||
* to a worker. | * to a worker. | ||||
* | * | ||||
* This data will be loaded with @{method:loadWorkerState} in the worker. | * This data will be loaded with @{method:loadWorkerState} in the worker. | ||||
* | * | ||||
* @return dict<string, wild> Serializable editor state. | * @return dict<string, wild> Serializable editor state. | ||||
* @task workers | * @task workers | ||||
*/ | */ | ||||
final private function getWorkerState() { | private function getWorkerState() { | ||||
$state = array(); | $state = array(); | ||||
foreach ($this->getAutomaticStateProperties() as $property) { | foreach ($this->getAutomaticStateProperties() as $property) { | ||||
$state[$property] = $this->$property; | $state[$property] = $this->$property; | ||||
} | } | ||||
$custom_state = $this->getCustomWorkerState(); | $custom_state = $this->getCustomWorkerState(); | ||||
$custom_encoding = $this->getCustomWorkerStateEncoding(); | $custom_encoding = $this->getCustomWorkerStateEncoding(); | ||||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | /* -( Workers )------------------------------------------------------------ */ | ||||
* | * | ||||
* See @{method:getCustomWorkerStateEncoding}. | * See @{method:getCustomWorkerStateEncoding}. | ||||
* | * | ||||
* @param map<string, wild> Map of values to encode. | * @param map<string, wild> Map of values to encode. | ||||
* @param map<string, string> Map of encodings to apply. | * @param map<string, string> Map of encodings to apply. | ||||
* @return map<string, wild> Map of encoded values. | * @return map<string, wild> Map of encoded values. | ||||
* @task workers | * @task workers | ||||
*/ | */ | ||||
final private function encodeStateForStorage( | private function encodeStateForStorage( | ||||
array $state, | array $state, | ||||
array $encodings) { | array $encodings) { | ||||
foreach ($state as $key => $value) { | foreach ($state as $key => $value) { | ||||
$encoding = idx($encodings, $key); | $encoding = idx($encodings, $key); | ||||
switch ($encoding) { | switch ($encoding) { | ||||
case self::STORAGE_ENCODING_BINARY: | case self::STORAGE_ENCODING_BINARY: | ||||
// The mechanics of this encoding (serialize + base64) are a little | // The mechanics of this encoding (serialize + base64) are a little | ||||
Show All 29 Lines | /* -( Workers )------------------------------------------------------------ */ | ||||
* | * | ||||
* See @{method:getCustomWorkerStateEncoding}. | * See @{method:getCustomWorkerStateEncoding}. | ||||
* | * | ||||
* @param map<string, wild> Map of encoded values. | * @param map<string, wild> Map of encoded values. | ||||
* @param map<string, string> Map of encodings. | * @param map<string, string> Map of encodings. | ||||
* @return map<string, wild> Map of decoded values. | * @return map<string, wild> Map of decoded values. | ||||
* @task workers | * @task workers | ||||
*/ | */ | ||||
final private function decodeStateFromStorage( | private function decodeStateFromStorage( | ||||
array $state, | array $state, | ||||
array $encodings) { | array $encodings) { | ||||
foreach ($state as $key => $value) { | foreach ($state as $key => $value) { | ||||
$encoding = idx($encodings, $key); | $encoding = idx($encodings, $key); | ||||
switch ($encoding) { | switch ($encoding) { | ||||
case self::STORAGE_ENCODING_BINARY: | case self::STORAGE_ENCODING_BINARY: | ||||
$value = base64_decode($value); | $value = base64_decode($value); | ||||
▲ Show 20 Lines • Show All 1,025 Lines • Show Last 20 Lines |