33
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2024-11-18 02:55:10 +00:00
patchtester/administrator/components/com_patchtester/PatchTester/Model/AbstractModel.php

103 lines
1.7 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 4.0.0
2019-08-28 00:57:15 +00:00
*/
abstract class AbstractModel
{
/**
* The database driver.
*
2019-08-28 01:07:28 +00:00
* @var \JDatabaseDriver
* @since 4.0.0
2019-08-28 00:57:15 +00:00
*/
protected $db;
/**
* The model state.
*
* @var Registry
* @since 4.0.0
2019-08-28 00:57:15 +00:00
*/
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 4.0.0
2019-08-28 00:57:15 +00:00
*/
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 4.0.0
2019-08-28 00:57:15 +00:00
*/
public function getDb()
{
return $this->db;
}
/**
* Get the model state.
*
* @return Registry
*
* @since 4.0.0
2019-08-28 00:57:15 +00:00
*/
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 4.0.0
2019-08-28 00:57:15 +00:00
*/
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 4.0.0
2019-08-28 00:57:15 +00:00
*/
public function setState(Registry $state)
{
$this->state = $state;
}
}