2013-04-14 06:53:20 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group search
|
|
|
|
*/
|
|
|
|
final class PhabricatorSavedQuery extends PhabricatorSearchDAO {
|
|
|
|
|
|
|
|
protected $parameters = array();
|
2013-04-30 10:47:10 -07:00
|
|
|
protected $queryKey = "";
|
|
|
|
protected $engineClassName = "PhabricatorPasteSearchEngine";
|
2013-04-14 06:53:20 -07:00
|
|
|
|
|
|
|
public function getConfiguration() {
|
|
|
|
return array(
|
|
|
|
self::CONFIG_SERIALIZATION => array(
|
|
|
|
'parameters' => self::SERIALIZATION_JSON), )
|
|
|
|
+ parent::getConfiguration();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setParameter($key, $value) {
|
|
|
|
$this->parameters[$key] = $value;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getParameter($key, $default = null) {
|
|
|
|
return idx($this->parameters, $key, $default);
|
|
|
|
}
|
2013-04-30 10:47:10 -07:00
|
|
|
|
|
|
|
public function save() {
|
|
|
|
if ($this->getEngineClass() === null) {
|
|
|
|
throw new Exception(pht("Engine class is null."));
|
|
|
|
}
|
|
|
|
|
|
|
|
$serial = $this->getEngineClass().serialize($this->parameters);
|
|
|
|
$this->queryKey = PhabricatorHash::digestForIndex($serial);
|
|
|
|
|
|
|
|
return parent::save();
|
|
|
|
}
|
2013-04-14 06:53:20 -07:00
|
|
|
}
|