*/ class Mage_Connect_Package { const PACKAGE_XML_DIR = 'var/package'; /** * Contain SimpleXMLElement for composing document. * * @var SimpleXMLElement */ protected $_packageXml; /** * Internal cache * * @var array */ protected $_authors; /** * Internal cache * * @var array */ protected $_contents; /** * Internal cache * * @var array */ protected $_hashContents; /** * Internal cache * * @var array */ protected $_compatible; /** * Internal cache * * @var array */ protected $_dependencyPhpExtensions; /** * Internal cache * * @var array */ protected $_dependencyPackages; /** * A helper object that can read from a package archive * * @var Mage_Connect_Package_Reader */ protected $_reader; /** * A helper object that can create and write to a package archive * * @var Mage_Connect_Package_Writer */ protected $_writer; /** * Validator object * * @var Mage_Connect_Validator */ protected $_validator = null; /** * Validation errors * * @var array */ protected $_validationErrors = array(); /** * Object with target * * @var Mage_Connect_Package_Target */ protected $_target = null; /** * Config object * * @var Mage_Connect_Config */ protected $_config = null; /** * Creates a package object (empty, or from existing archive, or from package definition xml) * * @param null|string|resource $source */ public function __construct($source=null) { libxml_use_internal_errors(true); if (is_string($source)) { // check what's in the string (a package definition or a package filename) if (0 === strpos($source, "_init($source); } elseif (is_file($source) && is_readable($source)) { // package archive filename $this->_loadFile($source); } else { throw new Mage_Exception('Invalid package source'); } } elseif (is_resource($source)) { $this->_loadResource($source); } elseif (is_null($source)) { $this->_init(); } else { throw new Mage_Exception('Invalid package source'); } } /** * Initializes an empty package object * * @param null|string $definition optional package definition xml * @return Mage_Connect_Package */ protected function _init($definition=null) { if (!is_null($definition)) { $this->_packageXml = simplexml_load_string($definition); } else { $packageXmlStub = <<