33
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2025-02-14 01:30:21 +00:00

Break model class inheritance

This commit is contained in:
Michael Babker 2019-08-27 19:57:15 -05:00
parent 5537bcfe1f
commit 208dfdda42
4 changed files with 105 additions and 3 deletions

View File

@ -0,0 +1,102 @@
<?php
/**
* Patch testing component for the Joomla! CMS
*
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later
*/
namespace PatchTester\Model;
use Joomla\CMS\Factory;
use Joomla\Registry\Registry;
/**
* Base model for the patch testing component
*
* @since __DEPLOY_VERSION__
*/
abstract class AbstractModel
{
/**
* The database driver.
*
* @var JDatabaseDriver
* @since __DEPLOY_VERSION__
*/
protected $db;
/**
* The model state.
*
* @var Registry
* @since __DEPLOY_VERSION__
*/
protected $state;
/**
* Instantiate the model.
*
* @param Registry $state The model state.
* @param JDatabaseDriver $db The database adpater.
*
* @since __DEPLOY_VERSION__
*/
public function __construct(Registry $state = null, JDatabaseDriver $db = null)
{
$this->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;
}
}

View File

@ -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

View File

@ -18,7 +18,7 @@ use PatchTester\Helper;
*
* @since 2.0
*/
class PullsModel extends \JModelDatabase
class PullsModel extends AbstractModel
{
/**
* The object context

View File

@ -13,7 +13,7 @@ namespace PatchTester\Model;
*
* @since 2.0
*/
class TestsModel extends \JModelDatabase
class TestsModel extends AbstractModel
{
/**
* Retrieves a list of applied patches