eZ Publish  [trunk]
ezwizardbaseclassloader.php
Go to the documentation of this file.
00001 <?php
00002 /**
00003  * File containing the eZWizardBaseClassLoader class.
00004  *
00005  * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved.
00006  * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
00007  * @version //autogentag//
00008  * @package lib
00009  */
00010 
00011 /*!
00012   \class eZWizardBaseClassLoader ezwizardbaseclassloader.php
00013   \brief The class eZWizardBaseClassLoader does
00014 
00015 */
00016 
00017 class eZWizardBaseClassLoader
00018 {
00019     /*!
00020      \static
00021      Create new specified class
00022     */
00023     static function createClass( $tpl,
00024                                  $module,
00025                                  $stepArray,
00026                                  $basePath,
00027                                  $storageName = false,
00028                                  $metaData = false )
00029     {
00030         if ( !$storageName )
00031         {
00032             $storageName = 'eZWizard';
00033         }
00034 
00035         if ( !$metaData )
00036         {
00037             $http = eZHTTPTool::instance();
00038             $metaData = $http->sessionVariable( $storageName . '_meta' );
00039         }
00040 
00041         if ( !isset( $metaData['current_step'] ) ||
00042              $metaData['current_step'] < 0 )
00043         {
00044             $metaData['current_step'] = 0;
00045             eZDebug::writeNotice( 'Setting wizard step to : ' . $metaData['current_step'], __METHOD__ );
00046         }
00047         $currentStep = $metaData['current_step'];
00048 
00049         if ( count( $stepArray ) <= $currentStep )
00050         {
00051             eZDebug::writeError( 'Invalid wizard step count: ' . $currentStep, __METHOD__ );
00052             return false;
00053         }
00054 
00055         $filePath = $basePath . $stepArray[$currentStep]['file'];
00056         if ( !file_exists( $filePath ) )
00057         {
00058             eZDebug::writeError( 'Wizard file not found : ' . $filePath, __METHOD__ );
00059             return false;
00060         }
00061 
00062         include_once( $filePath );
00063 
00064         $className = $stepArray[$currentStep]['class'];
00065         eZDebug::writeNotice( 'Creating class : ' . $className, __METHOD__ );
00066         $returnClass =  new $className( $tpl, $module, $storageName );
00067 
00068         if ( isset( $stepArray[$currentStep]['operation'] ) )
00069         {
00070             $operation = $stepArray[$currentStep]['operation'];
00071             return $returnClass->$operation();
00072             eZDebug::writeNotice( 'Running : "' . $className . '->' . $operation . '()". Specified in StepArray', __METHOD__ );
00073         }
00074 
00075         if ( isset( $metaData['current_stage'] ) )
00076         {
00077             $returnClass->setMetaData( 'current_stage', $metaData['current_stage'] );
00078             eZDebug::writeNotice( 'Setting wizard stage to : ' . $metaData['current_stage'], __METHOD__ );
00079         }
00080 
00081         return $returnClass;
00082     }
00083 }
00084 
00085 ?>