Backend\Core\Language\Language::getError PHP Method

getError() public static method

Get an error from the language-file
public static getError ( string $key, string $module = null ) : string
$key string The key to get.
$module string The module wherein we should search.
return string
    public static function getError($key, $module = null)
    {
        // do we know the module
        if ($module === null) {
            $module = self::getCurrentModule();
        }
        $key = \SpoonFilter::toCamelCase((string) $key);
        $module = (string) $module;
        // check if the error exists
        if (isset(self::$err[$module][$key])) {
            return self::$err[$module][$key];
        }
        // check if the error exists in the Core
        if (isset(self::$err['Core'][$key])) {
            return self::$err['Core'][$key];
        }
        // otherwise return the key in label-format
        return '{$err' . \SpoonFilter::toCamelCase($module) . $key . '}';
    }

Usage Example

Esempio n. 1
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // redefine fields
         /** @var $fileFile \SpoonFormFile */
         $fileFile = $this->frm->getField('file');
         $chkOverwrite = $this->frm->getField('overwrite');
         // name checks
         if ($fileFile->isFilled(BL::err('FieldIsRequired'))) {
             // only xml files allowed
             if ($fileFile->isAllowedExtension(array('xml'), sprintf(BL::getError('ExtensionNotAllowed'), 'xml'))) {
                 // load xml
                 $xml = @simplexml_load_file($fileFile->getTempFileName());
                 // invalid xml
                 if ($xml === false) {
                     $fileFile->addError(BL::getError('InvalidXML'));
                 }
             }
         }
         if ($this->frm->isCorrect()) {
             // import
             $statistics = BackendLocaleModel::importXML($xml, $chkOverwrite->getValue());
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_import', array('statistics' => $statistics));
             // everything is imported, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('Index') . '&report=imported&var=' . ($statistics['imported'] . '/' . $statistics['total']) . $this->filterQuery);
         }
     }
 }
All Usage Examples Of Backend\Core\Language\Language::getError