Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/storage/PhabricatorProjectTrigger.php
- This file was added.
<?php | |||||
final class PhabricatorProjectTrigger | |||||
extends PhabricatorProjectDAO | |||||
implements | |||||
PhabricatorApplicationTransactionInterface, | |||||
PhabricatorPolicyInterface, | |||||
PhabricatorDestructibleInterface { | |||||
protected $name; | |||||
protected $ruleset = array(); | |||||
protected $editPolicy; | |||||
public static function initializeNewTrigger() { | |||||
$default_edit = PhabricatorPolicies::POLICY_USER; | |||||
return id(new self()) | |||||
->setName('') | |||||
->setEditPolicy($default_edit); | |||||
} | |||||
protected function getConfiguration() { | |||||
return array( | |||||
self::CONFIG_AUX_PHID => true, | |||||
self::CONFIG_SERIALIZATION => array( | |||||
'ruleset' => self::SERIALIZATION_JSON, | |||||
), | |||||
self::CONFIG_COLUMN_SCHEMA => array( | |||||
'name' => 'text255', | |||||
), | |||||
self::CONFIG_KEY_SCHEMA => array( | |||||
), | |||||
) + parent::getConfiguration(); | |||||
} | |||||
public function getPHIDType() { | |||||
return PhabricatorProjectTriggerPHIDType::TYPECONST; | |||||
} | |||||
public function getDisplayName() { | |||||
$name = $this->getName(); | |||||
if (strlen($name)) { | |||||
return $name; | |||||
} | |||||
return $this->getDefaultName(); | |||||
} | |||||
public function getDefaultName() { | |||||
return pht('Custom Trigger'); | |||||
} | |||||
public function getURI() { | |||||
return urisprintf( | |||||
'/project/trigger/%d/', | |||||
$this->getID()); | |||||
} | |||||
public function getObjectName() { | |||||
return pht('Trigger %d', $this->getID()); | |||||
} | |||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */ | |||||
public function getApplicationTransactionEditor() { | |||||
return new PhabricatorProjectTriggerEditor(); | |||||
} | |||||
public function getApplicationTransactionTemplate() { | |||||
return new PhabricatorProjectTriggerTransaction(); | |||||
} | |||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */ | |||||
public function getCapabilities() { | |||||
return array( | |||||
PhabricatorPolicyCapability::CAN_VIEW, | |||||
PhabricatorPolicyCapability::CAN_EDIT, | |||||
); | |||||
} | |||||
public function getPolicy($capability) { | |||||
switch ($capability) { | |||||
case PhabricatorPolicyCapability::CAN_VIEW: | |||||
return PhabricatorPolicies::getMostOpenPolicy(); | |||||
case PhabricatorPolicyCapability::CAN_EDIT: | |||||
return $this->getEditPolicy(); | |||||
} | |||||
} | |||||
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | |||||
return false; | |||||
} | |||||
/* -( PhabricatorDestructibleInterface )----------------------------------- */ | |||||
public function destroyObjectPermanently( | |||||
PhabricatorDestructionEngine $engine) { | |||||
$this->delete(); | |||||
} | |||||
} |