CoreFiles by mySites.guru
DatabaseAwareTrait.php61 lines, 1,064 bytes, from Joomla_4.0.0-alpha7-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha6
md5
a86edb8cd05a514e3767590fa4d3cbd6
sha1
632e0198a09864237a15b0d3874d524d544cafff
sha256
363c15b340e6d3d5026ddfa4121719bb1cd910acff6f8451f71b622541f47d24
<?php
/**
 * Joomla! Content Management System
 *
 * @copyright  Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
 * @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 5 releases, Joomla 4.0.0-alpha7 to 4.0.0-alpha11. See them all, or every version of this file.