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
137cac91
Commit
137cac91
authored
Aug 12, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(model, migrations) add default migration strategy
parent
6a7262c5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
BaseModelMigration.php
...sense/mvc/app/models/OPNsense/Base/BaseModelMigration.php
+20
-0
BaseField.php
...nse/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php
+1
-1
No files found.
src/opnsense/mvc/app/models/OPNsense/Base/BaseModelMigration.php
View file @
137cac91
...
@@ -37,7 +37,27 @@ use Phalcon\Logger\Adapter\Syslog;
...
@@ -37,7 +37,27 @@ use Phalcon\Logger\Adapter\Syslog;
*/
*/
abstract
class
BaseModelMigration
abstract
class
BaseModelMigration
{
{
/**
* Walk through all nodes and check required defaults
* @param $node
*/
private
function
checkDefaults
(
$node
)
{
foreach
(
$node
->
__items
as
$key
=>
$subnode
)
{
if
(
count
(
$subnode
->
__items
)
>
0
)
{
$this
->
checkDefaults
(
$subnode
);
}
elseif
(
$subnode
->
isEmptyAndRequired
())
{
$subnode
->
applyDefault
();
}
}
}
/**
* default model migration
* @param $model
*/
public
function
run
(
$model
)
public
function
run
(
$model
)
{
{
$this
->
checkDefaults
(
$model
);
}
}
}
}
src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php
View file @
137cac91
...
@@ -338,7 +338,7 @@ abstract class BaseField
...
@@ -338,7 +338,7 @@ abstract class BaseField
* check if this field is unused and required
* check if this field is unused and required
* @return bool
* @return bool
*/
*/
p
rotected
function
isEmptyAndRequired
()
p
ublic
function
isEmptyAndRequired
()
{
{
if
(
$this
->
internalIsRequired
&&
(
$this
->
internalValue
==
""
||
$this
->
internalValue
==
null
))
{
if
(
$this
->
internalIsRequired
&&
(
$this
->
internalValue
==
""
||
$this
->
internalValue
==
null
))
{
return
true
;
return
true
;
...
...
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