From 208dfdda42fb5e94ab4d5fb8db6ca71d4ab540f3 Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Tue, 27 Aug 2019 19:57:15 -0500 Subject: [PATCH] Break model class inheritance --- .../PatchTester/Model/AbstractModel.php | 102 ++++++++++++++++++ .../PatchTester/Model/PullModel.php | 2 +- .../PatchTester/Model/PullsModel.php | 2 +- .../PatchTester/Model/TestsModel.php | 2 +- 4 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 administrator/components/com_patchtester/PatchTester/Model/AbstractModel.php diff --git a/administrator/components/com_patchtester/PatchTester/Model/AbstractModel.php b/administrator/components/com_patchtester/PatchTester/Model/AbstractModel.php new file mode 100644 index 0000000..c079924 --- /dev/null +++ b/administrator/components/com_patchtester/PatchTester/Model/AbstractModel.php @@ -0,0 +1,102 @@ +state = $state ?: new Registry; + $this->db = $db ?: Factory::getDbo(); + } + + /** + * Get the database driver. + * + * @return JDatabaseDriver + * + * @since __DEPLOY_VERSION__ + */ + public function getDb() + { + return $this->db; + } + + /** + * Get the model state. + * + * @return Registry + * + * @since __DEPLOY_VERSION__ + */ + public function getState() + { + return $this->state; + } + + /** + * Set the database driver. + * + * @param JDatabaseDriver $db The database driver. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public function setDb(JDatabaseDriver $db) + { + $this->db = $db; + } + + /** + * Set the model state. + * + * @param Registry $state The state object. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public function setState(Registry $state) + { + $this->state = $state; + } +} diff --git a/administrator/components/com_patchtester/PatchTester/Model/PullModel.php b/administrator/components/com_patchtester/PatchTester/Model/PullModel.php index 13e9cdc..360f9f2 100644 --- a/administrator/components/com_patchtester/PatchTester/Model/PullModel.php +++ b/administrator/components/com_patchtester/PatchTester/Model/PullModel.php @@ -18,7 +18,7 @@ use PatchTester\Helper; * * @since 2.0 */ -class PullModel extends \JModelDatabase +class PullModel extends AbstractModel { /** * Array containing top level non-production folders diff --git a/administrator/components/com_patchtester/PatchTester/Model/PullsModel.php b/administrator/components/com_patchtester/PatchTester/Model/PullsModel.php index 22868cb..e4b1bcb 100644 --- a/administrator/components/com_patchtester/PatchTester/Model/PullsModel.php +++ b/administrator/components/com_patchtester/PatchTester/Model/PullsModel.php @@ -18,7 +18,7 @@ use PatchTester\Helper; * * @since 2.0 */ -class PullsModel extends \JModelDatabase +class PullsModel extends AbstractModel { /** * The object context diff --git a/administrator/components/com_patchtester/PatchTester/Model/TestsModel.php b/administrator/components/com_patchtester/PatchTester/Model/TestsModel.php index 6cd5025..4e2c8cb 100644 --- a/administrator/components/com_patchtester/PatchTester/Model/TestsModel.php +++ b/administrator/components/com_patchtester/PatchTester/Model/TestsModel.php @@ -13,7 +13,7 @@ namespace PatchTester\Model; * * @since 2.0 */ -class TestsModel extends \JModelDatabase +class TestsModel extends AbstractModel { /** * Retrieves a list of applied patches