Aggregate Code Coverage for all tests
1 : <?php 2 : /** 3 : * PEAR2_Pyrus_PackageFile_v2Iterator_FileInstallationFilter 4 : * 5 : * PHP version 5 6 : * 7 : * @category PEAR2 8 : * @package PEAR2_Pyrus 9 : * @author Greg Beaver <cellog@php.net> 10 : * @copyright 2008 The PEAR Group 11 : * @license http://www.opensource.org/licenses/bsd-license.php New BSD License 12 : * @version SVN: $Id$ 13 : * @link http://svn.pear.php.net/wsvn/PEARSVN/Pyrus/ 14 : */ 15 : 16 : /** 17 : * filtered iterator for file installation 18 : * 19 : * @category PEAR2 20 : * @package PEAR2_Pyrus 21 : * @author Greg Beaver <cellog@php.net> 22 : * @copyright 2008 The PEAR Group 23 : * @license http://www.opensource.org/licenses/bsd-license.php New BSD License 24 : * @link http://svn.pear.php.net/wsvn/PEARSVN/Pyrus/ 25 : */ 26 : class PEAR2_Pyrus_PackageFile_v2Iterator_FileInstallationFilter extends FilterIterator 27 1 : { 28 : static private $_parent; 29 : static private $_installGroup; 30 : static function setParent(PEAR2_Pyrus_PackageFile_v2 $parent) 31 : { 32 1 : self::$_parent = $parent; 33 1 : $errs = new PEAR2_MultiErrors; 34 1 : $depchecker = new PEAR2_Pyrus_Dependency_Validator( 35 1 : array('channel' => self::$_parent->channel, 36 1 : 'package' => self::$_parent->package), 37 1 : PEAR2_Pyrus_Validate::INSTALLING, $errs); 38 1 : foreach (self::$_parent->installGroup as $instance) { 39 : try { 40 1 : if (isset($instance['installconditions'])) { 41 : $installconditions = $instance['installconditions']; 42 : if (is_array($installconditions)) { 43 : foreach ($installconditions as $type => $conditions) { 44 : if (!isset($conditions[0])) { 45 : $conditions = array($conditions); 46 : } 47 : foreach ($conditions as $condition) { 48 : $ret = $depchecker->{"validate{$type}Dependency"}($condition); 49 : } 50 : } 51 : } 52 : } 53 1 : } catch (Exception $e) { 54 : // can't use this release 55 : continue; 56 : } 57 1 : $release = array('install' => array(), 'ignore' => array()); 58 : // this is the release to use 59 1 : if (isset($instance['filelist'])) { 60 : // ignore files 61 : if (isset($instance['filelist']['ignore'])) { 62 : $ignore = isset($instance['filelist']['ignore'][0]) ? 63 : $instance['filelist']['ignore'] : 64 : array($instance['filelist']['ignore']); 65 : foreach ($ignore as $ig) { 66 : $release['ignore'][$ig['attribs']['name']] = true; 67 : } 68 : } 69 : // install files as this name 70 : if (isset($instance['filelist']['install'])) { 71 : $installas = isset($instance['filelist']['install'][0]) ? 72 : $instance['filelist']['install'] : 73 : array($instance['filelist']['install']); 74 : foreach ($installas as $as) { 75 : $release['install'][$as['attribs']['name']] = 76 : $as['attribs']['as']; 77 : } 78 : } 79 : } 80 1 : self::$_installGroup = $release; 81 1 : return; 82 : } 83 : } 84 : 85 : function current() 86 : { 87 1 : $file = $this->key(); 88 1 : $curfile = parent::current(); 89 1 : if (isset(self::$_installGroup['install'][$file])) { 90 : // add the install-as attribute for these files 91 : $curfile['attribs']['install-as'] = 92 : self::$_installGroup['install'][$file]; 93 : } 94 1 : if ($b = self::$_parent->getBaseInstallDir($file)) { 95 1 : $curfile['attribs']['baseinstalldir'] = $b; 96 1 : } 97 1 : return new PEAR2_Pyrus_PackageFile_v2Iterator_FileTag($curfile, 98 1 : dirname($file), self::$_parent); 99 : } 100 : 101 : function accept() 102 : { 103 1 : $file = $this->getInnerIterator()->key(); 104 1 : if (isset(self::$_installGroup['ignore'][$file])) { 105 : // skip ignored files 106 : return false; 107 : } 108 1 : return true; 109 : } 110 1 : }