本文整理汇总了PHP中Errors::getErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP Errors::getErrors方法的具体用法?PHP Errors::getErrors怎么用?PHP Errors::getErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Errors
的用法示例。
在下文中一共展示了Errors::getErrors方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: showResults
private function showResults()
{
if (Errors::hasErrors()) {
$this->response['status'] = FALSE;
$this->response['errors'] = Errors::getErrors();
unset($this->response['results']);
}
echo json_encode($this->response);
exit;
}
示例3: testWithOneFactory
/**
* Base testing
*/
public function testWithOneFactory()
{
$errors = new Errors();
$errors->addFactory(new FirstErrorFactory());
$errors->addFactory(new SecondErrorFactory());
$codes = $errors->getErrors();
$this->assertEquals([1 => 'Error #1', 2 => 'Error #2', 11 => 'Error #11', 12 => 'Error #12'], $codes);
$exceptions = $errors->getExceptions();
$this->assertEquals(['InvalidArgumentException' => 1, 'RuntimeException' => 2, 'LogicException' => 11], $exceptions);
// Success check reserved diapasons
$errors->checkReservedCodes();
// Success check has exception
$this->assertTrue($errors->hasException(new \RuntimeException()));
$this->assertFalse($errors->hasException(new \OutOfRangeException()));
// Success get code by exception
$this->assertEquals(11, $errors->getExceptionCode(new \LogicException()));
}
示例4: chain
/**
* Combines the errors from the Errors object passed into this object
*
* @param Errors $errors An errors object to combine with this.
*
* @return this updated with all errors from both objects
*/
public function chain(Errors $errors)
{
$this->addErrors($errors->getErrors());
return $this;
}
示例5: Errors
//Was the datafile fetched successfully
$errors = new Errors();
if ($res === -2) {
$errors->addError(new Error(2, sprintf($siteContext->getLocale('errDamagedDatasource'), $stier->getOption('name_of_service'))));
} elseif (!$res or $res === 0) {
$errors->addError(new Error(2, sprintf($siteContext->getLocale('errDatasourceInaccessible'), $stier->getOption('name_of_service'))));
}
if ($errors->isOccured()) {
require_once "lib/SiteGenerator/SiteGenerator.php";
require_once "lib/StatGenerator.php";
$sg = SiteGenerator::getGenerator($ind['type'], $siteContext);
$headline = $sg->newElement("headline");
$headline->setHeadline($siteContext->getLocale('errAnErrorOccured'));
$headline->setSize(1);
$sg->addElement($headline);
$errorList = $errors->getErrors();
foreach ($errorList as $error) {
$text = $sg->newElement("text");
$text->setText($error->getMessage());
$sg->addElement($text);
}
echo $sg->getSite();
exit;
}
//Do a password check
if (strlen($datafil->getLine(57)) > 0) {
$pwds = explode("::", $datafil->getLine(57));
//Is a valid password given?
if (strlen($ind['brugerkodeord']) === 0 or !in_array($ind['brugerkodeord'], $pwds) and $ind['brugerkodeord'] !== $datafil->getLine(6)) {
require_once "lib/SiteGenerator/SiteGenerator.php";
require_once "lib/StatGenerator.php";
示例6: foreach
<?php
if (Errors::hasErrors()) {
?>
<div class="callout callout-danger">
<?php
foreach (Errors::getErrors() as $error) {
?>
<p class="small"> - <?php
echo $error;
?>
</p>
<?php
}
?>
</div>
<?php
}