- md5
- 2089b4d0fa1c37cf92c4bae342a19d77
- sha1
- 2df03cfa57b4b82cbf0a384a6ace16d3b477317d
- sha256
- b41708b10fd624aa7f98ad983ecec41e2104a7825483d00cb71dced668735d33
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
<?php
/**
* Joomla! Content Management System
*
* @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\CMS\Object;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Trait which contains the legacy methods that formerly were inherited from \Joomla\CMS\Object\CMSObject to set and
* get errors in a class.
*
* @since 4.3.0
*
* @deprecated 4.3 will be removed in 6.0
* Throw an Exception instead of setError
*/
trait LegacyErrorHandlingTrait
{
/**
* An array of error messages or Exception objects.
*
* @var array
* @since 1.7.0
* @deprecated 3.1.4 JError has been deprecated
*/
// phpcs:disable PSR2.Classes.PropertyDeclaration
protected $_errors = array();
// phpcs:enable PSR2.Classes.PropertyDeclaration
/**
* Get the most recent error message.
*
* @param integer $i Option error index.
* @param boolean $toString Indicates if Exception objects should return their error message.
*
* @return string Error message
*
* @since 1.7.0
* @deprecated 3.1.4 JError has been deprecated
*/
public function getError($i = null, $toString = true)
{
// Find the error
if ($i === null) {
// Default, return the last message
$error = end($this->_errors);
} elseif (!\array_key_exists($i, $this->_errors)) {
// If $i has been specified but does not exist, return false
return false;
} else {
$error = $this->_errors[$i];
}
// Check if only the string is requested
if ($error instanceof \Exception && $toString) {
return $error->getMessage();
}
return $error;
}
/**
* Return all errors, if any.
*
* @return array Array of error messages.
*
* @since 1.7.0
* @deprecated 3.1.4 JError has been deprecated
*/
public function getErrors()
{
return $this->_errors;
}
/**
* Add an error message.
*
* @param string $error Error message.
*
* @return void
*
* @since 1.7.0
* @deprecated 3.1.4 JError has been deprecated
*/
public function setError($error)
{
$this->_errors[] = $error;
}
}
The same content is in 3 releases, Joomla 4.3.0-alpha1 to 4.3.0-alpha3. See them all, or every version of this file.