Path: blob/master/src/applications/dashboard/xaction/panel/PhabricatorDashboardPanelNameTransaction.php
13459 views
<?php12final class PhabricatorDashboardPanelNameTransaction3extends PhabricatorDashboardPanelTransactionType {45const TRANSACTIONTYPE = 'dashpanel:name';67public function generateOldValue($object) {8return $object->getName();9}1011public function applyInternalEffects($object, $value) {12$object->setName($value);13}1415public function getTitle() {16$old = $this->getOldValue();17$new = $this->getNewValue();1819return pht(20'%s renamed this panel from %s to %s.',21$this->renderAuthor(),22$this->renderOldValue(),23$this->renderNewValue());24}2526public function validateTransactions($object, array $xactions) {27$errors = array();2829$max_length = $object->getColumnMaximumByteLength('name');30foreach ($xactions as $xaction) {31$new = $xaction->getNewValue();32if (!strlen($new)) {33$errors[] = $this->newInvalidError(34pht('Panels must have a title.'),35$xaction);36continue;37}3839if (strlen($new) > $max_length) {40$errors[] = $this->newInvalidError(41pht(42'Panel names must not be longer than %s characters.',43$max_length));44continue;45}46}4748if (!$errors) {49if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {50$errors[] = $this->newRequiredError(51pht('Panels must have a title.'));52}53}5455return $errors;56}5758public function getTransactionTypeForConduit($xaction) {59return 'name';60}6162public function getFieldValuesForConduit($xaction, $data) {63return array(64'old' => $xaction->getOldValue(),65'new' => $xaction->getNewValue(),66);67}6869}707172