summaryrefslogtreecommitdiff
path: root/buildscripts/phing/classes/phing/parser/RootHandler.php
blob: 28afb5d51e406c7ad35e4bf041b519672e25638c (plain)
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
74
75
76
77
78
79
80
81
82
<?php
/*
 *  $Id: RootHandler.php,v 1.7 2003/12/24 13:02:09 hlellelid Exp $
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software consists of voluntary contributions made by many individuals
 * and is licensed under the LGPL. For more information please see
 * <http://phing.info>.
 */

require_once 'phing/parser/AbstractHandler.php';
include_once 'phing/parser/ExpatParseException.php';
include_once 'phing/parser/ProjectHandler.php';

/**
 * Root filter class for a phing buildfile.
 *
 * The root filter is called by the parser first. This is where the phing
 * specific parsing starts. RootHandler decides what to do next.
 *
 * @author    Andreas Aderhold <andi@binarycloud.com>
 * @copyright © 2001,2002 THYRELL. All rights reserved
 * @version   $Revision: 1.7 $
 * @package   phing.parser
 */
class RootHandler extends AbstractHandler {

    /**
     * The phing project configurator object
     */
    private $configurator;

    /**
     * Constructs a new RootHandler
     *
     * The root filter is required so the parser knows what to do. It's
     * called by the ExpatParser that is instatiated in ProjectConfigurator.
     *
     * It recieves the expat parse object ref and a reference to the
     * configurator
     *
     * @param AbstractSAXParser $parser The ExpatParser object.
     * @param ProjectConfigurator $configurator The ProjectConfigurator object.
     */
    function __construct(AbstractSAXParser $parser, ProjectConfigurator $configurator) {
        $this->configurator = $configurator;
        parent::__construct($parser, $this);
    }

    /**
     * Kick off a custom action for a start element tag.
     *
     * The root element of our buildfile is the &lt;project&gt; element. The
     * root filter handles this element if it occurs, creates ProjectHandler 
     * to handle any nested tags & attributes of the &lt;project&gt; tag,
     * and calls init.
     *
     * @param string $tag The xml tagname
     * @param array  $attrs The attributes of the tag
     * @throws ExpatParseException if the first element within our build file
     *         is not the &gt;project&lt; element
     */
    function startElement($tag, $attrs) {
        if ($tag === "project") {
            $ph = new ProjectHandler($this->parser, $this, $this->configurator);
            $ph->init($tag, $attrs);
        } else {
            throw new ExpatParseException("Unexpected tag <$tag> in top-level of build file.", $this->parser->getLocation());
        }
    }
}