示例#1
0
 function parse(array $params = null)
 {
     if (is_array($params) && array_key_exists('name', $params)) {
         if (!$this->Parameters->exists('ViewArguments')) {
             $this->Parameters['ViewArguments'] = array();
         }
         $viewArgs = $this->Parameters['ViewArguments'];
         $query = new \DBAL\XML\Query();
         $query->build()->where('entity')->attribute('name', $params['name']);
         // RETRIEVE XPATH
         $viewArgs['xpath'] = (string) $query;
         $this->Parameters['ViewArguments'] = $viewArgs;
     }
     return parent::parse($params);
 }
示例#2
0
 * ----------------------------------------------
 * EQUIVALENT XML
 * ----------------------------------------------
 * <test>
 *      <subnode></subnode>
 *      <subnode test="someValue" attr="2"></subnode>
 *      <subnode></subnode>
 *      <subnode test="someValue" attr="2"></subnode>
 * </test>
 * ----------------------------------------------
 * QUERY BUILDER CREATES VALID XPATH
 * SEARCH NODES WHERE 'subnode' ELEMENT
 * WHERE ATTRIBUTE 'test' = 'someValue'
 * ----------------------------------------------
 */
$query = new \DBAL\XML\Query();
$query->build()->where('subnode')->attribute('test', 'someValue');
// RETRIEVE XPATH
$xpath = (string) $query;
/*
 * EXECUTING XPATH QUERY
 * XPATH: subnode[@test="someValue"]
 */
$results = $node($xpath);
var_dump($results);
/* ----------------------------------------------
 * OUTPUT:
 * array() = ( 0 => (object)Tree\Node,      - CHILD 2
 *             1 => (object)Tree\Node )     - CHILD 4
 *            
 * ----------------------------------------------