- md5
- d4fa6fd6232b34ec927845fb0e7c878c
- sha1
- bb7431a05785ebb3f1d6fec3fc0a5f139497e328
- sha256
- 657fa6315c6b32c56fdac58b7797827370d3ef64552b26b04d860d1c946a239a
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
<?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.txt
*/
namespace Joomla\CMS\Object;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') 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
* Will be removed without replacement
* 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 = [];
// 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 will be removed in 6.0
* Will be removed without replacement
* Catch thrown Exceptions instead of getError
*/
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 will be removed in 6.0
* Will be removed without replacement
* Catch thrown Exceptions instead of getErrors
*/
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 will be removed in 6.0
* Will be removed without replacement
* Throw an Exception instead of using setError
*/
public function setError($error)
{
$this->_errors[] = $error;
}
}
The same content is in 78 releases, Joomla 5.0.0-alpha1 to 5.4.0-alpha2. See them all, or every version of this file.