PageRenderTime 39ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/Ezer/engine/process/xml/logic/Ezer_XmlIf.php

http://ezerphp.googlecode.com/
PHP | 113 lines | 67 code | 15 blank | 31 comment | 4 complexity | 5b21da775d6198853b538ba7f918e5bc MD5 | raw file
  1. <?php
  2. /**
  3. * This library is free software; you can redistribute it and/or
  4. * modify it under the terms of the GNU Lesser General Public
  5. * License as published by the Free Software Foundation; either
  6. * version 2.1 of the License, or (at your option) any later version.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * Lesser General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Lesser General Public
  14. * License along with this library; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. *
  17. * For questions, help, comments, discussion, etc., please send
  18. * e-mail to johnathan.kanarek@gmail.com
  19. */
  20. /**
  21. * Purpose: Loads an else from XML
  22. * @author Tan-Tan
  23. * @package Engine
  24. * @subpackage Process.Logic.XML
  25. */
  26. class Ezer_XmlElse extends Ezer_Else
  27. {
  28. public function __construct(DOMElement $element)
  29. {
  30. parent::__construct(uniqid('else_'));
  31. Ezer_XmlStepContainerUtil::parse($this, $element);
  32. }
  33. public function &createInstance(Ezer_ScopeInstance &$scope_instance)
  34. {
  35. $ret = new Ezer_XmlElseInstance($scope_instance, $this);
  36. return $ret;
  37. }
  38. }
  39. /**
  40. * Purpose: Loads an if from XML
  41. * @author Tan-Tan
  42. * @package Engine
  43. * @subpackage Process.Logic.XML
  44. */
  45. class Ezer_XmlIf extends Ezer_If implements Ezer_IntIf
  46. {
  47. public function __construct(DOMElement $element)
  48. {
  49. parent::__construct(uniqid('if_'));
  50. Ezer_XmlStepContainerUtil::parse($this, $element);
  51. $this->parse($element);
  52. }
  53. public function &createInstance(Ezer_ScopeInstance &$scope_instance)
  54. {
  55. return new Ezer_XmlIfInstance($scope_instance, $this);
  56. }
  57. public function parse(DOMNode $element)
  58. {
  59. for($i = 0;$i < $element->childNodes->length;$i++)
  60. {
  61. $childElement = $element->childNodes->item($i);
  62. if($childElement->parentNode !== $element)
  63. continue;
  64. if($childElement instanceof DOMComment || $childElement instanceof DOMText)
  65. continue;
  66. switch($childElement->nodeName)
  67. {
  68. case 'condition':
  69. $this->condition = $childElement->nodeValue;
  70. break;
  71. case 'else':
  72. $this->else = new Ezer_XmlElse($childElement);
  73. break;
  74. case 'elseif':
  75. $this->elseifs[] = new Ezer_XmlIf($childElement);
  76. break;
  77. case 'flow':
  78. case 'sequence':
  79. case 'activity':
  80. case 'assign':
  81. case 'if':
  82. case 'foreach':
  83. case 'repeatUntil':
  84. case 'while':
  85. case 'switch':
  86. case 'empty':
  87. case 'wait':
  88. case 'terminate':
  89. case 'throw':
  90. case 'rethrow':
  91. // ignore, handled by Ezer_XmlStepContainerUtil
  92. break;
  93. default:
  94. throw new Ezer_XmlPersistanceElementNotMappedException($childElement->nodeName);
  95. }
  96. }
  97. }
  98. }