当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend::loadClass方法代码示例

本文整理汇总了PHP中Zend::loadClass方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend::loadClass方法的具体用法?PHP Zend::loadClass怎么用?PHP Zend::loadClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend的用法示例。


在下文中一共展示了Zend::loadClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadTests

 /**
  * recurses through the Test subdir and includes classes in each test group subdir,
  * then builds an array of classnames for the tests that will be run
  *
  */
 public function loadTests($test_path = NULL)
 {
     $this->resetStats();
     if ($test_path === NULL) {
         // this seems hackey.  is it?  dunno.
         $test_path = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Security' . DIRECTORY_SEPARATOR . 'Test';
     }
     $test_root = dir($test_path);
     while (false !== ($entry = $test_root->read())) {
         if (is_dir($test_root->path . DIRECTORY_SEPARATOR . $entry) && !preg_match('|^\\.(.*)$|', $entry)) {
             $test_dirs[] = $entry;
         }
     }
     // include_once all files in each test dir
     foreach ($test_dirs as $test_dir) {
         $this_dir = dir($test_root->path . DIRECTORY_SEPARATOR . $test_dir);
         while (false !== ($entry = $this_dir->read())) {
             if (!is_dir($this_dir->path . DIRECTORY_SEPARATOR . $entry) && preg_match('/[A-Za-z]+\\.php/i', $entry)) {
                 $className = "Zend_Environment_Security_Test_" . $test_dir . "_" . basename($entry, '.php');
                 Zend::loadClass($className);
                 $classNames[] = $className;
             }
         }
     }
     $this->_tests_to_run = $classNames;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:31,代码来源:Security.php

示例2: addAdvancedRoute

 public function addAdvancedRoute($name, $map, $params = array(), $reqs = array())
 {
     if (!class_exists('Custom_Controller_Router_AdvancedRoute')) {
         Zend::loadClass('Custom_Controller_Router_AdvancedRoute');
     }
     $this->_routes[$name] = new Custom_Controller_Router_AdvancedRoute($map, $params, $reqs);
 }
开发者ID:Tony133,项目名称:zf-web,代码行数:7,代码来源:RewriteRouter.php

示例3: autoload

 public static function autoload($class)
 {
     try {
         Zend::loadClass($class);
     } catch (Zend_Exception $e) {
         return false;
     }
     return true;
 }
开发者ID:DBezemer,项目名称:server,代码行数:9,代码来源:sfZendFrameworkBridge.class.php

示例4: testLoadClassIllegalFilename

 /**
  * Tests that the security filter catches directory injections.
  */
 public function testLoadClassIllegalFilename()
 {
     try {
         Zend::loadClass('/path/to/danger');
     } catch (Zend_Exception $e) {
         $this->assertRegExp('/security(.*)filename/i', $e->getMessage());
         return;
     }
     $this->assertFail('Zend_Exception was expected but never thrown.');
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:13,代码来源:ZendTest.php

示例5: getDriver

 public function getDriver()
 {
     // @todo: when the Mysqli adapter moves out of the incubator,
     // the following trick to allow it to be loaded should be removed.
     $incubator = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . DIRECTORY_SEPARATOR . 'incubator' . DIRECTORY_SEPARATOR . 'library';
     Zend::loadClass('Zend_Db_Adapter_Mysqli', $incubator);
     // @todo: also load any auxiliary classes if necessary, e.g.:
     // Zend_Db_Adapter_Mysqli_Exception
     // Zend_Db_Statement_Mysqli
     // Zend_Db_Statement_Mysqli_Exception
     return 'Mysqli';
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:12,代码来源:MysqliTest.php

示例6: autoload

 public static function autoload($class)
 {
     try {
         if (self::$withLoader) {
             Zend_Loader::loadClass($class);
         } else {
             Zend::loadClass($class);
         }
     } catch (Zend_Exception $e) {
         return false;
     }
     return true;
 }
开发者ID:JimmyVB,项目名称:Symfony-v1.2,代码行数:13,代码来源:sfZendFrameworkBridge.class.php

示例7: autoload

 public static function autoload($class)
 {
     try {
         if (class_exists('Zend_Version')) {
             Zend_Loader::loadClass($class);
         } else {
             Zend::loadClass($class);
         }
     } catch (Zend_Exception $e) {
         return false;
     }
     return true;
 }
开发者ID:taryono,项目名称:school,代码行数:13,代码来源:sfZendFrameworkBridge.class.php

示例8: setUp

 public function setUp()
 {
     if (!class_exists('Zend_Log') || !class_exists('Zend_Log_Adapter_Null')) {
         Zend::loadClass('Zend_Log');
         Zend::loadClass('Zend_Log_Adapter_Null');
     }
     if (!Zend_Log::hasLogger('LOG')) {
         Zend_Log::registerLogger(new Zend_Log_Adapter_Null(), 'LOG');
     }
     $this->_instance->setDirectives(array('logging' => true));
     $this->_instance->save('bar : data to cache', 'bar', array('tag3', 'tag4'));
     $this->_instance->save('bar2 : data to cache', 'bar2', array('tag3', 'tag1'));
     $this->_instance->save('bar3 : data to cache', 'bar3', array('tag2', 'tag3'));
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:14,代码来源:CommonBackendTest.php

示例9: Primitus_View_Plugin_Render

/**
 * The Primitus View plugin is a procedural function which implements the logic of
 * the template-level {render} function. It is responsible for either calling the
 * requested controller's render() method to get the template, or simply processing
 * the template in the views/ directory if the controller didn't exist.
 * 
 * You can set template-level variables in the module being rendered by simply setting
 * them in the smarty {render} function. i.e.
 * 
 * {render module="blog" action="view" entry=$entry}
 * 
 * will expose the {$entry} template variable to the blog::view template in /blog/view.tpl
 * 
 * @category   Primitus
 * @package    Primitus
 * @subpackage View
 * @copyright  Copyright (c) 2006 John Coggeshall
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
function Primitus_View_Plugin_Render($params, &$smarty)
{
    if (!isset($params['module'])) {
        throw new Primitus_View_Exception("No module name was provided to render");
    }
    $module = $params['module'];
    if (strtolower(substr($module, strlen($module) - 10)) != "controller") {
        $module .= "Controller";
    }
    $action = isset($params['action']) ? $params['action'] : "indexAction";
    $dispatcher = Primitus::registry('Dispatcher');
    $controllerFile = $dispatcher->formatControllerFile($module);
    if (file_exists($controllerFile)) {
        // Load the Class
        Zend::loadClass($module, $dispatcher->getControllerDirectory());
        $controller = new $module();
        if ($controller instanceof Primitus_Controller_Action_Base) {
            unset($params['module']);
            unset($params['action']);
            if (!empty($params)) {
                $view = Primitus_View::getInstance($module);
                foreach ($params as $key => $value) {
                    $view->assign($key, $value);
                }
            }
            return $controller->render($action);
        } else {
            throw new Primitus_View_Exception("Bad Request");
        }
    } else {
        $view = Primitus_View::getInstance($module);
        unset($params['module']);
        unset($params['action']);
        if (!empty($params)) {
            $view = Primitus_View::getInstance($module);
            foreach ($params as $key => $value) {
                $view->assign($key, $value);
            }
        }
        return $view->render($action);
    }
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:61,代码来源:Render.php

示例10: __autoload

 /**
  * load class
  * @param string $className : the class to load
  * @throws Exception
  */
 function __autoload($className)
 {
     if (class_exists('Zend', false)) {
         if (is_int(strrpos($className, '_Interface'))) {
             Zend::loadClass($className);
         } else {
             Zend::loadInterface($className);
         }
     } else {
         if (!defined('__CLASS_PATH__')) {
             define('__CLASS_PATH__', realpath(dirname(__FILE__)));
         }
         $file = __CLASS_PATH__ . '/' . str_replace('_', '/', $className) . '.php';
         if (!file_exists($file)) {
             throw new Exception('Cannot load class file ' . $className);
         } else {
             require_once $file;
         }
     }
 }
开发者ID:ViniciusFelix,项目名称:ProjetoPadrao,代码行数:25,代码来源:Autoload.php

示例11: __construct

 /**
  * @param  array $modules
  * @param  array $config
  * @throws Zend_Environment_Exception
  * @return void
  */
 public function __construct($modules, $config = array())
 {
     if (is_array($config)) {
         if (isset($config['cache'])) {
             $this->_cache = $config['cache'];
         }
     }
     if (isset($this->_cache)) {
         if ($data = $this->_cache->load($this->_cachePrefix . 'module')) {
             $this->_data = unserialize($data);
             return;
         }
     }
     if ($modules === null) {
         $modules = array();
         $registry = new Zend_Environment_ModuleRegistry();
         foreach ($registry as $file) {
             $class = rtrim($file->getFilename(), '.php');
             $module = "Zend_Environment_Module_{$class}";
             Zend::loadClass($module);
             try {
                 $modules[] = new $module(strtolower($class));
             } catch (Zend_Environment_Exception $e) {
             }
         }
     } elseif (!is_array($modules)) {
         $modules = array($modules);
     }
     foreach ($modules as $instance) {
         if (!$instance instanceof Zend_Environment_Module_Interface) {
             throw new Zend_Environment_Exception("Module does not implement Zend_Environment_Module_Interface");
         }
         $this->_data[$instance->getId()] = $instance;
     }
     $this->_cache('module', serialize($this->_data));
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:42,代码来源:Environment.php

示例12: _dispatch

 /**
  * If $performDispatch is FALSE, this method will check if a controller
  * file exists.  This still doesn't necessarily mean that it can be dispatched
  * in the stricted sense, as file may not contain the controller class or the
  * controller may reject the action.
  *
  * If $performDispatch is TRUE, then this method will actually
  * instantiate the controller and call its action.  Calling the action
  * is done by passing a Zend_Controller_Dispatcher_Token to the controller's constructor.
  *
  * @param Zend_Controller_Dispatcher_Token $action
  * @param boolean $performDispatch
  * @return boolean|Zend_Controller_Dispatcher_Token
  */
 protected function _dispatch(Zend_Controller_Dispatcher_Token $action, $performDispatch)
 {
     if ($this->_directory === null) {
         throw new Zend_Controller_Dispatcher_Exception('Controller directory never set.  Use setControllerDirectory() first.');
     }
     $className = $this->formatControllerName($action->getControllerName());
     /**
      * If $performDispatch is FALSE, only determine if the controller file
      * can be accessed.
      */
     if (!$performDispatch) {
         return Zend::isReadable($this->_directory . DIRECTORY_SEPARATOR . $className . '.php');
     }
     Zend::loadClass($className, $this->_directory);
     $controller = new $className();
     if (!$controller instanceof Zend_Controller_Action) {
         throw new Zend_Controller_Dispatcher_Exception("Controller \"{$className}\" is not an instance of Zend_Controller_Action.");
     }
     /**
      * Dispatch
      *
      * Call the action of the Zend_Controller_Action.  It will return either null or a
      * new Zend_Controller_Dispatcher_Token object.  If a Zend_Controller_Dispatcher_Token object is returned, this will be returned
      * back to ZFrontController, which will call $this again to forward to
      * another action.
      */
     $nextAction = $controller->run($this, $action);
     // Destroy the page controller instance
     $controller = null;
     // Return either null (finished) or a Zend_Controller_Dispatcher_Token object (forward to another action).
     return $nextAction;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:46,代码来源:Dispatcher.php

示例13: remove

 /**
  * Removes the Role from the registry
  *
  * The $role parameter can either be a Role or a Role identifier.
  *
  * @param  Zend_Acl_Role_Interface|string $role
  * @throws Zend_Acl_Role_Registry_Exception
  * @return Zend_Acl_Role_Registry Provides a fluent interface
  */
 public function remove($role)
 {
     Zend::loadClass('Zend_Acl_Role_Registry_Exception');
     try {
         $roleId = $this->get($role)->getRoleId();
     } catch (Zend_Acl_Role_Registry_Exception $e) {
         throw $e;
     }
     foreach ($this->_roles[$roleId]['children'] as $childId => $child) {
         unset($this->_roles[$childId]['parents'][$roleId]);
     }
     foreach ($this->_roles[$roleId]['parents'] as $parentId => $parent) {
         unset($this->_roles[$parentId]['children'][$roleId]);
     }
     unset($this->_roles[$roleId]);
     return $this;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:26,代码来源:Registry.php

示例14: testTableInsert

 public function testTableInsert()
 {
     Zend::loadClass('Zend_Db_Table_ZfTestTable');
     $table = $this->getIdentifier(self::TABLE_NAME);
     $id = $this->getIdentifier('id');
     $tab1 = new Zend_Db_Table_ZfTestTable(array('db' => $this->_db, 'name' => $table, 'primary' => $id));
     $nextId = $this->_db->fetchOne("SELECT nextval('" . self::SEQUENCE_NAME . "')");
     $row = array('id' => $nextId, 'title' => 'News Item 3', 'subtitle' => 'Sub title 3', 'body' => 'This is body 1', 'date_created' => '2006-05-03 13:13:13');
     $insertResult = $tab1->insert($row);
     $last_insert_id = $this->_db->lastInsertId($table);
     $this->assertEquals($insertResult, (string) $last_insert_id);
     $this->assertEquals(3, (string) $last_insert_id);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:13,代码来源:PgsqlTest.php

示例15: dispatch

 /**
  * Dispatch an HTTP request to a controller/action.
  *
  * @param Zend_Controller_Request_Abstract|null $request
  * @param Zend_Controller_Response_Abstract|null $response
  * @return Zend_Controller_Response_Abstract
  */
 public function dispatch(Zend_Controller_Request_Abstract $request = null, Zend_Controller_Response_Abstract $response = null)
 {
     /**
      * Instantiate default request object (HTTP version) if none provided
      */
     if (null === $request && null === ($request = $this->getRequest())) {
         Zend::loadClass('Zend_Controller_Request_Http');
         $request = new Zend_Controller_Request_Http();
     }
     /**
      * Instantiate default response object (HTTP version) if none provided
      */
     if (null === $response && null === ($response = $this->getResponse())) {
         Zend::loadClass('Zend_Controller_Response_Http');
         $response = new Zend_Controller_Response_Http();
     }
     /**
      * Register request and response objects with plugin broker
      */
     $this->_plugins->setRequest($request)->setResponse($response);
     // Begin dispatch
     try {
         /**
          * Route request to controller/action, if a router is provided
          */
         if (null !== ($router = $this->getRouter())) {
             /**
              * Notify plugins of router startup
              */
             $this->_plugins->routeStartup($request);
             $router->setParams($this->getParams());
             $router->route($request);
             /**
              * Notify plugins of router completion
              */
             $this->_plugins->routeShutdown($request);
         }
         /**
          * Notify plugins of dispatch loop startup
          */
         $this->_plugins->dispatchLoopStartup($request);
         $dispatcher = $this->getDispatcher();
         $dispatcher->setParams($this->getParams());
         /**
          *  Attempt to dispatch the controller/action. If the $request
          *  indicates that it needs to be dispatched, move to the next
          *  action in the request.
          */
         do {
             $request->setDispatched(true);
             /**
              * Notify plugins of dispatch startup
              */
             $this->_plugins->preDispatch($request);
             /**
              * Skip requested action if preDispatch() has reset it
              */
             if (!$request->isDispatched()) {
                 continue;
             }
             /**
              * Dispatch request
              */
             $dispatcher->dispatch($request, $response);
             /**
              * Notify plugins of dispatch completion
              */
             $this->_plugins->postDispatch($request);
         } while (!$request->isDispatched());
         /**
          * Notify plugins of dispatch loop completion
          */
         $this->_plugins->dispatchLoopShutdown();
     } catch (Exception $e) {
         $response->setException($e);
     }
     return $response;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:85,代码来源:Front.php


注:本文中的Zend::loadClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。