Varien_Pear_Package Class Reference

List of all members.

Public Member Functions

 __construct ()
 getPear ()
 getPearConfig ($key)
 set ($key, $data)
 get ($key)
 setPfm ($pfm)
 getPfm ($package=null)
 clearPackage ()
 generatePackage ($make=false)
 defineData ()
 definePackage ()
 defineRelease ()

Protected Attributes

 $_data
 $_pear
 $_pfm


Detailed Description

Definition at line 20 of file Package.php.


Constructor & Destructor Documentation

__construct (  ) 

Definition at line 36 of file Package.php.

00037     {
00038         $this->_pear = Varien_Pear::getInstance();
00039     }


Member Function Documentation

clearPackage (  ) 

Definition at line 131 of file Package.php.

00132     {
00133         $pfm = $this->getPfm();
00134         $pfm->clearContents();
00135         $pfm->clearCompatible();
00136         $pfm->clearDeps();
00137         $pfm->clearChangeLog();
00138         return $this;
00139     }

defineData (  ) 

Definition at line 171 of file Package.php.

00172     {
00173         $this->set('options/outputdirectory', $this->getPear()->getPearDir().DS.'output');
00174         $this->set('options/filelistgenerator', 'php');
00175         $this->set('options/simpleoutput', true);
00176 
00177         return $this;
00178     }

definePackage (  ) 

Definition at line 180 of file Package.php.

00181     {
00182         return $this;
00183     }

defineRelease (  ) 

Definition at line 185 of file Package.php.

00186     {
00187         return $this;
00188     }

generatePackage ( make = false  ) 

Definition at line 141 of file Package.php.

00142     {
00143         PEAR::setErrorHandling(PEAR_ERROR_DIE);
00144 
00145         $this->definePackage();
00146 
00147         $pfm = $this->getPfm();
00148         $pfm->addRelease();
00149 
00150         $this->defineRelease();
00151 
00152         $pfm->generateContents();
00153         $pfm1 = $pfm->exportCompatiblePackageFile1($this->get('options'));
00154 
00155         if ($make) {
00156             $pfm1->writePackageFile();
00157             $pfm->writePackageFile();
00158 
00159             $outputDir = $this->get('options/outputdirectory');
00160             MagePearWrapper::getInstance()->run('package', array(),
00161                 array($outputDir.'package.xml', $outputDir.'package2.xml')
00162             );
00163         } else {
00164             $pfm1->debugPackageFile();
00165             $pfm->debugPackageFile();
00166         }
00167 
00168         return $this;
00169     }

get ( key  ) 

Definition at line 74 of file Package.php.

00075     {
00076         if (''===$key) {
00077             return $this->_data;
00078         }
00079 
00080         // accept a/b/c as ['a']['b']['c']
00081         $keyArr = explode('/', $key);
00082         $data = $this->_data;
00083         foreach ($keyArr as $i=>$k) {
00084             if ($k==='') {
00085                 return null;
00086             }
00087             if (is_array($data)) {
00088                 if (!isset($data[$k])) {
00089                     return null;
00090                 }
00091                 $data = $data[$k];
00092             } else {
00093                 return null;
00094             }
00095         }
00096         return $data;
00097     }

getPear (  ) 

Definition at line 41 of file Package.php.

00042     {
00043         return $this->_pear;
00044     }

getPearConfig ( key  ) 

Definition at line 46 of file Package.php.

00047     {
00048         return $this->getPear()->getConfig()->get($key);
00049     }

getPfm ( package = null  ) 

Get PackageFileManager2 instance

Parameters:
string|PEAR_PackageFile_v1 $package
Returns:
PEAR_PackageFileManager2|PEAR_Error

Definition at line 111 of file Package.php.

00112     {
00113         if (!$this->_pfm) {
00114             if (is_null($package)) {
00115                 $this->_pfm = new PEAR_PackageFileManager2;
00116                 $this->_pfm->setOptions($this->get('options'));
00117             } else {
00118                 $this->defineData();
00119 
00120                 $this->_pfm = PEAR_PackageFileManager2::importOptions($package, $this->get('options'));
00121                 if ($this->_pfm instanceof PEAR_Error) {
00122                     $e = PEAR_Exception('Could not instantiate PEAR_PackageFileManager2');
00123                     $e->errorObject = $this->_pfm;
00124                     throw $e;
00125                 }
00126             }
00127         }
00128         return $this->_pfm;
00129     }

set ( key,
data 
)

Definition at line 51 of file Package.php.

00052     {
00053         if (''===$key) {
00054             $this->_data = $data;
00055             return $this;
00056         }
00057 
00058         // accept a/b/c as ['a']['b']['c']
00059         $keyArr = explode('/', $key);
00060 
00061         $ref = &$this->_data;
00062         for ($i=0, $l=sizeof($keyArr); $i<$l; $i++) {
00063             $k = $keyArr[$i];
00064             if (!isset($ref[$k])) {
00065                 $ref[$k] = array();
00066             }
00067             $ref = &$ref[$k];
00068         }
00069         $ref = $data;
00070 
00071         return $this;
00072     }

setPfm ( pfm  ) 

Definition at line 99 of file Package.php.

00100     {
00101         $this->_pfm = $pfm;
00102         return $this;
00103     }


Member Data Documentation

$_data [protected]

Initial value:

 array(
        'options' => array(
            'baseinstalldir'=>'',
            'filelistgenerator'=>'file',
            'packagedirectory'=>'.',
            'outputdirectory'=>'.',
        ),
        'package' => array(),
        'release' => array(),
    )

Definition at line 22 of file Package.php.

$_pear [protected]

Definition at line 33 of file Package.php.

$_pfm [protected]

Definition at line 34 of file Package.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:25:04 2009 for Magento by  doxygen 1.5.8