Details
Details
- Reviewers
amckinley - Maniphest Tasks
- T13242: 2019 Week 5 Bonus Content
- Commits
- rPf7e8fa0764fe: Provide an Editor extension point for transaction validation
Used this extension to keep ducks away from projects:
<?php final class NoDucksEditorExtension extends PhabricatorEditorExtension { const EXTENSIONKEY = 'no.ducks'; public function getExtensionName() { return pht('No Ducks!'); } public function supportsObject( PhabricatorApplicationTransactionEditor $editor, PhabricatorApplicationTransactionInterface $object) { return ($object instanceof PhabricatorProject); } public function validateTransactions($object, array $xactions) { $errors = array(); $name_type = PhabricatorProjectNameTransaction::TRANSACTIONTYPE; $old_value = $object->getName(); foreach ($xactions as $xaction) { if ($xaction->getTransactionType() !== $name_type) { continue; } $new_value = $xaction->getNewValue(); if ($old_value === $new_value) { continue; } if (preg_match('/duck/i', $new_value)) { $errors[] = $this->newInvalidTransactionError( $xaction, pht('Project names must not contain the substring "duck".')); } } return $errors; } }
Diff Detail
Diff Detail
- Repository
- rP Phabricator
- Branch
- subtype2
- Lint
Lint Passed - Unit
Tests Passed - Build Status
Buildable 21708 Build 29617: Run Core Tests Build 29616: arc lint + arc unit