本文整理汇总了PHP中Errors类的典型用法代码示例。如果您正苦于以下问题:PHP Errors类的具体用法?PHP Errors怎么用?PHP Errors使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Errors类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: error
function error()
{
require 'controllers/error.php';
$controller = new Errors();
$controller->index();
return false;
}
示例2: addErrorObject
/**
* Add errors from Errors object
* @param Errors $object
* @param bool $saveKey
* @return $this
*/
public function addErrorObject(Errors $object, $saveKey = false)
{
$errors = $object->getErrors(true);
foreach ($errors as $key => $error) {
$this->addError($error['name'], $saveKey ? $key : '', $error['data']);
}
return $this;
}
示例3: testWithInvalidReservedDiapason
/**
* Test for invalid reserved codes
*
* @expectedException \RuntimeException
* @expectedExceptionMessage The reserved codes for factory "FivePercent\Component\Error\ThirdErrorFactoryWithInvalidReservedDiapason" [15 - 30] superimposed on "FivePercent\Component\Error\SecondErrorFactory" factory [10 - 19].
*/
public function testWithInvalidReservedDiapason()
{
$errors = new Errors();
$errors->addFactory(new FirstErrorFactory());
$errors->addFactory(new SecondErrorFactory());
$errors->addFactory(new ThirdErrorFactoryWithInvalidReservedDiapason());
$errors->checkReservedCodes();
}
示例4: __construct
/**
* Constructs a validation exception
*
* @param Errors $errors The validation errors
*/
public function __construct(Errors $errors)
{
$this->errors = $errors;
if (!$errors->hasErrors()) {
parent::__construct('No errors');
} else {
parent::__construct($errors->toString());
}
}
示例5: colSelect
/**
* 带有col布局的select (后台使用).
*
* @param string $name 表单name
* @param array $list 值列表 (值 => 标签)
* @param Errors $errors 错误对象
* @param string $label label
* @param mixed $value 默认值
* @param array $options 其他附属参数
*/
public function colSelect($name, $list = array(), $errors, $label = '', $selected = null, $options = [])
{
$attributes = array_merge(['class' => 'form-control'], $options);
$hasError = $errors->has($name) ? 'has-error' : '';
$label = $label ? $this->label($name, $label, ['class' => 'col-sm-2 control-label']) : '';
$string = '<div class ="form-group ' . $hasError . '">';
$string .= $label;
$string .= '<div class="col-sm-6">';
$string .= call_user_func_array(['Form', 'select'], [$name, $list, $selected, $attributes]);
$string .= $errors->first($name, '<small class="help-block">:message</small>');
$string .= '</div></div>';
return $string;
}
示例6: __call
/**
* Ставим хук на вызов неизвестного метода
* @param string [component|module]_[method]
* @param array $aArgs
* @return unknown
*/
public function __call($sName, $aArgs = array())
{
//Ищем среди прикрепленный компонентов
if ($this->_c !== null) {
$aArgsRef = array();
foreach ($aArgs as $key => $v) {
$aArgsRef[] =& $aArgs[$key];
}
//$sName == [component name]_[method name]
$aName = explode("_", $sName, 2);
if (sizeof($aName) == 2) {
$sComponent = mb_strtolower($aName[0]);
$sMethod = $aName[1];
if (!empty($sMethod) && isset($this->_c[$sComponent])) {
if (method_exists($this->_c[$sComponent], $sMethod)) {
return call_user_func_array(array($this->_c[$sComponent], $sMethod), $aArgsRef);
}
Errors::i()->set("Компонент не имеет требуемого метода <b>{$sComponent}" . '->' . $sMethod . '()</b>')->autohide(false);
return null;
}
}
//$sName == [method name]
foreach ($this->_c as $name => $component) {
if (method_exists($component, $sName)) {
return call_user_func_array(array($component, $sName), $aArgsRef);
}
}
}
return null;
}
示例7: process_single
/**
* Process a single feed
*
* @param array $feed Feed information (required elements are 'name' for error reporting, 'feed' for the feed URL and 'id' for the feed's unique internal ID)
* @return int Number of items added
*/
public static function process_single($feed)
{
do_action('iu-feed-start', $feed);
$sp =& self::load_feed($feed);
if ($error = $sp->error()) {
self::log(sprintf(_r('An error occurred with "%2$s": %1$s'), $error, $feed['name']), Errors::get_code('api.itemupdater.itemerror'));
do_action('iu-feed-finish', $feed);
return -1;
}
$count = 0;
$items = $sp->get_items();
foreach ($items as $item) {
$new_item = self::normalise($item, $feed['id']);
$new_item = apply_filters('item_data_precache', $new_item, $feed);
if (Items::get_instance()->check_item($new_item)) {
$count++;
do_action('iu-item-add', $new_item, $feed);
} else {
do_action('iu-item-noadd', $new_item, $feed);
}
}
$sp->__destruct();
unset($sp);
do_action('iu-feed-finish', $feed);
return $count;
}
示例8: _sortArgs
/**
* Sort parameters by order specified in method declaration
*
* Takes a callback and a list of available params, then filters and sorts
* by the parameters the method actually needs, using the reflection APIs
*
* @author Morten Fangel <fangel@sevengoslings.net>
* @param callback $callback
* @param array $params
* @return array
*/
protected function _sortArgs($callback, $params)
{
// Takes a callback and a list or params and filter and
// sort the list by the parameters the method actually needs
if (is_array($callback)) {
$ref_func = new ReflectionMethod($callback[0], $callback[1]);
} else {
$ref_func = new ReflectionFunction($callback);
}
// Create a reflection on the method
$ref_parameters = $ref_func->getParameters();
// finds the parameters needed for the function via Reflections
$ordered_parameters = array();
foreach ($ref_parameters as $ref_parameter) {
// Run through all the parameters we need
if (isset($params[$ref_parameter->getName()])) {
// We have this parameters in the list to choose from
$ordered_parameters[] = $params[$ref_parameter->getName()];
} elseif ($ref_parameter->isDefaultValueAvailable()) {
// We don't have this parameter, but it's optional
$ordered_parameters[] = $ref_parameter->getDefaultValue();
} else {
// We don't have this parameter and it wasn't optional, abort!
throw new Exception('Missing parameter ' . $ref_parameter->getName() . '', Errors::get_code('admin.ajax.missing_param'));
$ordered_parameters[] = null;
}
}
return $ordered_parameters;
}
示例9: post
public function post($request)
{
// to Receive POST Params (use $this->params)
parent::post($request);
$folderID = $this->getParam('folderID');
$msgID = $this->getParam('msgID');
$attachmentID = $this->getParam('attachmentID');
if ($this->isLoggedIn()) {
if ($folderID && $msgID && $attachmentID) {
$dir = PHPGW_INCLUDE_ROOT . "/expressoMail/inc";
if ($this->getExpressoVersion() != "2.2") {
$_GET['msgFolder'] = $folderID;
$_GET['msgNumber'] = $msgID;
$_GET['indexPart'] = $attachmentID;
include "{$dir}/get_archive.php";
} else {
$_GET['msg_folder'] = $folderID;
$_GET['msg_number'] = $msgID;
$_GET['msg_part'] = $attachmentID;
$_GET['idx_file'] = $this->getParam('attachmentIndex');
$_GET['newfilename'] = $this->getParam('attachmentName');
$_GET['encoding'] = $this->getParam('attachmentEncoding');
include "{$dir}/gotodownload.php";
}
// Dont modify header of Response Method to 'application/json'
$this->setCannotModifyHeader(true);
return $this->getResponse();
} else {
Errors::runException("MAIL_ATTACHMENT_NOT_FOUND");
}
}
}
示例10: setNewServer
public function setNewServer($host, $user, $password, $database, $faild = self::EXCEPTION_FAILD_MODE)
{
//$this->server=null;
//
if ($host == "" and $user == "" and $database == "") {
throw new DatabaseArgumentsException();
} else {
Database::$server = mysqli_connect($host, $user, $password, $database);
//
if (!Database::$server) {
if ($faild == 2 && Config::get('panel.configured')) {
throw new DatabaseConnectionException();
} else {
if ($faild == 1) {
\Errors::r_db();
}
}
}
//
mysqli_query(Database::$server, "SET NAMES " . Config::get("database.charset"));
//
Database::$serverData = ['host' => $host, "username" => $user, "password" => $password, "database" => $database];
//
//
return Database::$server;
}
}
示例11: process
public static function process()
{
header('Content-Type: text/plain; charset=utf-8');
require_once LILINA_INCPATH . '/contrib/simplepie.class.php';
$updated = false;
foreach (self::$feeds as $feed) {
do_action('iu-feed-start', $feed);
$sp = self::load_feed($feed);
if ($error = $sp->error()) {
self::log(sprintf(_r('An error occurred with "%2$s": %1$s'), $error, $feed['name']), Errors::get_code('api.itemupdater.itemerror'));
continue;
}
$count = 0;
$items = $sp->get_items();
foreach ($items as $item) {
$new_item = self::normalise($item, $feed['id']);
$new_item = apply_filters('item_data_precache', $new_item);
if (Items::get_instance()->check_item($new_item)) {
$count++;
$updated = true;
}
}
do_action('iu-feed-finish', $feed);
}
Items::get_instance()->sort_all();
if ($updated) {
Items::get_instance()->save_cache();
}
}
示例12: getInfo
/**
* Возвращаем данные столика
* @param $arData
* @return CDBResult|CIBlockResult|string
*/
function getInfo($tableID, $arData = false, $GetNext = false)
{
$arFilterTable = array("IBLOCK_ID" => IB_TABLE_ID, "PROPERTY_CLUB" => $this->clubID, "ID" => intval($tableID));
$arSelectTable = array("ID");
$arOrderTable = array();
$arOrder = is_array($arData["arSelect"]) ? array_merge($arData["arOrder"], $arOrderTable) : $arOrderTable;
$arGroupBy = is_array($arData["arGroupBy"]) ? array_merge($arData["arGroupBy"], array()) : false;
$arNavStartParams = is_array($arData["arGroupBy"]) ? array_merge($arData["arNavStartParams"], array()) : false;
$arSelect = is_array($arData["arSelect"]) ? array_merge($arData["arSelect"], $arSelectTable) : $arSelectTable;
$arFilter = is_array($arData["arFilter"]) ? array_merge($arData["arFilter"], $arFilterTable) : $arFilterTable;
$res = CIBlockElement::GetList($arOrder, $arFilter, $arGroupBy, $arNavStartParams, $arSelect);
if (!$res) {
return Errors::run("404");
}
$ob = $GetNext ? $res->GetNext() : $res->Fetch();
if (isset($ob["PREVIEW_PICTURE"])) {
$arFile = CFile::GetFileArray($ob["PREVIEW_PICTURE"]);
$ob["PREVIEW_PICTURE"] = $arFile["SRC"];
}
if (isset($ob["PROPERTY_PRICE_GROUP_VALUE"])) {
$res = CIBlockElement::GetList(array(), array("ID" => intval($ob["PROPERTY_PRICE_GROUP_VALUE"]), "IBLOCK_ID" => IB_PRICE_GROUP), false, false, array("NAME", "ID", "PROPERTY_PRICE"));
$ob["PROPERTY_PRICE_GROUP"] = $res->Fetch();
}
return $ob;
}
示例13: post
public function post($request)
{
// to Receive POST Params (use $this->params)
parent::post($request);
if ($this->isLoggedIn()) {
$old_id = $this->getParam('folderID');
$new_name = $this->getParam('folderName');
if (!$this->getImap()->folder_exists($old_id)) {
Errors::runException("MAIL_INVALID_OLD_FOLDER");
}
$default_folders = array_keys($this->defaultFolders);
if (in_array($old_id, $default_folders)) {
Errors::runException("MAIL_INVALID_OLD_FOLDER");
}
if (empty($new_name) || preg_match('/[\\/\\\\!\\@\\#\\$\\%\\&\\*\\(\\)]/', $new_name)) {
Errors::runException("MAIL_INVALID_NEW_FOLDER_NAME");
}
$old_id_arr = explode($this->getImap()->imap_delimiter, $old_id);
$new_id = implode($this->getImap()->imap_delimiter, array_slice($old_id_arr, 0, count($old_id_arr) - 1)) . $this->getImap()->imap_delimiter . $new_name;
$params['current'] = $old_id;
$params['rename'] = $new_id;
$result = $this->getImap()->ren_mailbox($params);
if ($result != 'Ok') {
Errors::runException("MAIL_FOLDER_NOT_RENAMED");
}
}
$this->setResult(array('folderID' => $new_id));
//to Send Response (JSON RPC format)
return $this->getResponse();
}
示例14: addError
public function addError($errorCode, array $params = [], $subReports = null, $schemaDescription = null)
{
$errorMessage = vsprintf(Errors::getMessage($errorCode), $params);
$error = ['code' => $errorCode, 'params' => $params, 'message' => $errorMessage, 'path' => $this->getPath()];
if ($schemaDescription !== null) {
if (is_object($schemaDescription)) {
if (isset($schemaDescription->description)) {
$error['description'] = $schemaDescription->description;
} else {
if (isset($schemaDescription->id)) {
$error['description'] = $schemaDescription->id;
}
}
} else {
if (is_string($schemaDescription)) {
$error['description'] = $schemaDescription;
}
}
}
if ($subReports !== null) {
if (!is_array($subReports)) {
$subReports = [$subReports];
}
$error['inner'] = [];
foreach ($subReports as $subReport) {
foreach ($subReport->errors as $subError) {
$error['inner'][] = $subError;
}
}
if (empty($error['inner'])) {
unset($error['inner']);
}
}
$this->errors[] = $error;
}
示例15: post
public function post($request)
{
// to Receive POST Params (use $this->params)
parent::post($request);
if ($this->isLoggedIn()) {
$msgBody = $this->getParam("message");
$params['input_to'] = $GLOBALS['phpgw_info']['server']['sugestoes_email_to'];
$params['input_cc'] = $GLOBALS['phpgw_info']['server']['sugestoes_email_cc'];
$params['input_cc'] = $GLOBALS['phpgw_info']['server']['sugestoes_email_bcc'];
$params['input_subject'] = lang("Suggestions");
$params['body'] = $msgBody;
$params['type'] = 'textplain';
$GLOBALS['phpgw']->preferences->read_repository();
$_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user'];
$boemailadmin = CreateObject('emailadmin.bo');
$emailadmin_profile = $boemailadmin->getProfileList();
$_SESSION['phpgw_info']['expressomail']['email_server'] = $boemailadmin->getProfile($emailadmin_profile[0]['profileID']);
$_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server'];
$_SESSION['phpgw_info']['expressomail']['user']['email'] = $GLOBALS['phpgw']->preferences->values['email'];
$expressoMail = CreateObject('expressoMail.imap_functions');
$returncode = $expressoMail->send_mail($params);
if (!$returncode || !(is_array($returncode) && $returncode['success'] == true)) {
Errors::runException("MAIL_NOT_SENT");
}
}
$this->setResult(true);
//to Send Response (JSON RPC format)
return $this->getResponse();
}