1
<?php
2
/**
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the LGPL. For more information please see
17
 * <http://phing.info>.
18
 */
19

20
/**
21
 * Implements an XSLT processing filter while copying files.
22
 *
23
 * This is a shortcut for calling the <copy> task with the XSLTFilter used
24
 * in the <filterchains> section.
25
 *
26
 * @author  Andreas Aderhold, andi@binarycloud.com
27
 * @package phing.tasks.system
28
 */
29
class XsltTask extends CopyTask
30
{
31

32
    /**
33
     * @var XsltFilter object that we use to handle transformation.
34
     */
35
    private $xsltFilter;
36

37
    /**
38
     * @var XsltParam[] parameters to pass to XSLT processor.
39
     */
40
    private $parameters = [];
41

42
    /**
43
     * Setup the filterchains w/ XSLTFilter that we will use while copying the files.
44
     */
45 0
    public function init()
46
    {
47 0
        $xf = new XsltFilter();
48 0
        $chain = new FilterChain($this->getProject());
49 0
        $chain->addXsltFilter($xf);
50 0
        $this->addFilterChain($chain);
51 0
        $this->xsltFilter = $xf;
52
    }
53

54
    /**
55
     * Set any XSLT Param and invoke CopyTask::main()
56
     *
57
     * @see CopyTask::main()
58
     */
59 0
    public function main()
60
    {
61 0
        $this->log("Doing XSLT transformation using stylesheet " . $this->xsltFilter->getStyle(), Project::MSG_VERBOSE);
62 0
        $this->xsltFilter->setParams($this->parameters);
63 0
        parent::main();
64
    }
65

66
    /**
67
     * @param bool $isHtml
68
     */
69 0
    public function setHtml(bool $isHtml)
70
    {
71 0
        $this->xsltFilter->setHtml($isHtml);
72
    }
73

74
    /**
75
     * Set the stylesheet to use.
76
     *
77
     * @param PhingFile $style
78
     */
79 0
    public function setStyle(PhingFile $style)
80
    {
81 0
        $this->xsltFilter->setStyle($style);
82
    }
83

84
    /**
85
     * Whether to resolve entities in the XML document.
86
     *
87
     * @param bool $resolveExternals
88
     *
89
     * @since 2.4
90
     */
91 0
    public function setResolveDocumentExternals(bool $resolveExternals)
92
    {
93 0
        $this->xsltFilter->setResolveDocumentExternals($resolveExternals);
94
    }
95

96
    /**
97
     * Whether to resolve entities in the stylesheet.
98
     *
99
     * @param bool $resolveExternals
100
     *
101
     * @since 2.4
102
     */
103 0
    public function setResolveStylesheetExternals(bool $resolveExternals)
104
    {
105 0
        $this->xsltFilter->setResolveStylesheetExternals($resolveExternals);
106
    }
107

108
    /**
109
     * Support nested <param> tags using XSLTParam class.
110
     *
111
     * @return XsltParam
112
     */
113 0
    public function createParam()
114
    {
115 0
        $num = array_push($this->parameters, new XsltParam());
116

117 0
        return $this->parameters[$num - 1];
118
    }
119
}

Read our documentation on viewing source code .

Loading