/** * loadFromFile() - Load data from file * * this attempts to load a project profile file from a variety of locations depending * on what information the user provided vie $options or attributes, specifically the * 'projectDirectory' or 'projectProfileFile' * */ public function loadFromFile() { // if no data is supplied, need either a projectProfileFile or a projectDirectory if (!isset($this->_attributes['projectProfileFile']) && !isset($this->_attributes['projectDirectory'])) { require_once 'Zend/Tool/Project/Exception.php'; throw new Zend_Tool_Project_Exception('loadFromFile() must have at least "projectProfileFile" or "projectDirectory" set.'); } if (isset($this->_attributes['projectProfileFile'])) { $projectProfileFilePath = $this->_attributes['projectProfileFile']; if (!file_exists($projectProfileFilePath)) { require_once 'Zend/Tool/Project/Exception.php'; throw new Zend_Tool_Project_Exception('"projectProfileFile" was supplied but file was not found at location ' . $projectProfileFilePath); } $this->_attributes['projectDirectory'] = dirname($projectProfileFilePath); } else { $projectProfileFilePath = rtrim($this->_attributes['projectDirectory'], '/\\') . '/.zfproject.xml'; if (!file_exists($projectProfileFilePath)) { require_once 'Zend/Tool/Project/Exception.php'; throw new Zend_Tool_Project_Exception('"projectDirectory" was supplied but no profile file file was not found at location ' . $projectProfileFilePath); } $this->_attributes['projectProfileFile'] = $projectProfileFilePath; } $profileData = file_get_contents($projectProfileFilePath); $profileFileParser = new Zend_Tool_Project_Profile_FileParser_Xml(); $profileFileParser->unserialize($profileData, $this); $this->rewind(); }