mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-29 06:38:52 +00:00
[ticket/10411] Throw exceptions instead of using trigger_error()
PHPBB3-10411
This commit is contained in:
parent
41eea66da9
commit
e0df593448
3 changed files with 28 additions and 55 deletions
23
phpBB/includes/groupposition/exception.php
Normal file
23
phpBB/includes/groupposition/exception.php
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package groupposition
|
||||||
|
* @copyright (c) 2013 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
if (!defined('IN_PHPBB'))
|
||||||
|
{
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package groupposition
|
||||||
|
*/
|
||||||
|
class phpbb_groupposition_exception extends \Exception
|
||||||
|
{
|
||||||
|
}
|
|
@ -42,11 +42,6 @@ class phpbb_groupposition_legend implements phpbb_groupposition_interface
|
||||||
*/
|
*/
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
/**
|
|
||||||
* URI for the adm_back_link when there was an error.
|
|
||||||
*/
|
|
||||||
protected $adm_back_link = '';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
@ -59,16 +54,6 @@ class phpbb_groupposition_legend implements phpbb_groupposition_interface
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the back link for error messages
|
|
||||||
*
|
|
||||||
* @param string $adm_back_link Return URL to use after an error occured
|
|
||||||
*/
|
|
||||||
public function set_admin_back_link($adm_back_link)
|
|
||||||
{
|
|
||||||
$this->adm_back_link = $adm_back_link;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the group_legend for a given group, if the group exists.
|
* Returns the group_legend for a given group, if the group exists.
|
||||||
*
|
*
|
||||||
|
@ -86,7 +71,7 @@ class phpbb_groupposition_legend implements phpbb_groupposition_interface
|
||||||
if ($current_value === false)
|
if ($current_value === false)
|
||||||
{
|
{
|
||||||
// Group not found.
|
// Group not found.
|
||||||
$this->error('NO_GROUP');
|
throw new phpbb_groupposition_exception('NO_GROUP');
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) $current_value;
|
return (int) $current_value;
|
||||||
|
@ -241,16 +226,6 @@ class phpbb_groupposition_legend implements phpbb_groupposition_interface
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Error
|
|
||||||
*
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
private function error($message)
|
|
||||||
{
|
|
||||||
trigger_error($this->user->lang[$message] . (($this->adm_back_link) ? adm_back_link($this->adm_back_link) : ''), E_USER_WARNING);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get group type language var
|
* Get group type language var
|
||||||
*
|
*
|
||||||
|
|
|
@ -52,11 +52,6 @@ class phpbb_groupposition_teampage implements phpbb_groupposition_interface
|
||||||
*/
|
*/
|
||||||
protected $cache;
|
protected $cache;
|
||||||
|
|
||||||
/**
|
|
||||||
* URI for the adm_back_link when there was an error.
|
|
||||||
*/
|
|
||||||
protected $adm_back_link = '';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
@ -71,16 +66,6 @@ class phpbb_groupposition_teampage implements phpbb_groupposition_interface
|
||||||
$this->cache = $cache;
|
$this->cache = $cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the back link for error messages
|
|
||||||
*
|
|
||||||
* @param string $adm_back_link Return URL to use after an error occured
|
|
||||||
*/
|
|
||||||
public function set_admin_back_link($adm_back_link)
|
|
||||||
{
|
|
||||||
$this->adm_back_link = $adm_back_link;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the teampage position for a given group, if the group exists.
|
* Returns the teampage position for a given group, if the group exists.
|
||||||
*
|
*
|
||||||
|
@ -101,7 +86,7 @@ class phpbb_groupposition_teampage implements phpbb_groupposition_interface
|
||||||
if ($row === false)
|
if ($row === false)
|
||||||
{
|
{
|
||||||
// Group not found.
|
// Group not found.
|
||||||
$this->error('NO_GROUP');
|
throw new phpbb_groupposition_exception('NO_GROUP');
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) $row['teampage_position'];
|
return (int) $row['teampage_position'];
|
||||||
|
@ -128,7 +113,7 @@ class phpbb_groupposition_teampage implements phpbb_groupposition_interface
|
||||||
if ($row === false)
|
if ($row === false)
|
||||||
{
|
{
|
||||||
// Group not found.
|
// Group not found.
|
||||||
$this->error('NO_GROUP');
|
throw new phpbb_groupposition_exception('NO_GROUP');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
|
@ -152,7 +137,7 @@ class phpbb_groupposition_teampage implements phpbb_groupposition_interface
|
||||||
if ($current_value === false)
|
if ($current_value === false)
|
||||||
{
|
{
|
||||||
// Group not found.
|
// Group not found.
|
||||||
$this->error('NO_GROUP');
|
throw new phpbb_groupposition_exception('NO_GROUP');
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) $current_value;
|
return (int) $current_value;
|
||||||
|
@ -176,7 +161,7 @@ class phpbb_groupposition_teampage implements phpbb_groupposition_interface
|
||||||
if ($row === false)
|
if ($row === false)
|
||||||
{
|
{
|
||||||
// Group not found.
|
// Group not found.
|
||||||
$this->error('NO_GROUP');
|
throw new phpbb_groupposition_exception('NO_GROUP');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
|
@ -594,16 +579,6 @@ class phpbb_groupposition_teampage implements phpbb_groupposition_interface
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Error
|
|
||||||
*
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
private function error($message)
|
|
||||||
{
|
|
||||||
trigger_error($this->user->lang[$message] . (($this->adm_back_link) ? adm_back_link($this->adm_back_link) : ''), E_USER_WARNING);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get group type language var
|
* Get group type language var
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue