Skip to content

Commit b3eb8cd

Browse files
committed
Merge branch '3.next' into dep-plugin-load
2 parents 0d5a887 + adf7ff9 commit b3eb8cd

File tree

4 files changed

+44
-5
lines changed

4 files changed

+44
-5
lines changed

Configure.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,18 +260,37 @@ public static function config($name, ConfigEngineInterface $engine)
260260
/**
261261
* Gets the names of the configured Engine objects.
262262
*
263+
* Checking if a specific engine has been configured with this method is deprecated.
264+
* Use Configure::isConfigured() instead.
265+
*
263266
* @param string|null $name Engine name.
264267
* @return array|bool Array of the configured Engine objects, bool for specific name.
265268
*/
266269
public static function configured($name = null)
267270
{
268271
if ($name !== null) {
272+
deprecationWarning(
273+
'Checking for a named engine with configured() is deprecated. ' .
274+
'Use Configure::isConfigured() instead.'
275+
);
276+
269277
return isset(static::$_engines[$name]);
270278
}
271279

272280
return array_keys(static::$_engines);
273281
}
274282

283+
/**
284+
* Returns true if the Engine objects is configured.
285+
*
286+
* @param string $name Engine name.
287+
* @return bool
288+
*/
289+
public static function isConfigured($name)
290+
{
291+
return isset(static::$_engines[$name]);
292+
}
293+
275294
/**
276295
* Remove a configured engine. This will unset the engine
277296
* and make any future attempts to use it cause an Exception.

Configure/FileConfigTrait.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ protected function _getFilePath($key, $checkExists = false)
6060
return $file;
6161
}
6262

63-
if (is_file(realpath($file))) {
64-
return realpath($file);
63+
$realPath = realpath($file);
64+
if ($realPath !== false && is_file($realPath)) {
65+
return $realPath;
6566
}
6667

6768
throw new Exception(sprintf('Could not load configuration file: %s', $file));

ConventionsTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ protected function _pluralHumanName($name)
135135
*/
136136
protected function _pluginPath($pluginName)
137137
{
138-
if (Plugin::loaded($pluginName)) {
138+
if (Plugin::isLoaded($pluginName)) {
139139
return Plugin::path($pluginName);
140140
}
141141

Plugin.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,22 @@ public static function routes($name = null)
337337
}
338338

339339
/**
340-
* Returns true if the plugin $plugin is already loaded
341-
* If plugin is null, it will return a list of all loaded plugins
340+
* Check whether or not a plugin is loaded.
341+
*
342+
* @param string $plugin The name of the plugin to check.
343+
* @return bool
344+
*/
345+
public static function isLoaded($plugin)
346+
{
347+
return static::getCollection()->has($plugin);
348+
}
349+
350+
/**
351+
* Return a list of loaded plugins.
352+
*
353+
* If a plugin name is provided, the return value will be a bool
354+
* indicating whether or not the named plugin is loaded. This usage
355+
* is deprecated. Instead you should use Plugin::isLoaded($name)
342356
*
343357
* @param string|null $plugin Plugin name.
344358
* @return bool|array Boolean true if $plugin is already loaded.
@@ -347,6 +361,11 @@ public static function routes($name = null)
347361
public static function loaded($plugin = null)
348362
{
349363
if ($plugin !== null) {
364+
deprecationWarning(
365+
'Checking a single plugin with Plugin::loaded() is deprecated. ' .
366+
'Use Plugin::isLoaded() instead.'
367+
);
368+
350369
return static::getCollection()->has($plugin);
351370
}
352371
$names = [];

0 commit comments

Comments
 (0)