Skip to content

Commit

Permalink
mvc - replace \Phalcon\Filter\Validation\Exception with \OPNsense\Bas…
Browse files Browse the repository at this point in the history
…e\ValidationException (both simple empty Exception classes).

for #6389
  • Loading branch information
AdSchellevis committed May 1, 2024
1 parent 7d212f3 commit 0dc6089
Show file tree
Hide file tree
Showing 31 changed files with 141 additions and 105 deletions.
1 change: 1 addition & 0 deletions plist
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@
/usr/local/opnsense/mvc/app/models/OPNsense/Base/Messages/Message.php
/usr/local/opnsense/mvc/app/models/OPNsense/Base/ModelException.php
/usr/local/opnsense/mvc/app/models/OPNsense/Base/Validation.php
/usr/local/opnsense/mvc/app/models/OPNsense/Base/ValidationException.php
/usr/local/opnsense/mvc/app/models/OPNsense/Base/Validators/CallbackValidator.php
/usr/local/opnsense/mvc/app/models/OPNsense/Base/Validators/CsvListValidator.php
/usr/local/opnsense/mvc/app/models/OPNsense/Base/Validators/Email.php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ protected function getModel()
* @param string $node reference node, to use as relative offset
* @param string $prefix prefix to use when $node is provided (defaults to static::$internalModelName)
* @return array result / validation output
* @throws \Phalcon\Filter\Validation\Exception on validation issues
* @throws \OPNsense\Base\ValidationException on validation issues
* @throws \ReflectionException when binding to the model class fails
* @throws UserException when denied write access
*/
Expand Down Expand Up @@ -296,7 +296,7 @@ protected function validate($node = null, $prefix = null, $validateFullModel = f
* @param bool $validateFullModel by default we only validate the fields we have changed
* @param bool $disable_validation skip validation, be careful to use this!
* @return array result / validation output
* @throws \Phalcon\Filter\Validation\Exception on validation issues
* @throws \OPNsense\Base\ValidationException on validation issues
* @throws \ReflectionException when binding to the model class fails
* @throws \OPNsense\Base\UserException when denied write access
*/
Expand Down Expand Up @@ -340,7 +340,7 @@ protected function setBaseHook($node)
/**
* Update model settings
* @return array status / validation errors
* @throws \Phalcon\Filter\Validation\Exception on validation issues
* @throws \OPNsense\Base\ValidationException on validation issues
* @throws \ReflectionException when binding to the model class fails
* @throws UserException when denied write access
*/
Expand Down Expand Up @@ -445,7 +445,7 @@ public function getBase($key_name, $path, $uuid = null)
* @param string $path relative model path
* @param array|null $overlay properties to overlay when available (call setNodes)
* @return array
* @throws \Phalcon\Filter\Validation\Exception on validation issues
* @throws \OPNsense\Base\ValidationException on validation issues
* @throws \ReflectionException when binding to the model class fails
* @throws UserException when denied write access
*/
Expand Down Expand Up @@ -485,7 +485,7 @@ public function addBase($post_field, $path, $overlay = null)
* @param string $path relative model path
* @param null|string $uuid node key
* @return array
* @throws \Phalcon\Filter\Validation\Exception on validation issues
* @throws \OPNsense\Base\ValidationException on validation issues
* @throws \ReflectionException when binding to the model class fails
* @throws UserException when denied write access
*/
Expand Down Expand Up @@ -520,7 +520,7 @@ public function delBase($path, $uuid)
* @param string $uuid node key
* @param array|null $overlay properties to overlay when available (call setNodes)
* @return array
* @throws \Phalcon\Filter\Validation\Exception on validation issues
* @throws \OPNsense\Base\ValidationException on validation issues
* @throws \ReflectionException when binding to the model class fails
* @throws UserException when denied write access
*/
Expand Down Expand Up @@ -569,7 +569,7 @@ public function setBase($post_field, $path, $uuid, $overlay = null)
* @param string $uuid node key
* @param string $enabled desired state enabled(1)/disabled(0), leave empty for toggle
* @return array
* @throws \Phalcon\Filter\Validation\Exception on validation issues
* @throws \OPNsense\Base\ValidationException on validation issues
* @throws \ReflectionException when binding to the model class fails
* @throws UserException when denied write access
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function setJobAction($uuid)
* add new job and set with attributes from post
* @return array save result + validation output
* @throws \OPNsense\Base\ModelException when not bound to model
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException
*/
public function addJobAction()
Expand All @@ -116,7 +116,7 @@ public function addJobAction()
* delete job by uuid ( only if origin is cron)
* @param string $uuid item unique id
* @return array status
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
* @throws \OPNsense\Base\ModelException when not bound to model
*/
Expand All @@ -136,7 +136,7 @@ public function delJobAction($uuid)
* @param $uuid item unique id
* @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle
* @return array status
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function toggleJobAction($uuid, $enabled = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function getconfigAction()
/**
* update netflow configuration fields
* @return array
* @throws \Phalcon\Filter\Validation\Exception
* @throws \OPNsense\Base\ValidationException
*/
public function setconfigAction()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function listCategoriesAction()
* Update alias with given properties
* @param string $uuid internal id
* @return array save result + validation output
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function setItemAction($uuid)
Expand All @@ -159,7 +159,7 @@ public function setItemAction($uuid)
* Add new alias and set with attributes from post
* @return array save result + validation output
* @throws \OPNsense\Base\ModelException when not bound to model
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function addItemAction()
Expand Down Expand Up @@ -210,7 +210,7 @@ public function getAliasUUIDAction($name)
* Delete alias by uuid, save contents to tmp for removal on apply
* @param string $uuid internal id
* @return array save status
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
* @throws \OPNsense\Base\UserException when unable to delete
*/
Expand All @@ -237,7 +237,7 @@ public function delItemAction($uuid)
* @param string $uuid id to toggled
* @param string|null $enabled set enabled by default
* @return array status
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function toggleItemAction($uuid, $enabled = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function searchItemAction($add_empty = '0')
* Update category with given properties
* @param string $uuid internal id
* @return array save result + validation output
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function setItemAction($uuid)
Expand All @@ -85,7 +85,7 @@ public function setItemAction($uuid)
* Add new category and set with attributes from post
* @return array save result + validation output
* @throws \OPNsense\Base\ModelException when not bound to model
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function addItemAction()
Expand All @@ -108,7 +108,7 @@ public function getItemAction($uuid = null)
* Delete alias by uuid, save contents to tmp for removal on apply
* @param string $uuid internal id
* @return array save status
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
* @throws \OPNsense\Base\UserException when unable to delete
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function searchItemAction()
* Update group with given properties
* @param string $uuid internal id
* @return array save result + validation output
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function setItemAction($uuid)
Expand All @@ -84,7 +84,7 @@ public function setItemAction($uuid)
* Add new group and set with attributes from post
* @return array save result + validation output
* @throws \OPNsense\Base\ModelException when not bound to model
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function addItemAction()
Expand All @@ -107,7 +107,7 @@ public function getItemAction($uuid = null)
* Delete alias by uuid, save contents to tmp for removal on apply
* @param string $uuid internal id
* @return array save status
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
* @throws \OPNsense\Base\UserException when unable to delete
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ServiceController extends ApiMutableServiceControllerBase
* @return array result status
* @throws \Exception when configd action fails
* @throws \OPNsense\Base\ModelException when unable to construct model
* @throws \Phalcon\Filter\Validation\Exception when one or more model validations fail
* @throws \OPNsense\Base\ValidationException when one or more model validations fail
*/
public function reconfigureAction()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public function getRulesetpropertiesAction()
* Update ruleset properties
* @return array result status
* @throws \Exception when config action fails
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function setRulesetpropertiesAction()
Expand Down Expand Up @@ -408,7 +408,7 @@ public function getRulesetAction($id)
* @param $filename rule filename (key)
* @return array result status
* @throws \Exception when configd action fails
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function setRulesetAction($filename)
Expand Down Expand Up @@ -445,7 +445,7 @@ public function setRulesetAction($filename)
* @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle
* @return array status 0/1 or error
* @throws \Exception
* @throws \Phalcon\Filter\Validation\Exception
* @throws \OPNsense\Base\ValidationException
*/
public function toggleRulesetAction($filenames, $enabled = null)
{
Expand Down Expand Up @@ -488,7 +488,7 @@ public function toggleRulesetAction($filenames, $enabled = null)
* @param string|int $enabled desired state enabled(1)/disabled(1), leave empty for toggle
* @return array empty
* @throws \Exception when configd action fails
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function toggleRuleAction($sids, $enabled = null)
Expand Down Expand Up @@ -543,7 +543,7 @@ public function toggleRuleAction($sids, $enabled = null)
* @param $sid item unique id
* @return array result status
* @throws \Exception when configd action fails
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function setRuleAction($sid)
Expand Down Expand Up @@ -584,7 +584,7 @@ public function searchUserRuleAction()
* Update user defined rules
* @param string $uuid internal id
* @return array save result + validation output
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function setUserRuleAction($uuid)
Expand All @@ -595,7 +595,7 @@ public function setUserRuleAction($uuid)
/**
* Add new user defined rule
* @return array save result + validation output
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function addUserRuleAction()
Expand All @@ -618,7 +618,7 @@ public function getUserRuleAction($uuid = null)
* Delete user rule item
* @param string $uuid user rule internal id
* @return array save status
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function delUserRuleAction($uuid)
Expand All @@ -631,7 +631,7 @@ public function delUserRuleAction($uuid)
* @param $uuid user defined rule internal id
* @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle
* @return array save result
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function toggleUserRuleAction($uuid, $enabled = null)
Expand All @@ -653,7 +653,7 @@ public function searchPolicyAction()
* Update policy
* @param string $uuid internal id
* @return array save result + validation output
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function setPolicyAction($uuid)
Expand All @@ -664,7 +664,7 @@ public function setPolicyAction($uuid)
/**
* Add new policy
* @return array save result + validation output
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function addPolicyAction()
Expand All @@ -687,7 +687,7 @@ public function getPolicyAction($uuid = null)
* Delete policy item
* @param string $uuid user rule internal id
* @return array save status
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function delPolicyAction($uuid)
Expand All @@ -700,7 +700,7 @@ public function delPolicyAction($uuid)
* @param $uuid user defined rule internal id
* @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle
* @return array save result
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function togglePolicyAction($uuid, $enabled = null)
Expand All @@ -726,7 +726,7 @@ public function searchPolicyRuleAction()
* Update policy rule adjustment
* @param string $uuid internal id
* @return array save result + validation output
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function setPolicyRuleAction($uuid)
Expand All @@ -737,7 +737,7 @@ public function setPolicyRuleAction($uuid)
/**
* Add new policy rule adjustment
* @return array save result + validation output
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function addPolicyRuleAction()
Expand All @@ -760,7 +760,7 @@ public function getPolicyRuleAction($uuid = null)
* Delete policy rule adjustment item
* @param string $uuid internal id
* @return array save status
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function delPolicyRuleAction($uuid)
Expand All @@ -773,7 +773,7 @@ public function delPolicyRuleAction($uuid)
* @param $uuid user internal id
* @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle
* @return array save result
* @throws \Phalcon\Filter\Validation\Exception when field validations fail
* @throws \OPNsense\Base\ValidationException when field validations fail
* @throws \ReflectionException when not bound to model
*/
public function togglePolicyRuleAction($uuid, $enabled = null)
Expand Down
Loading

0 comments on commit 0dc6089

Please sign in to comment.