Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
b7f55e9f
Commit
b7f55e9f
authored
May 27, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(mvc) send model validation messages to syslog
parent
9d52255d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
8 deletions
+19
-8
BaseModel.php
src/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php
+19
-8
No files found.
src/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php
View file @
b7f55e9f
...
...
@@ -32,6 +32,7 @@ namespace OPNsense\Base;
use
OPNsense\Base\FieldTypes\ArrayField
;
use
OPNsense\Base\FieldTypes\ContainerField
;
use
OPNsense\Core\Config
;
use
Phalcon\Logger\Adapter\Syslog
;
/**
* Class BaseModel implements base model to bind config and definition to object.
...
...
@@ -389,14 +390,24 @@ abstract class BaseModel
*/
public
function
serializeToConfig
(
$disable_validation
=
false
)
{
if
(
$disable_validation
==
false
)
{
// perform validation, collect all messages and raise exception
$messages
=
$this
->
performValidation
();
if
(
$messages
->
count
()
>
0
)
{
$exception_msg
=
""
;
foreach
(
$messages
as
$msg
)
{
$exception_msg
.=
"["
.
$msg
->
getField
()
.
"] "
.
$msg
->
getMessage
()
.
"
\n
"
;
}
// create logger to save possible consistency issues to
$logger
=
new
Syslog
(
"config"
,
array
(
'option'
=>
LOG_PID
,
'facility'
=>
LOG_LOCAL4
));
// Perform validation, collect all messages and raise exception if validation is not disabled.
// If for some reason the developer chooses to ignore the errors, let's at least log there something
// wrong in this model.
$messages
=
$this
->
performValidation
();
if
(
$messages
->
count
()
>
0
)
{
$exception_msg
=
""
;
foreach
(
$messages
as
$msg
)
{
$exception_msg
.=
"["
.
$msg
->
getField
()
.
"] "
.
$msg
->
getMessage
()
.
"
\n
"
;
// always log validation errors
$logger
->
error
(
str_replace
(
"
\\
"
,
"."
,
get_class
(
$this
))
.
"."
.
$msg
->
getField
()
.
" "
.
$msg
->
getMessage
());
}
if
(
!
$disable_validation
)
{
throw
new
\Phalcon\Validation\Exception
(
$exception_msg
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment