3 final class PhabricatorPhurlURLLongURLTransaction
4 extends PhabricatorPhurlURLTransactionType
{
6 const TRANSACTIONTYPE
= 'phurl.longurl';
8 public function generateOldValue($object) {
9 return $object->getLongURL();
12 public function applyInternalEffects($object, $value) {
13 $object->setLongURL($value);
16 public function getTitle() {
18 '%s changed the destination URL from %s to %s.',
19 $this->renderAuthor(),
20 $this->renderOldValue(),
21 $this->renderNewValue());
24 public function getTitleForFeed() {
26 '%s changed the destination URL %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->getLongURL(), $xactions)) {
37 $errors[] = $this->newRequiredError(
38 pht('URL path is required'));
41 foreach ($xactions as $xaction) {
42 if ($xaction->getOldValue() != $xaction->getNewValue()) {
43 $protocols = PhabricatorEnv
::getEnvConfig('uri.allowed-protocols');
44 $uri = new PhutilURI($xaction->getNewValue());
45 if (!isset($protocols[$uri->getProtocol()])) {
46 $errors[] = $this->newRequiredError(
47 pht('The protocol of the URL is invalid.'));
55 public function getIcon() {
56 return 'fa-external-link-square';