3 final class PhabricatorSavedQuery
extends PhabricatorSearchDAO
4 implements PhabricatorPolicyInterface
{
6 protected $parameters = array();
8 protected $engineClassName;
10 private $parameterMap = self
::ATTACHABLE
;
12 protected function getConfiguration() {
14 self
::CONFIG_SERIALIZATION
=> array(
15 'parameters' => self
::SERIALIZATION_JSON
,
17 self
::CONFIG_COLUMN_SCHEMA
=> array(
18 'engineClassName' => 'text255',
19 'queryKey' => 'text12',
21 self
::CONFIG_KEY_SCHEMA
=> array(
22 'key_queryKey' => array(
23 'columns' => array('queryKey'),
27 ) + parent
::getConfiguration();
30 public function setParameter($key, $value) {
31 $this->parameters
[$key] = $value;
35 public function getParameter($key, $default = null) {
36 return idx($this->parameters
, $key, $default);
39 public function save() {
40 if ($this->getEngineClassName() === null) {
41 throw new Exception(pht('Engine class is null.'));
44 // Instantiate the engine to make sure it's valid.
47 $serial = $this->getEngineClassName().serialize($this->parameters
);
48 $this->queryKey
= PhabricatorHash
::digestForIndex($serial);
50 return parent
::save();
53 public function newEngine() {
54 return newv($this->getEngineClassName(), array());
57 public function attachParameterMap(array $map) {
58 $this->parameterMap
= $map;
62 public function getEvaluatedParameter($key) {
63 return $this->assertAttachedKey($this->parameterMap
, $key);
66 public function newCopy() {
68 ->setParameters($this->getParameters())
70 ->setEngineClassName($this->getEngineClassName());
74 /* -( PhabricatorPolicyInterface )----------------------------------------- */
77 public function getCapabilities() {
79 PhabricatorPolicyCapability
::CAN_VIEW
,
83 public function getPolicy($capability) {
84 return PhabricatorPolicies
::POLICY_PUBLIC
;
87 public function hasAutomaticCapability($capability, PhabricatorUser
$viewer) {