33
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2024-11-15 01:34:08 +00:00
patchtester/administrator/components/com_patchtester/PatchTester/Model/AbstractModel.php

103 lines
1.8 KiB
PHP
Raw Normal View History

2019-08-28 00:57:15 +00:00
<?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.
*
2019-08-28 01:07:28 +00:00
* @var \JDatabaseDriver
2019-08-28 00:57:15 +00:00
* @since __DEPLOY_VERSION__
*/
protected $db;
/**
* The model state.
*
* @var Registry
* @since __DEPLOY_VERSION__
*/
protected $state;
/**
* Instantiate the model.
*
2019-08-28 01:07:28 +00:00
* @param Registry $state The model state.
* @param \JDatabaseDriver $db The database adpater.
2019-08-28 00:57:15 +00:00
*
* @since __DEPLOY_VERSION__
*/
2019-08-28 01:07:28 +00:00
public function __construct(Registry $state = null, \JDatabaseDriver $db = null)
2019-08-28 00:57:15 +00:00
{
$this->state = $state ?: new Registry;
$this->db = $db ?: Factory::getDbo();
}
/**
* Get the database driver.
*
2019-08-28 01:07:28 +00:00
* @return \JDatabaseDriver
2019-08-28 00:57:15 +00:00
*
* @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.
*
2019-08-28 01:07:28 +00:00
* @param \JDatabaseDriver $db The database driver.
2019-08-28 00:57:15 +00:00
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
2019-08-28 01:07:28 +00:00
public function setDb(\JDatabaseDriver $db)
2019-08-28 00:57:15 +00:00
{
$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;
}
}