[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/search/storage/ -> PhabricatorSavedQuery.php (source)

   1  <?php
   2  
   3  final class PhabricatorSavedQuery extends PhabricatorSearchDAO
   4    implements PhabricatorPolicyInterface {
   5  
   6    protected $parameters = array();
   7    protected $queryKey;
   8    protected $engineClassName;
   9  
  10    public function getConfiguration() {
  11      return array(
  12        self::CONFIG_SERIALIZATION => array(
  13          'parameters' => self::SERIALIZATION_JSON,
  14        ),
  15        self::CONFIG_COLUMN_SCHEMA => array(
  16          'engineClassName' => 'text255',
  17          'queryKey' => 'text12',
  18        ),
  19        self::CONFIG_KEY_SCHEMA => array(
  20          'key_queryKey' => array(
  21            'columns' => array('queryKey'),
  22            'unique' => true,
  23          ),
  24        ),
  25      ) + parent::getConfiguration();
  26    }
  27  
  28    public function setParameter($key, $value) {
  29      $this->parameters[$key] = $value;
  30      return $this;
  31    }
  32  
  33    public function getParameter($key, $default = null) {
  34      return idx($this->parameters, $key, $default);
  35    }
  36  
  37    public function save() {
  38      if ($this->getEngineClassName() === null) {
  39        throw new Exception(pht('Engine class is null.'));
  40      }
  41  
  42      // Instantiate the engine to make sure it's valid.
  43      $this->newEngine();
  44  
  45      $serial = $this->getEngineClassName().serialize($this->parameters);
  46      $this->queryKey = PhabricatorHash::digestForIndex($serial);
  47  
  48      return parent::save();
  49    }
  50  
  51    public function newEngine() {
  52      return newv($this->getEngineClassName(), array());
  53    }
  54  
  55  
  56  /* -(  PhabricatorPolicyInterface  )----------------------------------------- */
  57  
  58  
  59    public function getCapabilities() {
  60      return array(
  61        PhabricatorPolicyCapability::CAN_VIEW,
  62      );
  63    }
  64  
  65    public function getPolicy($capability) {
  66      return PhabricatorPolicies::POLICY_PUBLIC;
  67    }
  68  
  69    public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
  70      return false;
  71    }
  72  
  73    public function describeAutomaticCapability($capability) {
  74      return null;
  75    }
  76  
  77  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1