CoreFiles by mySites.guru
DatabaseAwareTrait.php61 lines, 1,052 bytes, from Joomla_4.0.6-Stable-Full_Package.zip
Raw History Compare with 4.0.5
md5
00e2e2104ab86dd56d2d60a9bc87af8c
sha1
8fd3bd3af5481728f61629169be87e9ae324b0c3
sha256
df6c0c3a91c9a52ceb028f180ec8af8ea07e34c7280aa0b8e88864867f53a753
<?php
/**
 * Joomla! Content Management System
 *
 * @copyright  (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\MVC\Model;

\defined('JPATH_PLATFORM') or die;

use Joomla\Database\DatabaseInterface;

/**
 * Database aware trait.
 *
 * @since  4.0.0
 */
trait DatabaseAwareTrait
{
	/**
	 * The database driver.
	 *
	 * @var    DatabaseInterface
	 * @since  4.0.0
	 */
	protected $_db;

	/**
	 * Get the database driver.
	 *
	 * @return  DatabaseInterface  The database driver.
	 *
	 * @since   4.0.0
	 * @throws  \UnexpectedValueException
	 */
	public function getDbo()
	{
		if ($this->_db)
		{
			return $this->_db;
		}

		throw new \UnexpectedValueException('Database driver not set in ' . __CLASS__);
	}

	/**
	 * Set the database driver.
	 *
	 * @param   DatabaseInterface  $db  The database driver.
	 *
	 * @return  void
	 *
	 * @since   4.0.0
	 */
	public function setDbo(DatabaseInterface $db = null)
	{
		$this->_db = $db;
	}
}

The same content is in 47 releases, Joomla 4.0.0-beta6 to 4.2.0-alpha1. See them all, or every version of this file.