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


PHP Zend::exception方法代码示例

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


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

示例1: staticAuthenticate

 /**
  * Authenticates against the given parameters
  *
  * $options requires the following key-value pairs:
  *
  *      'filename' => path to digest authentication file
  *      'realm'    => digest authentication realm
  *      'username' => digest authentication user
  *      'password' => password for the user of the realm
  *
  * @param  array $options
  * @throws Zend_Auth_Digest_Exception
  * @return Zend_Auth_Digest_Token
  */
 public static function staticAuthenticate(array $options)
 {
     $optionsRequired = array('filename', 'realm', 'username', 'password');
     foreach ($optionsRequired as $optionRequired) {
         if (!isset($options[$optionRequired]) || !is_string($options[$optionRequired])) {
             throw Zend::exception('Zend_Auth_Digest_Exception', "Option '{$optionRequired}' is required to be " . 'provided as a string');
         }
     }
     if (false === ($fileHandle = @fopen($options['filename'], 'r'))) {
         throw Zend::exception('Zend_Auth_Digest_Exception', "Cannot open '{$options['filename']}' for reading");
     }
     require_once 'Zend/Auth/Digest/Token.php';
     $id = "{$options['username']}:{$options['realm']}";
     $idLength = strlen($id);
     $tokenValid = false;
     $tokenIdentity = array('realm' => $options['realm'], 'username' => $options['username']);
     while ($line = trim(fgets($fileHandle))) {
         if (substr($line, 0, $idLength) === $id) {
             if (substr($line, -32) === md5("{$options['username']}:{$options['realm']}:{$options['password']}")) {
                 $tokenValid = true;
                 $tokenMessage = null;
             } else {
                 $tokenMessage = 'Password incorrect';
             }
             return new Zend_Auth_Digest_Token($tokenValid, $tokenIdentity, $tokenMessage);
         }
     }
     $tokenMessage = "Username '{$options['username']}' and realm '{$options['realm']}' combination not found";
     return new Zend_Auth_Digest_Token($tokenValid, $tokenIdentity, $tokenMessage);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:44,代码来源:Adapter.php

示例2: _disconnect

 /**
  * Disconnects from the peer, closes the socket.
  * 
  * @return void
  */
 protected function _disconnect()
 {
     if (!is_resource($this->_socket)) {
         throw Zend::exception('Zend_TimeSync_ProtocolException', "could not close server connection from '{$this->_timeserver}' on port '{$this->_port}'");
     }
     @fclose($this->_socket);
     $this->_socket = null;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:13,代码来源:Protocol.php

示例3: __set

 /**
  * @param string $var
  * @param string $value
  */
 protected function __set($var, $value)
 {
     switch ($var) {
         case 'updatedMin':
         case 'updatedMax':
             throw Zend::exception('Zend_Gdata_Exception', "Parameter '{$var}' is not currently supported in Spreadsheets.");
             break;
     }
     parent::__set($var, $value);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:14,代码来源:Spreadsheets.php

示例4: testException

 public function testException()
 {
     $this->assertTrue(Zend::exception('Zend_Exception') instanceof Exception);
     try {
         $e = Zend::exception('Zend_FooBar_Baz', 'should fail');
         $this->fail('invalid exception class should throw exception');
     } catch (Exception $e) {
         // success...
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:10,代码来源:ZendTest.php

示例5: setTimestamp

 /**
  * Sets a new timestamp
  *
  * @param $date mixed - OPTIONAL timestamp otherwise actual timestamp is used
  * @return boolean
  * @throws Zend_Date_Exception
  */
 public function setTimestamp($date = false)
 {
     // no date value, take actual time
     if ($date === false) {
         $this->_unixtimestamp = time();
         return true;
     }
     if (is_numeric($date)) {
         $this->_unixtimestamp = $date;
         return true;
     }
     throw Zend::exception('Zend_Date_Exception', '\'' . $date . '\' is no valid date');
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:20,代码来源:DateObject.php

示例6: __construct

 /**
  * Create instance with parameters
  * Disallowed parameters are:
  *   - filename use Zend_Mail_Mbox for a single file
  * Supported parameters are:
  *   - rootdir rootdir of mbox structure
  *   - folder intial selected folder, default is 'INBOX'
  *
  * @param  $params              array mail reader specific parameters
  * @throws Zend_Mail_Exception
  */
 public function __construct($params)
 {
     if (isset($params['filename'])) {
         throw Zend::exception('Zend_Mail_Exception', 'use Zend_Mail_Mbox for a single file');
     }
     if (!isset($params['rootdir']) || !is_dir($params['rootdir'])) {
         throw Zend::exception('Zend_Mail_Exception', 'no valid rootdir given in params');
     }
     $this->_rootdir = rtrim($params['rootdir'], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
     $this->_buildFolderTree($this->_rootdir);
     $this->selectFolder(!empty($params['folder']) ? $params['folder'] : 'INBOX');
     $this->_has['top'] = true;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:24,代码来源:Mbox.php

示例7: __construct

 /**
  * Create instance with parameters
  * Supported parameters are:
  *   - rootdir rootdir of maildir structure
  *   - dirname alias for rootdir
  *   - delim   delim char for folder structur, default is '.'
  *   - folder intial selected folder, default is 'INBOX'
  *
  * @param  $params              array mail reader specific parameters
  * @throws Zend_Mail_Exception
  */
 public function __construct($params)
 {
     if (isset($params['dirname']) && !isset($params['rootdir'])) {
         $params['rootdir'] = $params['dirname'];
     }
     if (!isset($params['rootdir']) || !is_dir($params['rootdir'])) {
         throw Zend::exception('Zend_Mail_Exception', 'no valid rootdir given in params');
     }
     $this->_rootdir = rtrim($params['rootdir'], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
     $this->_delim = isset($params['delim']) ? $params['delim'] : '.';
     $this->_buildFolderTree();
     $this->selectFolder(!empty($params['folder']) ? $params['folder'] : 'INBOX');
     $this->_has['top'] = true;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:25,代码来源:Maildir.php

示例8: _query

 /**
  * Writes/receives data to/from the timeserver
  * 
  * @return int unix timestamp
  */
 protected function _query()
 {
     $this->_connect();
     $begin = time();
     fputs($this->_socket, "\n");
     $result = fread($this->_socket, 49);
     $end = time();
     $this->_disconnect();
     if (!$result) {
         throw Zend::exception('Zend_TimeSync_ProtocolException', 'invalid result returned from server');
     } else {
         $time = abs(hexdec('7fffffff') - hexdec(bin2hex($result)) - hexdec('7fffffff'));
         $time -= 2208988800;
         // socket delay
         $time -= ($end - $begin) / 2;
         return $time;
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:23,代码来源:Sntp.php

示例9: fetch

 /**
  * fetch one or more items of one or more messages
  *
  * @param string|array $items items to fetch from message(s) as string (if only one item)
  *                             or array of strings
  * @param int          $from  message for items or start message if $to !== null
  * @param int|null     $to    if null only one message ($from) is fetched, else it's the
  *                             last message, INF means last message avaible
  * @return string|array if only one item of one message is fetched it's returned as string
  *                      if items of one message are fetched it's returned as (name => value)
  *                      if one items of messages are fetched it's returned as (msgno => value)
  *                      if items of messages are fetchted it's returned as (msgno => (name => value))
  */
 public function fetch($items, $from, $to = null)
 {
     if ($to === null) {
         $set = (int) $from;
     } else {
         if (is_array($from)) {
             $set = implode(',', $from);
         } else {
             if ($to === INF) {
                 $set = (int) $from . ':*';
             } else {
                 $set = (int) $from . ':' . (int) $to;
             }
         }
     }
     $items = (array) $items;
     $itemList = $this->escapeList($items);
     $this->sendRequest('FETCH', array($set, $itemList), $tag);
     $result = array();
     while (!$this->readLine($tokens, $tag)) {
         if ($tokens[1] != 'FETCH') {
             continue;
         }
         if ($to === null && $tokens[0] != $from) {
             continue;
         }
         if (count($items) == 1) {
             $data = next($tokens[2]);
         } else {
             $data = array();
             while (key($tokens[2]) !== null) {
                 $data[current($tokens[2])] = next($tokens[2]);
                 next($tokens[2]);
             }
         }
         if ($to === null && $tokens[0] == $from) {
             return $data;
         }
         $result[$tokens[0]] = $data;
     }
     if ($to === null) {
         throw Zend::exception('Zend_Mail_Transport_Exception', 'the single id was not found in response');
     }
     return $result;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:58,代码来源:Imap.php

示例10: setType

 /**
  * Set a new type, and convert the value
  *
  * @param $type  new type to set
  * @throws Zend_Measure_Exception
  */
 public function setType($type)
 {
     if (empty(self::$_UNITS[$type])) {
         throw Zend::exception('Zend_Measure_Exception', 'unknown type of torque:' . $type);
     }
     // Convert to standard value
     $value = parent::getValue();
     if (is_array(self::$_UNITS[parent::getType()][0])) {
         foreach (self::$_UNITS[parent::getType()][0] as $key => $found) {
             switch ($key) {
                 case "/":
                     $value /= $found;
                     break;
                 default:
                     $value *= $found;
                     break;
             }
         }
     } else {
         $value = $value * self::$_UNITS[parent::getType()][0];
     }
     // Convert to expected value
     if (is_array(self::$_UNITS[$type][0])) {
         foreach (self::$_UNITS[$type][0] as $key => $found) {
             switch ($key) {
                 case "/":
                     $value *= $found;
                     break;
                 default:
                     $value /= $found;
                     break;
             }
         }
     } else {
         $value = $value / self::$_UNITS[$type][0];
     }
     parent::setValue($value, $type, $this->_Locale);
     parent::setType($type);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:45,代码来源:Torque.php

示例11: setType

 /**
  * Set a new type, and convert the value
  *
  * @throws Zend_Measure_Exception
  */
 public function setType($type)
 {
     if (empty(self::$_UNITS[$type])) {
         throw Zend::exception('Zend_Measure_Exception', 'unknown type of force:' . $type);
     }
     // Convert to standard value
     $value = parent::getValue();
     $value = $value * self::$_UNITS[parent::getType()][0];
     // Convert to expected value
     $value = $value / self::$_UNITS[$type][0];
     parent::setValue($value, $type, $this->_Locale);
     parent::setType($type);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:18,代码来源:Force.php

示例12: __construct

 /**
  *
  * create instance with parameters
  * Supported paramters are
  *   - host hostname or ip address of IMAP server
  *   - user username
  *   - password password for user 'username' [optional, default = '']
  *   - port port for IMAP server [optional, default = 110]
  *   - ssl 'SSL' or 'TLS' for secure sockets
  *   - folder select this folder [optional, default = 'INBOX']
  *
  * @param  $params array  mail reader specific parameters
  * @throws Zend_Mail_Exception
  */
 public function __construct($params)
 {
     if ($params instanceof Zend_Mail_Transport_Imap) {
         $this->_protocol = $params;
         $this->_currentFolder = 'INBOX';
         if (!$this->_protocol->select($this->_currentFolder)) {
             throw Zend::exception('Zend_Mail_Exception', 'cannot select INBOX, is this a valid transport?');
         }
         return;
     }
     if (!isset($params['host']) || !isset($params['user'])) {
         throw Zend::exception('Zend_Mail_Exception', 'need at least a host an user in params');
     }
     $params['password'] = isset($params['password']) ? $params['password'] : '';
     $params['port'] = isset($params['port']) ? $params['port'] : null;
     $params['ssl'] = isset($params['ssl']) ? $params['ssl'] : false;
     $this->_protocol = new Zend_Mail_Transport_Imap();
     $this->_protocol->connect($params['host'], $params['port'], $params['ssl']);
     if (!$this->_protocol->login($params['user'], $params['password'])) {
         throw Zend::exception('Zend_Mail_Exception', 'cannot login, user or password wrong');
     }
     $this->_currentFolder = isset($params['folder']) ? $params['folder'] : 'INBOX';
     if (!$this->_protocol->select($this->_currentFolder)) {
         throw Zend::exception('Zend_Mail_Exception', 'cannot change folder, maybe it does not exist');
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:40,代码来源:Imap.php

示例13: unregisterPlugin

 /**
  * Unregister a plugin.
  *
  * @param Zend_Controller_Plugin_Abstract $plugin
  * @return Zend_Controller_Plugin_Broker
  */
 public function unregisterPlugin(Zend_Controller_Plugin_Abstract $plugin)
 {
     $key = array_search($plugin, $this->_plugins, true);
     if (false === $key) {
         throw Zend::exception('Zend_Controller_Exception', 'Plugin never registered.');
     }
     unset($this->_plugins[$key]);
     return $this;
 }
开发者ID:BackupTheBerlios,项目名称:openpublisher-svn,代码行数:15,代码来源:Broker.php

示例14: _send

 /**
  * Send the given string followed by a LINEEND to the server
  *
  * @param string $str
  * @throws Zend_Mail_Transport_Exception
  */
 protected function _send($str)
 {
     $res = fwrite($this->_con, $str . $this->EOL);
     if ($res === false) {
         throw Zend::exception('Zend_Mail_Transport_Exception', 'Could not write to SMTP server');
     }
     if (self::DEBUG) {
         echo "S: {$str}<br>\n";
     }
 }
开发者ID:BackupTheBerlios,项目名称:openpublisher-svn,代码行数:16,代码来源:Smtp.php

示例15: removeMessage

 /**
  * stub for not supported message deletion
  */
 public function removeMessage($id)
 {
     throw Zend::exception('Zend_Mail_Exception', 'maildir is (currently) read-only');
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:7,代码来源:Maildir.php


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