Page MenuHomePhorge

SemiStructuredObjectInstance.php
No OneTemporary

SemiStructuredObjectInstance.php

<?php
final class SemiStructuredObjectInstance extends SemiStructuredDAO
implements
PhabricatorPolicyInterface,
PhabricatorApplicationTransactionInterface,
// PhabricatorSubscribableInterface,
PhabricatorFlaggableInterface,
// PhabricatorConduitResultInterface,
PhabricatorDestructibleInterface {
protected $classID;
protected $status;
protected $name;
protected $rawData;
// description?
// comments?
const STATUS_ACTIVE = 'active';
const STATUS_ARCHIVED = 'archived';
private $class = self::ATTACHABLE;
public static function initializeNewObjectInstance(
PhabricatorUser $actor,
SemiStructuredObjectType $object_class = null) {
$object = id(new self())
// ->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy()) // TODO take policies from class?
// ->setEditPolicy($actor->getPHID())
->setStatus(self::STATUS_ACTIVE);
if ($object_class !== null) {
$object
->setClassID($object_class->getID())
->attachClass($object_class);
}
return $object;
}
public function attachClass(
SemiStructuredObjectType $object_class = null) {
$this->class = $object_class;
return $this;
}
public function getClass() {
return $this->assertAttached($this->class);
}
public function getURI() {
return urisprintf('/semistruct/instance/%d/', $this->getID());
}
public function getIcon() {
// TODO
return 'fa-google';
}
public static function getStatusNameMap() {
return array(
self::STATUS_ACTIVE => pht('Active'),
self::STATUS_ARCHIVED => pht('Archived'),
);
}
protected function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'sort255',
'status' => 'text32',
'rawData' => 'text',
),
self::CONFIG_KEY_SCHEMA => array(
'classID' => array(
'columns' => array('classID'),
),
),
) + parent::getConfiguration();
}
public function getPHIDType() {
return SemiStructuredObjectInstancePHIDType::TYPECONST;
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
public function getApplicationTransactionEditor() {
return new SemiStructuredObjectInstanceTransactionEditor();
}
public function getApplicationTransactionTemplate() {
return new SemiStructuredObjectInstanceTransaction();
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
);
}
public function getPolicy($capability) {
return;
switch ($capability) {
// TODO
case PhabricatorPolicyCapability::CAN_VIEW:
return $this->getViewPolicy();
case PhabricatorPolicyCapability::CAN_EDIT:
return $this->getEditPolicy();
}
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
return true;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$this->openTransaction();
$this->delete();
$this->saveTransaction();
}
}

File Metadata

Mime Type
text/x-php
Expires
Sun, Jan 19, 19:05 (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1127674
Default Alt Text
SemiStructuredObjectInstance.php (3 KB)

Event Timeline