Path: blob/master/src/applications/owners/xaction/PhabricatorOwnersPackageIgnoredTransaction.php
12256 views
<?php12final class PhabricatorOwnersPackageIgnoredTransaction3extends PhabricatorOwnersPackageTransactionType {45const TRANSACTIONTYPE = 'owners.ignored';67public function generateOldValue($object) {8return $object->getIgnoredPathAttributes();9}1011public function generateNewValue($object, $value) {12return array_fill_keys($value, true);13}1415public function applyInternalEffects($object, $value) {16$object->setIgnoredPathAttributes($value);17}1819public function getTitle() {20$old = array_keys($this->getOldValue());21$new = array_keys($this->getNewValue());2223$add = array_diff($new, $old);24$rem = array_diff($old, $new);2526$all_n = new PhutilNumber(count($add) + count($rem));27$add_n = phutil_count($add);28$rem_n = phutil_count($rem);2930if ($new && $old) {31return pht(32'%s changed %s ignored attribute(s), added %s: %s; removed %s: %s.',33$this->renderAuthor(),34$all_n,35$add_n,36$this->renderValueList($add),37$rem_n,38$this->renderValueList($rem));39} else if ($new) {40return pht(41'%s changed %s ignored attribute(s), added %s: %s.',42$this->renderAuthor(),43$all_n,44$add_n,45$this->rendervalueList($add));46} else {47return pht(48'%s changed %s ignored attribute(s), removed %s: %s.',49$this->renderAuthor(),50$all_n,51$rem_n,52$this->rendervalueList($rem));53}54}5556public function validateTransactions($object, array $xactions) {57$errors = array();5859$valid_attributes = array(60'generated' => true,61);6263foreach ($xactions as $xaction) {64$new = $xaction->getNewValue();6566foreach ($new as $attribute) {67if (isset($valid_attributes[$attribute])) {68continue;69}7071$errors[] = $this->newInvalidError(72pht(73'Changeset attribute "%s" is not valid. Valid changeset '.74'attributes are: %s.',75$attribute,76implode(', ', array_keys($valid_attributes))),77$xaction);78}79}8081return $errors;82}8384}858687