[ticket/10411] Throw exceptions instead of using trigger_error()

PHPBB3-10411
This commit is contained in:
Joas Schilling 2013-02-26 16:52:53 +01:00
parent 41eea66da9
commit e0df593448
3 changed files with 28 additions and 55 deletions

View 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
{
}

View file

@ -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
* *

View file

@ -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
* *