Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / phurl / xaction / PhabricatorPhurlURLLongURLTransaction.php
blob7a4e34516ee42d4173c1b7c661d28c1698210279
1 <?php
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() {
17 return pht(
18 '%s changed the destination URL from %s to %s.',
19 $this->renderAuthor(),
20 $this->renderOldValue(),
21 $this->renderNewValue());
24 public function getTitleForFeed() {
25 return pht(
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) {
34 $errors = array();
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.'));
52 return $errors;
55 public function getIcon() {
56 return 'fa-external-link-square';