/
QueryManager.php
55 lines (49 loc) · 1.55 KB
/
QueryManager.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
*
* This interface encapsulates methods for the management of search queries.
* Provides methods for the creation and retrieval of search queries.
* @author
* @version 1.0
*
*/
class QueryManager {
private $pm;
private $workspace;
/**
*
* Creates a new QueryManager object, given an active PersistenceManager.
* @param generic $pm the active PersistenceManager.
*
*/
public function __construct(&$pm) {
$this->pm =& $pm;
$this->workspace = $pm->getWorkspace();
}
/**
*
* Creates a new query by specifying the query statement itself.
* It is generic enough where people can come up with their own query implemenation.
* If the query statement is syntactically invalid, an InvalidQueryException is thrown.
* @param string $statement the parameter containing the query statement.
* @return Query a Query object.
*
*/
public function createQuery($statement) {
return new Query($this->pm, $statement);
}
/**
*
* Retrieves an existing persistent query.
* If node is not a valid persisted query, an InvalidQueryException is thrown.
* Persistent queries are created by first using QueryManager->createQuery to create a Query object and then calling Query->storeAsNode to persist the query to a location in the workspace.
* @param Node $node a persisted query.
* @return Query a Query object.
*
*/
public function getQuery(Node $node) {
Log4PCR::info("Requested query: $this->workspace=>" . $node->getPath());
return new Query($this->pm, $node->getProperty('pcr:statement')->getString());
}
}
?>