Changeset View
Changeset View
Standalone View
Standalone View
src/applications/nuance/source/NuanceSourceDefinition.php
| Show All 37 Lines | abstract class NuanceSourceDefinition extends Phobject { | ||||
| public function requireSourceObject() { | public function requireSourceObject() { | ||||
| $source = $this->getSourceObject(); | $source = $this->getSourceObject(); | ||||
| if (!$source) { | if (!$source) { | ||||
| throw new PhutilInvalidStateException('setSourceObject'); | throw new PhutilInvalidStateException('setSourceObject'); | ||||
| } | } | ||||
| return $source; | return $source; | ||||
| } | } | ||||
| /** | public function getSourceViewActions(AphrontRequest $request) { | ||||
| * Gives a @{class:NuanceSourceDefinition} object for a given | return array(); | ||||
| * @{class:NuanceSource}. Note you still need to @{method:setActor} | |||||
| * before the @{class:NuanceSourceDefinition} object will be useful. | |||||
| */ | |||||
| public static function getDefinitionForSource(NuanceSource $source) { | |||||
| $definitions = self::getAllDefinitions(); | |||||
| $map = mpull($definitions, null, 'getSourceTypeConstant'); | |||||
| $definition = $map[$source->getType()]; | |||||
| $definition->setSourceObject($source); | |||||
| return $definition; | |||||
| } | } | ||||
| public static function getAllDefinitions() { | public static function getAllDefinitions() { | ||||
| return id(new PhutilClassMapQuery()) | return id(new PhutilClassMapQuery()) | ||||
| ->setAncestorClass(__CLASS__) | ->setAncestorClass(__CLASS__) | ||||
| ->setUniqueMethod('getSourceTypeConstant') | ->setUniqueMethod('getSourceTypeConstant') | ||||
| ->execute(); | ->execute(); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 215 Lines • ▼ Show 20 Lines | |||||
| /* -( Handling Action Requests )------------------------------------------- */ | /* -( Handling Action Requests )------------------------------------------- */ | ||||
| public function handleActionRequest(AphrontRequest $request) { | public function handleActionRequest(AphrontRequest $request) { | ||||
| return new Aphront404Response(); | return new Aphront404Response(); | ||||
| } | } | ||||
| public function getActionURI($path = null) { | |||||
| $source_id = $this->getSourceObject()->getID(); | |||||
| return '/action/'.$source_id.'/'.ltrim($path, '/'); | |||||
| } | |||||
| } | } | ||||