Skip to content

Commit

Permalink
Merge pull request #2588 from cakephp/3.0-remove-error-translation
Browse files Browse the repository at this point in the history
3.0 remove error translation
  • Loading branch information
ADmad committed Jan 4, 2014
2 parents ba8d3ff + 01227b2 commit 1f8696a
Show file tree
Hide file tree
Showing 110 changed files with 458 additions and 564 deletions.
6 changes: 3 additions & 3 deletions Cake/Cache/Cache.php
Expand Up @@ -118,7 +118,7 @@ protected static function _buildEngine($name) {
static::$_registry = new CacheRegistry();
}
if (empty(static::$_config[$name]['className'])) {
throw new Error\Exception(__d('cake_dev', 'The "%s" cache configuration does not exist.', $name));
throw new Error\Exception(sprintf('The "%s" cache configuration does not exist.', $name));
}

$config = static::$_config[$name];
Expand Down Expand Up @@ -200,7 +200,7 @@ public static function write($key, $value, $config = 'default') {
$success = $engine->write($key, $value);
if ($success === false && $value !== '') {
trigger_error(
__d('cake_dev',
sprintf(
"%s cache was unable to write '%s' to %s cache",
$config,
$key,
Expand Down Expand Up @@ -356,7 +356,7 @@ public static function groupConfigs($group = null) {
return [$group => self::$_groups[$group]];
}

throw new Error\Exception(__d('cake_dev', 'Invalid cache group %s', $group));
throw new Error\Exception(sprintf('Invalid cache group %s', $group));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Cake/Cache/CacheEngine.php
Expand Up @@ -205,7 +205,7 @@ public function key($key) {
protected function _key($key) {
$key = $this->key($key);
if (!$key) {
throw new \InvalidArgumentException(__d('cake_dev', 'An empty value is not valid as a cache key'));
throw new \InvalidArgumentException('An empty value is not valid as a cache key');
}

return $this->_config['prefix'] . $key;
Expand Down
9 changes: 4 additions & 5 deletions Cake/Cache/CacheRegistry.php
Expand Up @@ -51,7 +51,7 @@ protected function _resolveClassName($class) {
* @throws Cake\Error\Exception
*/
protected function _throwMissingClassError($class, $plugin) {
throw new Error\Exception(__d('cake_dev', 'Cache engine %s is not available.', $class));
throw new Error\Exception(sprintf('Cache engine %s is not available.', $class));
}

/**
Expand All @@ -76,15 +76,14 @@ protected function _create($class, $alias, $config) {
}

if (!($instance instanceof CacheEngine)) {
throw new Error\Exception(__d(
'cake_dev',
throw new Error\Exception(
'Cache engines must use Cake\Cache\CacheEngine as a base class.'
));
);
}

if (!$instance->init($config)) {
throw new Error\Exception(
__d('cake_dev', 'Cache engine %s is not properly configured.', $class)
sprintf('Cache engine %s is not properly configured.', $class)
);
}

Expand Down
13 changes: 7 additions & 6 deletions Cake/Cache/Engine/FileEngine.php
Expand Up @@ -328,7 +328,7 @@ protected function _clearDirectory($path, $now, $threshold) {
* @throws Cake\Error\Exception
*/
public function decrement($key, $offset = 1) {
throw new Error\Exception(__d('cake_dev', 'Files cannot be atomically decremented.'));
throw new Error\Exception('Files cannot be atomically decremented.');
}

/**
Expand All @@ -340,7 +340,7 @@ public function decrement($key, $offset = 1) {
* @throws Cake\Error\Exception
*/
public function increment($key, $offset = 1) {
throw new Error\Exception(__d('cake_dev', 'Files cannot be atomically incremented.'));
throw new Error\Exception('Files cannot be atomically incremented.');
}

/**
Expand Down Expand Up @@ -377,9 +377,10 @@ protected function _setKey($key, $createKey = false) {
unset($path);

if (!$exists && !chmod($this->_File->getPathname(), (int)$this->_config['mask'])) {
trigger_error(__d(
'cake_dev', 'Could not apply permission mask "%s" on cache file "%s"',
[$this->_File->getPathname(), $this->_config['mask']]), E_USER_WARNING);
trigger_error(sprintf(
'Could not apply permission mask "%s" on cache file "%s"',
$this->_File->getPathname(), $this->_config['mask']
), E_USER_WARNING);
}
}
return true;
Expand All @@ -400,7 +401,7 @@ protected function _active() {
}
if ($this->_init && !($dir->isDir() && $dir->isWritable())) {
$this->_init = false;
trigger_error(__d('cake_dev', '%s is not writable', $this->_config['path']), E_USER_WARNING);
trigger_error(sprintf('%s is not writable', $this->_config['path']), E_USER_WARNING);
return false;
}
return true;
Expand Down
6 changes: 3 additions & 3 deletions Cake/Cache/Engine/MemcachedEngine.php
Expand Up @@ -139,7 +139,7 @@ public function init($config = []) {
if ($this->_config['login'] !== null && $this->_config['password'] !== null) {
if (!method_exists($this->_Memcached, 'setSaslAuthData')) {
throw new Error\Exception(
__d('cake_dev', 'Memcached extension is not build with SASL support')
'Memcached extension is not build with SASL support'
);
}
$this->_Memcached->setSaslAuthData($this->_config['login'], $this->_config['password']);
Expand All @@ -159,13 +159,13 @@ protected function _setOptions() {
$serializer = strtolower($this->_config['serialize']);
if (!isset($this->_serializers[$serializer])) {
throw new Error\Exception(
__d('cake_dev', '%s is not a valid serializer engine for Memcached', $serializer)
sprintf('%s is not a valid serializer engine for Memcached', $serializer)
);
}

if ($serializer !== 'php' && !constant('Memcached::HAVE_' . strtoupper($serializer))) {
throw new Error\Exception(
__d('cake_dev', 'Memcached extension is not compiled with %s support', $serializer)
sprintf('Memcached extension is not compiled with %s support', $serializer)
);
}

Expand Down
2 changes: 1 addition & 1 deletion Cake/Collection/Collection.php
Expand Up @@ -41,7 +41,7 @@ public function __construct($items) {
}

if (!($items instanceof \Traversable)) {
$msg = __d('cake_dev', 'Only array or \Traversable are allowed for Collection');
$msg = 'Only array or \Traversable are allowed for Collection';
throw new InvalidArgumentException($msg);
}

Expand Down
2 changes: 1 addition & 1 deletion Cake/Collection/Iterator/MapReduce.php
Expand Up @@ -172,7 +172,7 @@ protected function _execute() {
$this->_data = null;

if (!empty($this->_intermediate) && empty($this->_reducer)) {
throw new \LogicException(__d('cake_dev', 'No reducer function was provided'));
throw new \LogicException('No reducer function was provided');
}

$reducer = $this->_reducer;
Expand Down
4 changes: 2 additions & 2 deletions Cake/Configure/Engine/IniConfig.php
Expand Up @@ -99,12 +99,12 @@ public function __construct($path = null, $section = null) {
*/
public function read($key) {
if (strpos($key, '..') !== false) {
throw new Error\ConfigureException(__d('cake_dev', 'Cannot load configuration files with ../ in them.'));
throw new Error\ConfigureException('Cannot load configuration files with ../ in them.');
}

$file = $this->_getFilePath($key);
if (!is_file($file)) {
throw new Error\ConfigureException(__d('cake_dev', 'Could not load configuration file: %s', $file));
throw new Error\ConfigureException(sprintf('Could not load configuration file: %s', $file));
}

$contents = parse_ini_file($file, true);
Expand Down
6 changes: 3 additions & 3 deletions Cake/Configure/Engine/PhpConfig.php
Expand Up @@ -62,17 +62,17 @@ public function __construct($path = null) {
*/
public function read($key) {
if (strpos($key, '..') !== false) {
throw new Error\ConfigureException(__d('cake_dev', 'Cannot load configuration files with ../ in them.'));
throw new Error\ConfigureException('Cannot load configuration files with ../ in them.');
}

$file = $this->_getFilePath($key);
if (!is_file($file)) {
throw new Error\ConfigureException(__d('cake_dev', 'Could not load configuration file: %s', $file));
throw new Error\ConfigureException(sprintf('Could not load configuration file: %s', $file));
}

include $file;
if (!isset($config)) {
throw new Error\ConfigureException(__d('cake_dev', 'No variable %s found in %s', '$config', $file));
throw new Error\ConfigureException(sprintf('No variable $config found in %s', $file));
}
return $config;
}
Expand Down
2 changes: 1 addition & 1 deletion Cake/Console/Command/Task/PluginTask.php
Expand Up @@ -180,7 +180,7 @@ protected function _modifyBootstrap($plugin) {
if (!preg_match("@\n\s*Plugin::loadAll@", $contents)) {
$bootstrap->append("\nPlugin::load('$plugin', ['bootstrap' => false, 'routes' => false]);\n");
$this->out('');
$this->out(__d('cake_dev', '%s modified', $this->bootstrap));
$this->out(sprintf('%s modified', $this->bootstrap));
}
}

Expand Down
4 changes: 2 additions & 2 deletions Cake/Console/Command/Task/TestTask.php
Expand Up @@ -342,7 +342,7 @@ public function getRealClassName($type, $class, $plugin = null) {
public function mapType($type, $plugin) {
$type = ucfirst($type);
if (empty($this->classTypes[$type])) {
throw new Error\Exception(__d('cake_dev', 'Invalid object type.'));
throw new Error\Exception('Invalid object type.');
}
$real = $this->classTypes[$type];
if ($plugin) {
Expand All @@ -361,7 +361,7 @@ public function mapType($type, $plugin) {
*/
public function getBaseType($type) {
if (empty($this->baseTypes[$type])) {
throw new Error\Exception(__d('cake_dev', 'Invalid type name'));
throw new Error\Exception('Invalid type name');
}
return $this->baseTypes[$type];
}
Expand Down
8 changes: 4 additions & 4 deletions Cake/Console/Command/TestShell.php
Expand Up @@ -173,7 +173,7 @@ public function initialize() {
$this->_dispatcher = new TestSuiteDispatcher();
$sucess = $this->_dispatcher->loadTestFramework();
if (!$sucess) {
throw new \Exception(__d('cake_dev', 'Please install PHPUnit framework <info>(http://www.phpunit.de)</info>'));
throw new \Exception('Please install PHPUnit framework <info>(http://www.phpunit.de)</info>');
}
}

Expand Down Expand Up @@ -369,7 +369,7 @@ protected function _mapFileToCase($file, $category, $throwOnMissingFile = true)
return $testCase;
}

throw new \Exception(__d('cake_dev', 'Test case %s cannot be run via this shell', $testFile));
throw new \Exception(sprintf('Test case %s cannot be run via this shell', $testFile));
}
}

Expand All @@ -382,7 +382,7 @@ protected function _mapFileToCase($file, $category, $throwOnMissingFile = true)
$testFile = CAKE . 'Test/TestCase/' . $testCase . 'Test.php';

if (!file_exists($testFile) && $throwOnMissingFile) {
throw new \Exception(__d('cake_dev', 'Test case %s not found', $testFile));
throw new \Exception(sprintf('Test case %s not found', $testFile));
}

return $testCase;
Expand All @@ -399,7 +399,7 @@ protected function _mapFileToCase($file, $category, $throwOnMissingFile = true)
}

if (!file_exists($testFile) && $throwOnMissingFile) {
throw new \Exception(__d('cake_dev', 'Test case %s not found', $testFile));
throw new \Exception(sprintf('Test case %s not found', $testFile));
}

$testCase = substr($testFile, 0, -8);
Expand Down
6 changes: 3 additions & 3 deletions Cake/Controller/Component/Acl/PhpAcl.php
Expand Up @@ -102,11 +102,11 @@ public function initialize(Component $Component) {
*/
public function build(array $config) {
if (empty($config['roles'])) {
throw new Error\AclException(__d('cake_dev', '"roles" section not found in configuration.'));
throw new Error\AclException('"roles" section not found in configuration.');
}

if (empty($config['rules']['allow']) && empty($config['rules']['deny'])) {
throw new Error\AclException(__d('cake_dev', 'Neither "allow" nor "deny" rules were provided in configuration.'));
throw new Error\AclException('Neither "allow" nor "deny" rules were provided in configuration.');
}

$rules['allow'] = !empty($config['rules']['allow']) ? $config['rules']['allow'] : array();
Expand Down Expand Up @@ -524,7 +524,7 @@ public function addRole(array $aro) {
$path .= implode('|', (array)$roleDependencies) . ' -> ';
}

trigger_error(__d('cake_dev', 'cycle detected when inheriting %s from %s. Path: %s', $role, $dependency, $path . $role));
trigger_error(sprintf('cycle detected when inheriting %s from %s. Path: %s', $role, $dependency, $path . $role));
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions Cake/Controller/Component/AclComponent.php
Expand Up @@ -70,7 +70,7 @@ public function __construct(ComponentRegistry $collection, $settings = array())
if (!class_exists($classname)) {
$classname = App::classname($name, 'Controller/Component/Acl');
if (!$classname) {
throw new Error\Exception(__d('cake_dev', 'Could not find %s.', $name));
throw new Error\Exception(sprintf('Could not find %s.', $name));
}
}
$this->adapter($classname);
Expand All @@ -94,7 +94,7 @@ public function adapter($adapter = null) {
$adapter = new $adapter();
}
if (!$adapter instanceof AclInterface) {
throw new Error\Exception(__d('cake_dev', 'AclComponent adapters must implement AclInterface'));
throw new Error\Exception('AclComponent adapters must implement AclInterface');
}
$this->_Instance = $adapter;
$this->_Instance->initialize($this);
Expand Down
4 changes: 2 additions & 2 deletions Cake/Controller/Component/Auth/BaseAuthenticate.php
Expand Up @@ -148,12 +148,12 @@ public function passwordHasher() {
list($plugin, $class) = pluginSplit($class, true);
$className = App::classname($class, 'Controller/Component/Auth', 'PasswordHasher');
if (!class_exists($className)) {
throw new Error\Exception(__d('cake_dev', 'Password hasher class "%s" was not found.', $class));
throw new Error\Exception(sprintf('Password hasher class "%s" was not found.', $class));
}

$this->_passwordHasher = new $className($config);
if (!($this->_passwordHasher instanceof AbstractPasswordHasher)) {
throw new Error\Exception(__d('cake_dev', 'Password hasher must extend AbstractPasswordHasher class.'));
throw new Error\Exception('Password hasher must extend AbstractPasswordHasher class.');
}
return $this->_passwordHasher;
}
Expand Down
2 changes: 1 addition & 1 deletion Cake/Controller/Component/Auth/BaseAuthorize.php
Expand Up @@ -100,7 +100,7 @@ abstract public function authorize($user, Request $request);
public function controller(Controller $controller = null) {
if ($controller) {
if (!$controller instanceof Controller) {
throw new Error\Exception(__d('cake_dev', '$controller needs to be an instance of Controller'));
throw new Error\Exception('$controller needs to be an instance of Controller');
}
$this->_Controller = $controller;
return true;
Expand Down
2 changes: 1 addition & 1 deletion Cake/Controller/Component/Auth/ControllerAuthorize.php
Expand Up @@ -51,7 +51,7 @@ class ControllerAuthorize extends BaseAuthorize {
public function controller(Controller $controller = null) {
if ($controller) {
if (!method_exists($controller, 'isAuthorized')) {
throw new Error\Exception(__d('cake_dev', '$controller does not implement an %s method.', 'isAuthorized()'));
throw new Error\Exception(sprintf('%s does not implement an isAuthorized() method.', get_class($controller)));
}
}
return parent::controller($controller);
Expand Down
2 changes: 1 addition & 1 deletion Cake/Controller/Component/Auth/CrudAuthorize.php
Expand Up @@ -83,7 +83,7 @@ protected function _setPrefixMappings() {
*/
public function authorize($user, Request $request) {
if (!isset($this->settings['actionMap'][$request->params['action']])) {
trigger_error(__d('cake_dev',
trigger_error(sprintf(
'CrudAuthorize::authorize() - Attempted access of un-mapped action "%1$s" in controller "%2$s"',
$request->action,
$request->controller
Expand Down
8 changes: 4 additions & 4 deletions Cake/Controller/Component/AuthComponent.php
Expand Up @@ -494,10 +494,10 @@ public function constructAuthorize() {
foreach ($config as $class => $settings) {
$className = App::classname($class, 'Controller/Component/Auth', 'Authorize');
if (!class_exists($className)) {
throw new Error\Exception(__d('cake_dev', 'Authorization adapter "%s" was not found.', $class));
throw new Error\Exception(sprintf('Authorization adapter "%s" was not found.', $class));
}
if (!method_exists($className, 'authorize')) {
throw new Error\Exception(__d('cake_dev', 'Authorization objects must implement an %s method.', 'authorize()'));
throw new Error\Exception('Authorization objects must implement an authorize() method.');
}
$settings = array_merge($global, (array)$settings);
$this->_authorizeObjects[] = new $className($this->_registry, $settings);
Expand Down Expand Up @@ -770,10 +770,10 @@ public function constructAuthenticate() {
foreach ($config as $class => $settings) {
$className = App::classname($class, 'Controller/Component/Auth', 'Authenticate');
if (!class_exists($className)) {
throw new Error\Exception(__d('cake_dev', 'Authentication adapter "%s" was not found.', $class));
throw new Error\Exception(sprintf('Authentication adapter "%s" was not found.', $class));
}
if (!method_exists($className, 'authenticate')) {
throw new Error\Exception(__d('cake_dev', 'Authentication objects must implement an %s method.', 'authenticate()'));
throw new Error\Exception('Authentication objects must implement an authenticate() method.');
}
$settings = array_merge($global, (array)$settings);
$this->_authenticateObjects[] = new $className($this->_registry, $settings);
Expand Down
2 changes: 1 addition & 1 deletion Cake/Controller/Component/CookieComponent.php
Expand Up @@ -401,7 +401,7 @@ public function type($type = 'aes') {
'aes'
];
if (!in_array($type, $availableTypes)) {
throw new Error\Exception(__d('cake_dev', 'You must use rijndael, or aes for cookie encryption type'));
throw new Error\Exception('You must use rijndael, or aes for cookie encryption type');
}
$this->_type = $type;
}
Expand Down
2 changes: 1 addition & 1 deletion Cake/Controller/Component/RequestHandlerComponent.php
Expand Up @@ -631,7 +631,7 @@ public function mapAlias($alias) {
*/
public function addInputType($type, $handler) {
if (!is_array($handler) || !isset($handler[0]) || !is_callable($handler[0])) {
throw new Error\Exception(__d('cake_dev', 'You must give a handler callback.'));
throw new Error\Exception('You must give a handler callback.');
}
$this->_inputTypeMap[$type] = $handler;
}
Expand Down
4 changes: 2 additions & 2 deletions Cake/Controller/Component/SecurityComponent.php
Expand Up @@ -201,7 +201,7 @@ public function requireAuth() {
*/
public function blackHole(Controller $controller, $error = '') {
if (!$this->blackHoleCallback) {
throw new Error\BadRequestException(__d('cake_dev', 'The request has been black-holed'));
throw new Error\BadRequestException('The request has been black-holed');
}
return $this->_callback($controller, $this->blackHoleCallback, array($error));
}
Expand Down Expand Up @@ -401,7 +401,7 @@ public function generateToken(Request $request) {
*/
protected function _callback(Controller $controller, $method, $params = array()) {
if (!is_callable(array($controller, $method))) {
throw new Error\BadRequestException(__d('cake_dev', 'The request has been black-holed'));
throw new Error\BadRequestException('The request has been black-holed');
}
return call_user_func_array(array(&$controller, $method), empty($params) ? null : $params);
}
Expand Down

0 comments on commit 1f8696a

Please sign in to comment.