Changeset View
Changeset View
Standalone View
Standalone View
src/applications/packages/storage/PackagesVersion.php
- This file was added.
| <?php | |||||
| final class PackagesVersion extends PackagesDAO | |||||
| implements | |||||
| PhabricatorPolicyInterface, | |||||
| PhabricatorProjectInterface, | |||||
| PhabricatorApplicationTransactionInterface, | |||||
| PhabricatorSubscribableInterface, | |||||
| PhabricatorMentionableInterface, | |||||
| PhabricatorFlaggableInterface, | |||||
| PhabricatorDestructibleInterface { | |||||
| protected $title; | |||||
| protected $packagePHID; | |||||
| protected $properties = array(); | |||||
| protected $editPolicy; | |||||
epriestley: I think we should leave a lot more wiggle room than this: basically, have a `$properties` sort… | |||||
| protected $viewPolicy; | |||||
| private $projectPHIDs = self::ATTACHABLE; | |||||
Not Done Inline ActionsView/Edit policy here may make sense to lock to the Package policies? epriestley: View/Edit policy here may make sense to lock to the Package policies? | |||||
| public static function initializeNewVersion(PhabricatorUser $actor) { | |||||
| $app = id(new PhabricatorApplicationQuery()) | |||||
| ->setViewer($actor) | |||||
| ->withClasses(array('PhabricatorPackagesApplication')) | |||||
| ->executeOne(); | |||||
| $view_policy = $app->getPolicy(PackagesDefaultViewCapability::CAPABILITY); | |||||
| return id(new PackagesVersion()) | |||||
| ->setViewPolicy($view_policy) | |||||
| ->setEditPolicy($actor->getPHID()); | |||||
| } | |||||
| protected function getConfiguration() { | |||||
| return array( | |||||
| self::CONFIG_AUX_PHID => true, | |||||
| self::CONFIG_SERIALIZATION => array( | |||||
| 'properties' => self::SERIALIZATION_JSON, | |||||
| ), | |||||
| self::CONFIG_COLUMN_SCHEMA => array( | |||||
| 'title' => 'text255', | |||||
| ), | |||||
| self::CONFIG_KEY_SCHEMA => array( | |||||
| 'key_package' => array( | |||||
| 'columns' => array('packagePHID'), | |||||
| ), | |||||
| ), | |||||
| ) + parent::getConfiguration(); | |||||
| } | |||||
| public function generatePHID() { | |||||
| return PhabricatorPHID::generateNewPHID(PackagesVersionPHIDType::TYPECONST); | |||||
| } | |||||
| public function getProjectPHIDs() { | |||||
| return $this->assertAttached($this->projectPHIDs); | |||||
| } | |||||
| public function attachProjectPHIDs(array $phids) { | |||||
| $this->projectPHIDs = $phids; | |||||
| return $this; | |||||
| } | |||||
| public function getURI() { | |||||
| return '/packages/version/'.$this->getID(); | |||||
| } | |||||
| public function getProperty($key, $default = null) { | |||||
| return idx($this->properties, $key, $default); | |||||
| } | |||||
| public function setProperty($key, $value) { | |||||
| $this->properties[$key] = $value; | |||||
| return $this; | |||||
| } | |||||
| /* -( PhabricatorPolicyInterface )----------------------------------------- */ | |||||
| public function getCapabilities() { | |||||
| return array( | |||||
| PhabricatorPolicyCapability::CAN_VIEW, | |||||
| PhabricatorPolicyCapability::CAN_EDIT, | |||||
| ); | |||||
| } | |||||
| public function getPolicy($capability) { | |||||
| switch ($capability) { | |||||
| case PhabricatorPolicyCapability::CAN_VIEW: | |||||
| return $this->getViewPolicy(); | |||||
| case PhabricatorPolicyCapability::CAN_EDIT: | |||||
| return $this->getEditPolicy(); | |||||
| } | |||||
| } | |||||
| public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | |||||
| return false; | |||||
| } | |||||
| public function describeAutomaticCapability($capability) { | |||||
| return null; | |||||
| } | |||||
| /* -( PhabricatorApplicationTransactionInterface )------------------------- */ | |||||
| public function getApplicationTransactionEditor() { | |||||
| return new PackagesVersionEditor(); | |||||
| } | |||||
| public function getApplicationTransactionObject() { | |||||
| return $this; | |||||
| } | |||||
| public function getApplicationTransactionTemplate() { | |||||
| return new PackagesVersionTransaction(); | |||||
| } | |||||
| public function willRenderTimeline( | |||||
| PhabricatorApplicationTransactionView $timeline, | |||||
| AphrontRequest $request) { | |||||
| return $timeline; | |||||
| } | |||||
| /* -( PhabricatorSubscribableInterface )----------------------------------- */ | |||||
| public function isAutomaticallySubscribed($phid) { | |||||
| return false; | |||||
| } | |||||
| public function shouldShowSubscribersProperty() { | |||||
| return true; | |||||
| } | |||||
| public function shouldAllowSubscription($phid) { | |||||
| return true; | |||||
| } | |||||
| /* -( PhabricatorDestructibleInterface )----------------------------------- */ | |||||
| public function destroyObjectPermanently( | |||||
| PhabricatorDestructionEngine $engine) { | |||||
| $this->openTransaction(); | |||||
| $this->delete(); | |||||
| // TODO: delete all signatures | |||||
Lint: TODO Comment This comment has a TODO. Lint: TODO Comment: This comment has a TODO. | |||||
| $this->saveTransaction(); | |||||
| } | |||||
| } | |||||
I think we should leave a lot more wiggle room than this: basically, have a $properties sort of property instead, and put the type ("git repository") + clone URI + hash in it.
It should be possible to publish a package version which changes the repository origin.
In the future, it should be possible to publish a package version which uses a tarball + checksum or similar.