forked from WordPress/phpdoc-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrorStore.php
More file actions
61 lines (55 loc) · 1.65 KB
/
ErrorStore.php
File metadata and controls
61 lines (55 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace Aivec\Plugins\DocParser;
use AVCPDP\Aivec\ResponseHandler\ErrorStore as ES;
use AVCPDP\Aivec\ResponseHandler\GenericError;
/**
* Error store
*/
class ErrorStore extends ES
{
const REQUIRED_FIELDS_MISSING = 'RequiredFieldsMissing';
const SOURCE_NOT_FOUND = 'SourceNotFound';
const IMPORT_ERROR = 'ImportError';
/**
* Adds errors to the store
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return void
*/
public function populate() {
$this->addError(new GenericError(
self::REQUIRED_FIELDS_MISSING,
$this->getConstantNameByValue(self::REQUIRED_FIELDS_MISSING),
400,
function ($field) {
// translators: name of the missing field
return sprintf(__('"%s" is required', 'wp-parser'), $field);
},
function ($message) {
return $message;
}
));
$em = function ($name) {
// translators: name of the plugin/theme/composer-package
return sprintf(__('"%s" does not exist', 'wp-parser'), $name);
};
$this->addError(new GenericError(
self::SOURCE_NOT_FOUND,
$this->getConstantNameByValue(self::SOURCE_NOT_FOUND),
404,
$em,
$em
));
$this->addError(new GenericError(
self::IMPORT_ERROR,
$this->getConstantNameByValue(self::IMPORT_ERROR),
422,
function ($message) {
return $message;
},
function ($message) {
return $message;
}
));
}
}