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
74a8a4f0
Commit
74a8a4f0
authored
Aug 12, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mvc: style sweep
parent
2e31042e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
28 additions
and
16 deletions
+28
-16
ApiMutableModelControllerBase.php
...ntrollers/OPNsense/Base/ApiMutableModelControllerBase.php
+3
-1
ApiMutableTableModelControllerBase.php
...lers/OPNsense/Base/ApiMutableTableModelControllerBase.php
+17
-7
BaseModel.php
src/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php
+2
-3
BaseModelMigration.php
...sense/mvc/app/models/OPNsense/Base/BaseModelMigration.php
+3
-1
M0_0_1.php
.../app/models/OPNsense/Base/BaseModel/migrations/M0_0_1.php
+1
-1
M1_0_0.php
.../app/models/OPNsense/Base/BaseModel/migrations/M1_0_0.php
+1
-1
M1_0_1.php
.../app/models/OPNsense/Base/BaseModel/migrations/M1_0_1.php
+1
-1
BaseModelTest.php
...ense/mvc/tests/app/models/OPNsense/Base/BaseModelTest.php
+0
-1
No files found.
src/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php
View file @
74a8a4f0
...
...
@@ -167,7 +167,9 @@ abstract class ApiMutableModelControllerBase extends ApiControllerBase
* @param $mdl The validated model containing the new state of the model
* @return Error message on error, or null/void on success
*/
protected
function
setActionHook
()
{
}
protected
function
setActionHook
()
{
}
/**
* update model settings
...
...
src/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableTableModelControllerBase.php
View file @
74a8a4f0
...
...
@@ -39,11 +39,13 @@ abstract class ApiMutableTableModelControllerBase extends ApiMutableModelControl
static
protected
$modelPathPrefix
=
''
;
static
protected
$gridFields
=
array
();
static
protected
$gridDefaultSort
=
null
;
private
function
getNodes
()
{
private
function
getNodes
()
{
$ref
=
static
::
$modelPathPrefix
.
static
::
$internalModelName
;
return
$this
->
getModel
()
->
getNodeByReference
(
$ref
);
}
private
function
getNodeByUUID
(
$uuid
)
{
private
function
getNodeByUUID
(
$uuid
)
{
$nodes
=
$this
->
getNodes
();
return
!
empty
(
$nodes
)
?
$nodes
->
$uuid
:
null
;
}
...
...
@@ -78,7 +80,9 @@ abstract class ApiMutableTableModelControllerBase extends ApiMutableModelControl
* @param $mdl The validated model containing the new state of the model
* @return Error message on error, or null/void on success
*/
protected
function
setItemActionHook
(
$mdl
)
{
}
protected
function
setItemActionHook
(
$mdl
)
{
}
/**
* update item with given properties
...
...
@@ -108,7 +112,9 @@ abstract class ApiMutableTableModelControllerBase extends ApiMutableModelControl
* @param $mdl The validated model containing the state of the new model
* @return Error message on error, or null/void on success
*/
protected
function
addItemActionHook
(
$mdl
)
{
}
protected
function
addItemActionHook
(
$mdl
)
{
}
/**
* add new item and set with attributes from post
...
...
@@ -134,7 +140,9 @@ abstract class ApiMutableTableModelControllerBase extends ApiMutableModelControl
* @param $uuid The UUID of the item to be deleted
* @return Error message on error, or null/void on succes s
*/
protected
function
delItemActionHook
(
$uuid
)
{
}
protected
function
delItemActionHook
(
$uuid
)
{
}
/**
* delete item by uuid
...
...
@@ -150,7 +158,7 @@ abstract class ApiMutableTableModelControllerBase extends ApiMutableModelControl
$errorMessage
=
delItemActionHook
(
$uuid
);
if
(
$errorMessage
)
{
$result
[
'error'
]
=
$errorMessage
;
}
else
if
(
getNodes
()
->
del
(
$uuid
))
{
}
elseif
(
getNodes
()
->
del
(
$uuid
))
{
// if item is removed, serialize to config and save
$mdl
->
serializeToConfig
();
Config
::
getInstance
()
->
save
();
...
...
@@ -172,7 +180,9 @@ abstract class ApiMutableTableModelControllerBase extends ApiMutableModelControl
* @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle
* @return Error message on error, or null/void on succes s
*/
protected
function
toggleItemActionHook
(
$uuid
,
$enabled
)
{
}
protected
function
toggleItemActionHook
(
$uuid
,
$enabled
)
{
}
/**
* toggle item by uuid (enable/disable)
...
...
src/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php
View file @
74a8a4f0
...
...
@@ -526,7 +526,7 @@ abstract class BaseModel
// fetch version migrations
$versions
=
array
();
foreach
(
glob
(
dirname
(
$class_info
->
getFileName
())
.
"/migrations/M*.php"
)
as
$filename
)
{
$version
=
str_replace
(
'_'
,
'.'
,
explode
(
'.'
,
substr
(
basename
(
$filename
),
1
))[
0
]);
$version
=
str_replace
(
'_'
,
'.'
,
explode
(
'.'
,
substr
(
basename
(
$filename
),
1
))[
0
]);
$versions
[
$version
]
=
$filename
;
}
uksort
(
$versions
,
"version_compare"
);
...
...
@@ -546,8 +546,7 @@ abstract class BaseModel
$this
->
internal_current_model_version
.
" to "
.
$mig_version
.
" in "
.
$class_info
->
getName
()
.
" [skipping step]"
);
" [skipping step]"
);
}
$this
->
internal_current_model_version
=
$mig_version
;
}
...
...
src/opnsense/mvc/app/models/OPNsense/Base/BaseModelMigration.php
View file @
74a8a4f0
...
...
@@ -37,5 +37,7 @@ use Phalcon\Logger\Adapter\Syslog;
*/
abstract
class
BaseModelMigration
{
public
function
run
(
$model
)
{}
public
function
run
(
$model
)
{
}
}
src/opnsense/mvc/tests/app/models/OPNsense/Base/BaseModel/migrations/M0_0_1.php
View file @
74a8a4f0
...
...
@@ -38,4 +38,4 @@ class M0_0_1 extends BaseModelMigration
$current_value
=
(
string
)
$model
->
general
->
FromEmail
;
$model
->
general
->
FromEmail
=
"001_"
.
$current_value
;
}
}
\ No newline at end of file
}
src/opnsense/mvc/tests/app/models/OPNsense/Base/BaseModel/migrations/M1_0_0.php
View file @
74a8a4f0
...
...
@@ -38,4 +38,4 @@ class M1_0_0 extends BaseModelMigration
$current_value
=
(
string
)
$model
->
general
->
FromEmail
;
$model
->
general
->
FromEmail
=
"100_"
.
$current_value
;
}
}
\ No newline at end of file
}
src/opnsense/mvc/tests/app/models/OPNsense/Base/BaseModel/migrations/M1_0_1.php
View file @
74a8a4f0
...
...
@@ -38,4 +38,4 @@ class M1_0_1 extends BaseModelMigration
$current_value
=
(
string
)
$model
->
general
->
FromEmail
;
$model
->
general
->
FromEmail
=
"101_"
.
$current_value
;
}
}
\ No newline at end of file
}
src/opnsense/mvc/tests/app/models/OPNsense/Base/BaseModelTest.php
View file @
74a8a4f0
...
...
@@ -234,5 +234,4 @@ class BaseModelTest extends \PHPUnit_Framework_TestCase
$data
=
BaseModelTest
::
$model
->
arraytypes
->
item
->
getNodes
();
$this
->
assertEquals
(
count
(
$data
),
9
);
}
}
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