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


PHP Zend::register方法代码示例

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


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

示例1: testRegistry

 /**
  * Tests that:
  *   1. an object can be registered with register().
  *   2. attempting to register the same object throws an exception.
  *   3. the object is returned by registry('objectName').
  *   4. the object is listed in the array returned by registry().
  */
 public function testRegistry()
 {
     /**
      * Register an object
      */
     $obj = new stdClass();
     // throws exception on failure
     Zend::register('objectName', $obj);
     /**
      * Attempt to register the same object again
      */
     $e = null;
     try {
         Zend::register('another', $obj);
     } catch (Zend_Exception $e) {
         $this->assertRegExp('/duplicate(.*)objectName/i', $e->getMessage());
     }
     if ($e === null) {
         $this->fail('No exception thown during registration of duplicate object.');
     }
     /**
      * Attempt to retrieve the object with registry()
      */
     $this->assertSame(Zend::registry('objectName'), $obj);
     /**
      * Check registry listing
      */
     $this->assertEquals(Zend::registry(), array('objectName' => 'stdClass'));
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:36,代码来源:ZendTest.php

示例2: dirname

<?php

require_once 'Zend/Controller/Front.php';
require_once 'Zend/View.php';
require_once dirname(__FILE__) . "/lib/plugins/UTF8Plugin.php";
require_once dirname(__FILE__) . "/lib/plugins/TestPlugin.php";
$front = Zend_Controller_Front::getInstance();
$front->setControllerDirectory('./app');
$front->registerPlugin(new UTF8Plugin());
$front->registerPlugin(new TestPlugin());
$view = new Zend_View();
$view->setScriptPath('./view');
Zend::register('view', $view);
$front->dispatch();
开发者ID:BackupTheBerlios,项目名称:agileweb,代码行数:14,代码来源:_common.php

示例3: testTableExceptionNoAdapter

 public function testTableExceptionNoAdapter()
 {
     Zend::loadClass('Zend_Db_Table_ZfTestTable');
     try {
         $dbTable = new Zend_Db_Table_ZfTestTable(array('db' => 327));
     } catch (Exception $e) {
         $this->assertThat($e, $this->isInstanceOf('Zend_Db_Table_Exception'), 'Expecting object of type Zend_Db_Table_Exception');
         $this->assertEquals($e->getMessage(), 'db object does not extend Zend_Db_Adapter_Abstract');
     }
     Zend::register('registered_db', 327);
     try {
         $dbTable = new Zend_Db_Table_ZfTestTable(array('db' => 'registered_db'));
     } catch (Exception $e) {
         $this->assertThat($e, $this->isInstanceOf('Zend_Db_Table_Exception'), 'Expecting object of type Zend_Db_Table_Exception');
         $this->assertEquals($e->getMessage(), 'db object does not extend Zend_Db_Adapter_Abstract');
     }
     try {
         Zend_Db_Table_ZfTestTable::setDefaultAdapter(327);
     } catch (Exception $e) {
         $this->assertThat($e, $this->isInstanceOf('Zend_Db_Table_Exception'), 'Expecting object of type Zend_Db_Table_Exception');
         $this->assertEquals($e->getMessage(), 'db object does not extend Zend_Db_Adapter_Abstract');
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:23,代码来源:Common.php

示例4: __autoload

<?php

/**
 * Bootstrap file
 */
//error_reporting(E_ALL|E_STRICT);
function __autoload($class)
{
    Zend::loadClass($class);
}
set_include_path('../lib' . PATH_SEPARATOR . '../app/models');
include 'Zend.php';
$params = array('host' => 'localhost', 'username' => 'root', 'password' => '', 'dbname' => 'uml');
$db = Zend_Db::factory('PDO_MYSQL', $params);
Zend_Db_Table::setDefaultAdapter($db);
Zend::register('db', $db);
$controller = Zend_Controller_Front::getInstance();
$controller->setControllerDirectory('../app/controllers');
//$controller->registerPlugin(new Hamster_Controller_Plugin_First());
$user = Hamster_Auth::getInstance();
Zend::register('user', $user);
$controller->dispatch();
开发者ID:BackupTheBerlios,项目名称:umlrecord,代码行数:22,代码来源:index.php

示例5: testRegistry

 /**
  * Tests that:
  *   1. an object can be registered with register().
  *   2. the object is returned by registry('objectName').
  *   3. the object is listed in the ArrayObject returned by registry().
  *   4. isRegistered() returns correct states.
  */
 public function testRegistry()
 {
     $registry = Zend::registry();
     $this->assertFalse($registry->offsetExists('objectName'));
     $subregistry = new Zend_Registry(array('option1' => 'setting1', 'option2' => 'setting2'));
     // throws exception on failure
     Zend::register('componentOptions', $subregistry);
     $this->assertTrue($registry->offsetExists('componentOptions'));
     // compare fetched value with the expected value
     $this->assertSame(Zend::registry('componentOptions'), $subregistry);
     $this->assertTrue($registry->offsetGet('componentOptions') == new Zend_Registry(array('option1' => 'setting1', 'option2' => 'setting2')));
     // Make sure a second object can be registered
     $object2 = new stdClass();
     $this->assertNotSame($subregistry, $object2);
     // throws exception on failure
     $registry->offsetSet('componentOptions', $object2);
     $this->assertTrue($registry->offsetExists('componentOptions'));
     $this->assertNotSame(Zend::registry('componentOptions'), $subregistry);
     $this->assertSame(Zend::registry('componentOptions'), $object2);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:27,代码来源:RegistryTest.php


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