コード例 #1
0
ファイル: Packager.php プロジェクト: nicholasryan/CorePlus
	private function _setupCore(){
		$this->_xmlFile = \ComponentFactory::ResolveNameToFile($this->_keyname);
		if(!$this->_xmlFile){
			throw new \Exception('XML file for Core not found??? [' . $this->_keyname . ']');
		}

		$this->_base = new DirectoryLocal(ROOT_PDIR);
		$this->_iterator = new DirectoryIterator($this->_base);

		// Get the XMLLoader object for this file.  This will allow me to have more fine-tune control over the file.
		$this->_xmlLoader = new \XMLLoader();
		$this->_xmlLoader->setRootName('component');
		if(!$this->_xmlLoader->loadFromFile($this->_xmlFile)){
			throw new \Exception('Unable to load XML file ' . $this->_xmlFile);
		}

		$this->_iterator->findDirectories = false;
		$this->_iterator->recursive = true;
		$this->_iterator->ignores = [
			'core/component.xml',
			'components/',
			'config/configuration.xml',
			'dropins/',
			'exports/',
			'nbproject/',
			'.idea/',
			'themes/',
			'.htaccess',
			'gnupg',
			'core/bootstrap.compiled.php',
			'logs/',
			'core/dev/',
			'core/tests/',
		];

		if(CDN_LOCAL_ASSETDIR)   $this->_iterator->ignores[] = CDN_LOCAL_ASSETDIR;
		if(CDN_LOCAL_PUBLICDIR)  $this->_iterator->ignores[] = CDN_LOCAL_PUBLICDIR;
		if(CDN_LOCAL_PRIVATEDIR) $this->_iterator->ignores[] = CDN_LOCAL_PRIVATEDIR;
		if(strpos(TMP_DIR_WEB, ROOT_PDIR) === 0) $this->_iterator->ignores[] = TMP_DIR_WEB;
		if(strpos(TMP_DIR_CLI, ROOT_PDIR) === 0) $this->_iterator->ignores[] = TMP_DIR_CLI;

		$this->_name = 'Core';

		$this->_licenses = [];
		foreach($this->_xmlLoader->getElements('//component/licenses/license') as $el){
			/** @var \DOMElement $el */
			$url = @$el->getAttribute('url');
			$this->_licenses[] = [
				'title' => $el->nodeValue,
				'url' => $url
			];
		}

		$this->_authors = [];
		foreach($this->_xmlLoader->getElements('//component/authors/author') as $el){
			$this->_authors[] = [
				'name' => $el->getAttribute('name'),
				'email' => @$el->getAttribute('email'),
			];
		}

		$this->_changelog = new Changelog\Parser('Core Plus', ROOT_PDIR . 'core/CHANGELOG');

		$this->_gitPaths = [
			ROOT_PDIR . 'config/',
			ROOT_PDIR . 'core/',
			ROOT_PDIR . 'install/',
			ROOT_PDIR . 'utilities/',
			ROOT_PDIR . 'index.php'
		];
	}