2013-01-08 22:09:14 -06:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @package db
|
|
|
|
* @copyright (c) 2012 phpBB Group
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-09-10 14:01:09 +02:00
|
|
|
namespace phpbb\db\migration;
|
|
|
|
|
2013-01-08 22:09:14 -06:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
if (!defined('IN_PHPBB'))
|
|
|
|
{
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-09-16 04:45:58 +02:00
|
|
|
* The migrator is responsible for applying new migrations in the correct order.
|
2013-01-08 22:09:14 -06:00
|
|
|
*
|
|
|
|
* @package db
|
|
|
|
*/
|
2013-09-10 14:01:09 +02:00
|
|
|
class exception extends \Exception
|
2013-01-08 22:09:14 -06:00
|
|
|
{
|
2013-01-22 13:19:49 -06:00
|
|
|
/**
|
|
|
|
* Extra parameters sent to exception to aid in debugging
|
|
|
|
* @var array
|
|
|
|
*/
|
2013-01-08 22:09:14 -06:00
|
|
|
protected $parameters;
|
|
|
|
|
2013-01-09 14:27:01 -06:00
|
|
|
/**
|
|
|
|
* Throw an exception.
|
|
|
|
*
|
|
|
|
* First argument is the error message.
|
|
|
|
* Additional arguments will be output with the error message.
|
|
|
|
*/
|
2013-01-08 22:09:14 -06:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$parameters = func_get_args();
|
|
|
|
$message = array_shift($parameters);
|
|
|
|
parent::__construct($message);
|
|
|
|
|
|
|
|
$this->parameters = $parameters;
|
|
|
|
}
|
|
|
|
|
2013-01-09 14:27:01 -06:00
|
|
|
/**
|
|
|
|
* Output the error as a string
|
2013-01-22 13:19:49 -06:00
|
|
|
*
|
|
|
|
* @return string
|
2013-01-09 14:27:01 -06:00
|
|
|
*/
|
2013-01-08 22:09:14 -06:00
|
|
|
public function __toString()
|
|
|
|
{
|
|
|
|
return $this->message . ': ' . var_export($this->parameters, true);
|
|
|
|
}
|
2013-02-09 21:10:56 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the parameters
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getParameters()
|
|
|
|
{
|
|
|
|
return $this->parameters;
|
|
|
|
}
|
2013-02-15 22:19:24 -06:00
|
|
|
|
|
|
|
/**
|
2013-09-16 04:45:58 +02:00
|
|
|
* Get localised message (with $user->lang())
|
|
|
|
*
|
2013-09-10 14:01:09 +02:00
|
|
|
* @param \phpbb\user $user
|
2013-02-15 22:19:24 -06:00
|
|
|
* @return string
|
|
|
|
*/
|
2013-09-10 14:01:09 +02:00
|
|
|
public function getLocalisedMessage(\phpbb\user $user)
|
2013-02-15 22:19:24 -06:00
|
|
|
{
|
|
|
|
$parameters = $this->getParameters();
|
|
|
|
array_unshift($parameters, $this->getMessage());
|
|
|
|
|
|
|
|
return call_user_func_array(array($user, 'lang'), $parameters);
|
|
|
|
}
|
2013-01-08 22:09:14 -06:00
|
|
|
}
|