Esempio n. 1
0
 /**
  * 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;
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 /**
  * 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()));
 }
Esempio n. 4
0
 /**
  * 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;
 }
Esempio n. 5
0
//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";
Esempio n. 6
0
<?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 
}