Changeset View
Changeset View
Standalone View
Standalone View
src/applications/almanac/storage/AlmanacBinding.php
<?php | <?php | ||||
final class AlmanacBinding | final class AlmanacBinding | ||||
extends AlmanacDAO | extends AlmanacDAO | ||||
implements | implements | ||||
PhabricatorPolicyInterface, | PhabricatorPolicyInterface, | ||||
PhabricatorCustomFieldInterface, | |||||
PhabricatorApplicationTransactionInterface, | PhabricatorApplicationTransactionInterface, | ||||
AlmanacPropertyInterface, | AlmanacPropertyInterface, | ||||
PhabricatorDestructibleInterface { | PhabricatorDestructibleInterface { | ||||
protected $servicePHID; | protected $servicePHID; | ||||
protected $devicePHID; | protected $devicePHID; | ||||
protected $interfacePHID; | protected $interfacePHID; | ||||
protected $mailKey; | protected $mailKey; | ||||
private $service = self::ATTACHABLE; | private $service = self::ATTACHABLE; | ||||
private $device = self::ATTACHABLE; | private $device = self::ATTACHABLE; | ||||
private $interface = self::ATTACHABLE; | private $interface = self::ATTACHABLE; | ||||
private $customFields = self::ATTACHABLE; | |||||
private $almanacProperties = self::ATTACHABLE; | private $almanacProperties = self::ATTACHABLE; | ||||
public static function initializeNewBinding(AlmanacService $service) { | public static function initializeNewBinding(AlmanacService $service) { | ||||
return id(new AlmanacBinding()) | return id(new AlmanacBinding()) | ||||
->setServicePHID($service->getPHID()) | ->setServicePHID($service->getPHID()) | ||||
->attachAlmanacProperties(array()); | ->attachAlmanacProperties(array()); | ||||
} | } | ||||
Show All 24 Lines | final class AlmanacBinding | ||||
public function save() { | public function save() { | ||||
if (!$this->mailKey) { | if (!$this->mailKey) { | ||||
$this->mailKey = Filesystem::readRandomCharacters(20); | $this->mailKey = Filesystem::readRandomCharacters(20); | ||||
} | } | ||||
return parent::save(); | return parent::save(); | ||||
} | } | ||||
public function getName() { | |||||
return pht('Binding %s', $this->getID()); | |||||
} | |||||
public function getURI() { | public function getURI() { | ||||
return '/almanac/binding/'.$this->getID().'/'; | return '/almanac/binding/'.$this->getID().'/'; | ||||
} | } | ||||
public function getService() { | public function getService() { | ||||
return $this->assertAttached($this->service); | return $this->assertAttached($this->service); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | if ($this->hasAlmanacProperty($key)) { | ||||
return $default; | return $default; | ||||
} | } | ||||
} | } | ||||
public function getAlmanacPropertyFieldSpecifications() { | public function getAlmanacPropertyFieldSpecifications() { | ||||
return array(); | return array(); | ||||
} | } | ||||
public function newAlmanacPropertyEditEngine() { | |||||
return new AlmanacBindingPropertyEditEngine(); | |||||
} | |||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */ | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
public function getCapabilities() { | public function getCapabilities() { | ||||
return array( | return array( | ||||
PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
Show All 22 Lines | if ($capability === PhabricatorPolicyCapability::CAN_EDIT) { | ||||
'The service for this binding is locked, so it can not be edited.'); | 'The service for this binding is locked, so it can not be edited.'); | ||||
} | } | ||||
} | } | ||||
return $notes; | return $notes; | ||||
} | } | ||||
/* -( PhabricatorCustomFieldInterface )------------------------------------ */ | |||||
public function getCustomFieldSpecificationForRole($role) { | |||||
return array(); | |||||
} | |||||
public function getCustomFieldBaseClass() { | |||||
return 'AlmanacCustomField'; | |||||
} | |||||
public function getCustomFields() { | |||||
return $this->assertAttached($this->customFields); | |||||
} | |||||
public function attachCustomFields(PhabricatorCustomFieldAttachment $fields) { | |||||
$this->customFields = $fields; | |||||
return $this; | |||||
} | |||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */ | /* -( PhabricatorApplicationTransactionInterface )------------------------- */ | ||||
public function getApplicationTransactionEditor() { | public function getApplicationTransactionEditor() { | ||||
return new AlmanacBindingEditor(); | return new AlmanacBindingEditor(); | ||||
} | } | ||||
public function getApplicationTransactionObject() { | public function getApplicationTransactionObject() { | ||||
Show All 25 Lines |