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


PHP Zend::registry方法代码示例

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


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

示例1: regformAction

 public function regformAction()
 {
     // show reg form
     $view = Zend::registry("view");
     $view->title = "User Registration";
     print $view->render('user/regform.php');
 }
开发者ID:BackupTheBerlios,项目名称:agileweb,代码行数:7,代码来源:UserController.php

示例2: __construct

 function __construct($config = array())
 {
     // set a Zend_Db_Adapter connection
     if (!empty($config['db'])) {
         // convenience variable
         $db = $config['db'];
         // use an object from the registry?
         if (is_string($db)) {
             $db = Zend::registry($db);
         }
         // make sure it's a Zend_Db_Adapter
         if (!$db instanceof Zend_Db_Adapter_Abstract) {
             throw new Varien_Db_Tree_Exception('db object does not implement Zend_Db_Adapter_Abstract');
         }
         // save the connection
         $this->_db = $db;
         $conn = $this->_db->getConnection();
         if ($conn instanceof PDO) {
             $conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
         } elseif ($conn instanceof mysqli) {
             //TODO: ???
         }
     } else {
         throw new Varien_Db_Tree_Exception('db object is not set in config');
     }
     if (!empty($config['table'])) {
         $this->setTable($config['table']);
     }
     if (!empty($config['id'])) {
         $this->setIdField($config['id']);
     } else {
         $this->setIdField('id');
     }
     if (!empty($config['left'])) {
         $this->setLeftField($config['left']);
     } else {
         $this->setLeftField('left_key');
     }
     if (!empty($config['right'])) {
         $this->setRightField($config['right']);
     } else {
         $this->setRightField('right_key');
     }
     if (!empty($config['level'])) {
         $this->setLevelField($config['level']);
     } else {
         $this->setLevelField('level');
     }
     if (!empty($config['pid'])) {
         $this->setPidField($config['pid']);
     } else {
         $this->setPidField('parent_id');
     }
 }
开发者ID:chucky515,项目名称:Magento-CE-Mirror,代码行数:54,代码来源:Tree.php

示例3: routeShutdown

 public function routeShutdown($action)
 {
     $user = Zend::registry('user');
     if ($user->getPermission($action->getControllerName(), $action->getActionName())) {
         return $action;
     } else {
         $action->setControllerName('index');
         $action->setActionName('unauthorized');
         return $action;
     }
 }
开发者ID:BackupTheBerlios,项目名称:umlrecord,代码行数:11,代码来源:First.php

示例4: __construct

 /**
  * @param array $config
  * @throws LocalizedException
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function __construct($config = [])
 {
     // set a \Zend_Db_Adapter connection
     if (!empty($config['db'])) {
         // convenience variable
         $connection = $config['db'];
         // use an object from the registry?
         if (is_string($connection)) {
             $connection = \Zend::registry($connection);
         }
         // make sure it's a \Zend_Db_Adapter
         if (!$connection instanceof \Zend_Db_Adapter_Abstract) {
             throw new LocalizedException(new \Magento\Framework\Phrase('db object does not implement \\Zend_Db_Adapter_Abstract'));
         }
         // save the connection
         $this->_db = $connection;
         $conn = $this->_db->getConnection();
         if ($conn instanceof \PDO) {
             $conn->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true);
         }
     } else {
         throw new LocalizedException(new \Magento\Framework\Phrase('db object is not set in config'));
     }
     if (!empty($config['table'])) {
         $this->setTable($config['table']);
     }
     if (!empty($config['id'])) {
         $this->setIdField($config['id']);
     } else {
         $this->setIdField('id');
     }
     if (!empty($config['left'])) {
         $this->setLeftField($config['left']);
     } else {
         $this->setLeftField('left_key');
     }
     if (!empty($config['right'])) {
         $this->setRightField($config['right']);
     } else {
         $this->setRightField('right_key');
     }
     if (!empty($config['level'])) {
         $this->setLevelField($config['level']);
     } else {
         $this->setLevelField('level');
     }
     if (!empty($config['pid'])) {
         $this->setPidField($config['pid']);
     } else {
         $this->setPidField('parent_id');
     }
 }
开发者ID:vasiljok,项目名称:magento2,代码行数:58,代码来源:Tree.php

示例5: nowaAction

 /**
  * Tworzy now� ankiet� i przekierowuje do akcji edytujAction
  */
 public function nowaAction()
 {
     $post = new Zend_Filter_Input($_POST);
     $user = Zend::registry('user');
     $poll = new Ankiety();
     $data = array('nazwa' => $post->getRaw('ankieta_nazwa'), 'opis' => $post->getRaw('ankieta_opis'), 'id_uzytkownik' => 1);
     try {
         $id = $poll->insert($data);
         $this->_forward('ankieter', 'edytuj', array('ankieta' => $id));
     } catch (Hamster_Validation_Exception $e) {
         $this->_forward('ankieter', 'index', array('validationError' => $e->getMessage()));
     }
 }
开发者ID:BackupTheBerlios,项目名称:phppool,代码行数:16,代码来源:AnkieterController.php

示例6: __construct

 /**
  * Constructor.
  *
  * @param array $config Array of user-specified config options.
  */
 public function __construct($config = null)
 {
     // set a custom Zend_Db_Adapter connection
     if (!empty($config['db'])) {
         // convenience variable
         $db = $config['db'];
         // use an object from the registry?
         if (is_string($db)) {
             $db = Zend::registry($db);
         }
         // make sure it's a Zend_Db_Adapter
         if (!$db instanceof Zend_Db_Adapter_Abstract) {
             throw new Zend_Db_Table_Exception('db object does not implement Zend_Db_Adapter_Abstract');
         }
         // save the connection
         $this->_db = $db;
     }
     // set the inflector
     self::$_inflector = new Zend_Db_Inflector();
     // continue with automated setup
     $this->_setup();
 }
开发者ID:BackupTheBerlios,项目名称:openpublisher-svn,代码行数:27,代码来源:Table.php

示例7: 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

示例8: logoutAction

 public function logoutAction()
 {
     $user = Zend::registry('user');
     $user->logout();
     $this->_redirect('/index/index');
 }
开发者ID:BackupTheBerlios,项目名称:phppool,代码行数:6,代码来源:IndexController.php

示例9: __construct

 public function __construct()
 {
     $this->db = Zend::registry('db');
 }
开发者ID:BackupTheBerlios,项目名称:phppool,代码行数:4,代码来源:Raporty.php

示例10:

<div id="bluebox">
	<div id="bluebox_body">
	
	<?php 
$user = Zend::registry('user');
if ($user->getUserId() == 0) {
    ?>
	<form action="/index/login" method="post">
	<label for="input_login">LOGIN</label>
	<div>
	<input type="text" class="input_classic" id="input_login" name="input_login">
	</div>
	<label for="input_haslo">HASŁO</label>
	<div>
	<input type="text" class="input_classic" id="input_haslo" name="input_haslo">
	</div>
	<input type="submit" value="zaloguj się" id="input_submit">
	</form>
	<?php 
} else {
    echo 'Zalogowany jako <b>' . $user->getLogin() . '</b> ';
    echo '<a href="/index/logout">wygoluj się</a>';
}
?>
	
	
	
	</div>
	<div id="bluebox_bottom"></div>
</div>
开发者ID:BackupTheBerlios,项目名称:phppool,代码行数:30,代码来源:login.php

示例11: deleteRecord

 /**
  * Delete this record and delete its duration from the task
  * TODO: Remove once this is ported!
  */
 public function deleteRecord()
 {
     $user = za()->getUser();
     $db = Zend::registry('DbService');
     $taskId = $this->taskid;
     $select = $db->select();
     $select->from('task', '*')->where('id = ?', $taskId);
     $task = $db->getObject($select, 'task');
     if ($task == null) {
         throw new Exception("Task ID " . $taskId . " does not exist");
     }
     $toDelete = $this->endtime - $this->starttime;
     try {
         $db->delete($this, 'id=' . $this->id);
         // Get the total time for this task. $select = $db->select();
         $select = $db->select();
         $select->from('timesheetrecord', new Zend_Db_Expr('SUM(endtime - starttime) AS tasktime'))->where('taskid = ?', $taskId);
         $row = $db->fetchAll($select);
         $total = $row[0]['tasktime'];
         if ($total > 0) {
             // hours = timespent / 3600
             $task->timespent = $task->timespent - $toDelete;
             $task->save();
         }
     } catch (Exception $e) {
         $this->log->err($e->getTraceAsString());
         throw $e;
     }
 }
开发者ID:nyeholt,项目名称:relapse,代码行数:33,代码来源:TimesheetRecord.php

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