コード例 #1
0
ファイル: Factory.php プロジェクト: villos/tree_admin
 /**
  *  Create a new object of the appropriate OA_Admin_Statistics_Common subclass.
  *
  * @static
  * @param string $controllerType The controller type (e.g. "global-advertiser").
  * @param array  $aParams        An array of parameters to be passed as the parameter
  *                               to the constructor of the class instantiated.
  * @return OA_Admin_Statistics_Common The instantiated class that inherits from
  *                                    OA_Admin_Statistics_Common.
  */
 function &getController($controllerType = '', $aParams = null)
 {
     // Instantiate & return the required statistics class
     $result = OA_Admin_Statistics_Factory::_getControllerClass($controllerType, $aParams, $class, $file);
     if (PEAR::isError($result)) {
         return $result;
     }
     // To allow catch errors and pass it out without calling error handler
     PEAR::pushErrorHandling(null);
     $oStatsController = OA_Admin_Statistics_Factory::_instantiateController($file, $class, $aParams);
     PEAR::popErrorHandling();
     return $oStatsController;
 }
コード例 #2
0
 function test_getControllerClass()
 {
     $expectPath = '/Statistics/Delivery/Controller/';
     foreach ($this->testTypesDelivery as $controllerType => $expectedClassName) {
         $aType = explode('-', $controllerType);
         $expectFile = '';
         foreach ($aType as $string) {
             $expectFile .= ucfirst($string);
         }
         OA_Admin_Statistics_Factory::_getControllerClass($controllerType, null, $class, $file);
         $this->assertEqual($class, $expectedClassName);
         $this->assertPattern("(\\/Statistics\\/Delivery\\/Controller\\/{$expectFile}\\.php)", $file);
     }
 }