Proide application-based handle loads; load Slowvote handles from the application
Summary: Ref T2715. This is pretty straightforward, I think. Notes: - Long term, I want to replace `PhabricatorObjectHandleData` with `PhabricatorObjectQuery` and `PhabricatorHandleQuery`. The former's name is a relic of old Facebook stuff and unusual now that everything else uses normal queries. - I simplified the amount of work applications need to do in order to populate handles. The should just need to set names and URIs in most cases. Test Plan: Used `phid.lookup` and `phid.query` to load slowvote handles. Browsed around to load other handles. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2715 Differential Revision: https://secure.phabricator.com/D6508
This commit is contained in:
		@@ -1,6 +1,7 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
final class PhabricatorObjectHandle {
 | 
			
		||||
final class PhabricatorObjectHandle
 | 
			
		||||
  implements PhabricatorPolicyInterface {
 | 
			
		||||
 | 
			
		||||
  private $uri;
 | 
			
		||||
  private $phid;
 | 
			
		||||
@@ -38,6 +39,9 @@ final class PhabricatorObjectHandle {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public function getName() {
 | 
			
		||||
    if ($this->name === null) {
 | 
			
		||||
      return pht('Unknown Object (%s)', $this->getTypeName());
 | 
			
		||||
    }
 | 
			
		||||
    return $this->name;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -99,9 +103,8 @@ final class PhabricatorObjectHandle {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public function getTypeName() {
 | 
			
		||||
    $types = PhabricatorPHIDType::getAllTypes();
 | 
			
		||||
    if (isset($types[$this->getType()])) {
 | 
			
		||||
      return $types[$this->getType()]->getTypeName();
 | 
			
		||||
    if ($this->getPHIDType()) {
 | 
			
		||||
      return $this->getPHIDType()->getTypeName();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    static $map = array(
 | 
			
		||||
@@ -223,4 +226,27 @@ final class PhabricatorObjectHandle {
 | 
			
		||||
    return $name;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected function getPHIDType() {
 | 
			
		||||
    $types = PhabricatorPHIDType::getAllTypes();
 | 
			
		||||
    return idx($types, $this->getType());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* -(  PhabricatorPolicyInterface  )----------------------------------------- */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  public function getCapabilities() {
 | 
			
		||||
    return array(
 | 
			
		||||
      PhabricatorPolicyCapability::CAN_VIEW,
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public function getPolicy($capability) {
 | 
			
		||||
    return PhabricatorPolicies::POLICY_PUBLIC;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user