3 final class PhabricatorPhurlURLAliasTransaction
4 extends PhabricatorPhurlURLTransactionType
{
6 const TRANSACTIONTYPE
= 'phurl.alias';
8 public function generateOldValue($object) {
9 return $object->getAlias();
12 public function applyInternalEffects($object, $value) {
13 $object->setAlias($value);
16 public function getTitle() {
18 '%s changed the alias from %s to %s.',
19 $this->renderAuthor(),
20 $this->renderOldValue(),
21 $this->renderNewValue());
24 public function getTitleForFeed() {
26 '%s changed the alias of %s from %s to %s.',
27 $this->renderAuthor(),
28 $this->renderObject(),
29 $this->renderOldValue(),
30 $this->renderNewValue());
33 public function validateTransactions($object, array $xactions) {
36 if ($this->isEmptyTextTransaction($object->getAlias(), $xactions)) {
37 $errors[] = $this->newRequiredError(
38 pht('Phurls must have an alias.'));
41 $max_length = $object->getColumnMaximumByteLength('alias');
42 foreach ($xactions as $xaction) {
43 $new_alias = $xaction->getNewValue();
46 $new_length = strlen($new_alias);
47 if ($new_length > $max_length) {
48 $errors[] = $this->newRequiredError(
49 pht('The alias can be no longer than %d characters.', $max_length));
53 if ($xaction->getOldValue() != $xaction->getNewValue()) {
54 $debug_alias = new PHUIInvisibleCharacterView($new_alias);
55 if (!preg_match('/[a-zA-Z]/', $new_alias)) {
56 $errors[] = $this->newRequiredError(
57 pht('The alias you provided (%s) must contain at least one '.
61 if (preg_match('/[^a-z0-9]/i', $new_alias)) {
62 $errors[] = $this->newRequiredError(
63 pht('The alias you provided (%s) may only contain letters and '.
73 public function getIcon() {