PhingXMLContext.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /*
  3. * $Id: PhingXMLContext.php 905 2010-10-05 16:28:03Z mrook $
  4. *
  5. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  6. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  8. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  9. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16. *
  17. * This software consists of voluntary contributions made by many individuals
  18. * and is licensed under the LGPL. For more information please see
  19. * <http://phing.info>.
  20. */
  21. /**
  22. * Track the current state of the Xml parse operation.
  23. *
  24. * @author Bryan Davis <bpd@keynetics.com>
  25. * @version $Revision: 905 $ $Date: 2010-10-05 18:28:03 +0200 (Tue, 05 Oct 2010) $
  26. * @access public
  27. * @package phing.parser
  28. */
  29. class PhingXMLContext {
  30. /**
  31. * Constructor
  32. * @param $project the project to which this antxml context belongs to
  33. */
  34. public function __construct ($project) {
  35. $this->project = $project;
  36. }
  37. /** The project to configure. */
  38. private $project;
  39. private $configurators = array();
  40. public function startConfigure ($cfg) {
  41. $this->configurators[] = $cfg;
  42. }
  43. public function endConfigure () {
  44. array_pop($this->configurators);
  45. }
  46. public function getConfigurator () {
  47. $l = count($this->configurators);
  48. if (0 == $l) {
  49. return null;
  50. } else {
  51. return $this->configurators[$l - 1];
  52. }
  53. }
  54. /** Impoerted files */
  55. private $importStack = array();
  56. public function addImport ($file) {
  57. $this->importStack[] = $file;
  58. }
  59. public function getImportStack () {
  60. return $this->importStack;
  61. }
  62. /**
  63. * find out the project to which this context belongs
  64. * @return project
  65. */
  66. public function getProject() {
  67. return $this->project;
  68. }
  69. } //end PhingXMLContext