/
View.php
73 lines (61 loc) · 1.86 KB
/
View.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
namespace DBAL\XML;
use DBAL\Data;
class View extends \DBAL\Data\View
{
function getDefaultQuery()
{
return new \DBAL\XML\Query();
}
function getDefaultSelect()
{
$command = $this->getDefaultQuery();
$command->build()
->from( $this->Parameters['path'] );
return $command;
}
function getDefaultInsert()
{
return $this->getDefaultUpdate();
}
function getDefaultUpdate()
{
$command = $this->getDefaultQuery();
return $command->build()
->update( $this->Parameters['path'] );
}
function getDefaultDelete()
{
return $this->getDefaultUpdate();
}
function prepare( $source = null )
{
if( $source instanceof \DBAL\Data\Source )
{
if( $this->adapter->isRead() )
{
if( isset( $this->Parameters['xpath']))
{
$this->command->Parameters['xpath'] = $this->Parameters['xpath'];
}
$source->Map->register( new \DBAL\XML\Filter\SimpleXML() );
if( isset( $this->command->Parameters['xpath']) )
{
$source->Map->register( new \DBAL\XML\Filter\XPath( $this->command->Parameters ) );
}
$source->Map->recurse( new Filter\Node() );
}
elseif( $this->adapter->isWrite() )
{
if( $source instanceof \DBAL\XML\Document )
$root = $source->getRoot();
else
$root = $source->Data[0];
if( $root instanceof \DBAL\Data\Tree\Node )
$this->command->build()
->set( $root );
}
}
return parent::prepare( $source );
}
}