web/lib/Zend/Tool/Project/Profile/FileParser/Xml.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Tool
    16  * @package    Zend_Tool
    17  * @subpackage Framework
    17  * @subpackage Framework
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @version    $Id: Xml.php 20851 2010-02-02 21:45:51Z ralph $
    20  * @version    $Id: Xml.php 24593 2012-01-05 20:35:02Z matthew $
    21  */
    21  */
    22 
    22 
    23 require_once 'Zend/Tool/Project/Profile/FileParser/Interface.php';
    23 require_once 'Zend/Tool/Project/Profile/FileParser/Interface.php';
    24 require_once 'Zend/Tool/Project/Context/Repository.php';
    24 require_once 'Zend/Tool/Project/Context/Repository.php';
    25 require_once 'Zend/Tool/Project/Profile.php';
    25 require_once 'Zend/Tool/Project/Profile.php';
    26 require_once 'Zend/Tool/Project/Profile/Resource.php';
    26 require_once 'Zend/Tool/Project/Profile/Resource.php';
    27 
    27 
    28 /**
    28 /**
    29  * @category   Zend
    29  * @category   Zend
    30  * @package    Zend_Tool
    30  * @package    Zend_Tool
    31  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    31  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    32  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    32  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    33  */
    33  */
    34 class Zend_Tool_Project_Profile_FileParser_Xml implements Zend_Tool_Project_Profile_FileParser_Interface
    34 class Zend_Tool_Project_Profile_FileParser_Xml implements Zend_Tool_Project_Profile_FileParser_Interface
    35 {
    35 {
    36 
    36 
    70         $xmlElement = new SimpleXMLElement('<projectProfile />');
    70         $xmlElement = new SimpleXMLElement('<projectProfile />');
    71 
    71 
    72         if ($profile->hasAttribute('type')) {
    72         if ($profile->hasAttribute('type')) {
    73             $xmlElement->addAttribute('type', $profile->getAttribute('type'));
    73             $xmlElement->addAttribute('type', $profile->getAttribute('type'));
    74         }
    74         }
    75         
    75 
    76         if ($profile->hasAttribute('version')) {
    76         if ($profile->hasAttribute('version')) {
    77             $xmlElement->addAttribute('version', $profile->getAttribute('version'));
    77             $xmlElement->addAttribute('version', $profile->getAttribute('version'));
    78         }
    78         }
    79         
    79 
    80         self::_serializeRecurser($profile, $xmlElement);
    80         self::_serializeRecurser($profile, $xmlElement);
    81 
    81 
    82         $doc = new DOMDocument('1.0');
    82         $doc = new DOMDocument('1.0');
    83         $doc->formatOutput = true;
    83         $doc->formatOutput = true;
    84         $domnode = dom_import_simplexml($xmlElement);
    84         $domnode = dom_import_simplexml($xmlElement);
   109         $xmlDataIterator = new SimpleXMLIterator($data);
   109         $xmlDataIterator = new SimpleXMLIterator($data);
   110 
   110 
   111         if ($xmlDataIterator->getName() != 'projectProfile') {
   111         if ($xmlDataIterator->getName() != 'projectProfile') {
   112             throw new Exception('Profiles must start with a projectProfile node');
   112             throw new Exception('Profiles must start with a projectProfile node');
   113         }
   113         }
   114         
   114 
   115         if (isset($xmlDataIterator['type'])) {
   115         if (isset($xmlDataIterator['type'])) {
   116             $this->_profile->setAttribute('type', (string) $xmlDataIterator['type']);
   116             $this->_profile->setAttribute('type', (string) $xmlDataIterator['type']);
   117         }
   117         }
   118         
   118 
   119         if (isset($xmlDataIterator['version'])) {
   119         if (isset($xmlDataIterator['version'])) {
   120             $this->_profile->setAttribute('version', (string) $xmlDataIterator['version']);
   120             $this->_profile->setAttribute('version', (string) $xmlDataIterator['version']);
   121         }
   121         }
   122         
   122 
   123         // start un-serialization of the xml doc
   123         // start un-serialization of the xml doc
   124         $this->_unserializeRecurser($xmlDataIterator);
   124         $this->_unserializeRecurser($xmlDataIterator);
   125 
   125 
   126         // contexts should be initialized after the unwinding of the profile structure
   126         // contexts should be initialized after the unwinding of the profile structure
   127         $this->_lazyLoadContexts();
   127         $this->_lazyLoadContexts();