Skip to content

Commit

Permalink
Make constants optional.
Browse files Browse the repository at this point in the history
Don't require constants from the application skeleton in the standalone
components. This makes it easier for the components to be used.

I've deprecated Folder::inCakePath() as it is a silly function that can
be replaced with usage of inPath()

Refs #9074
  • Loading branch information
markstory committed Jul 8, 2016
1 parent 8c3d299 commit 8603633
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
10 changes: 3 additions & 7 deletions src/Error/Debugger.php
Expand Up @@ -317,17 +317,13 @@ public static function formatTrace($backtrace, $options = [])
*/
public static function trimPath($path)
{
if (!defined('CAKE_CORE_INCLUDE_PATH') || !defined('APP')) {
return $path;
}

if (strpos($path, APP) === 0) {
if (defined('APP') && strpos($path, APP) === 0) {
return str_replace(APP, 'APP/', $path);
}
if (strpos($path, CAKE_CORE_INCLUDE_PATH) === 0) {
if (defined('CAKE_CORE_INCLUDE_PATH') && strpos($path, CAKE_CORE_INCLUDE_PATH) === 0) {
return str_replace(CAKE_CORE_INCLUDE_PATH, 'CORE', $path);
}
if (strpos($path, ROOT) === 0) {
if (defined('ROOT') && strpos($path, ROOT) === 0) {
return str_replace(ROOT, 'ROOT', $path);
}

Expand Down
1 change: 1 addition & 0 deletions src/Filesystem/Folder.php
Expand Up @@ -398,6 +398,7 @@ public static function addPathElement($path, $element)
*
* @param string $path The path to check.
* @return bool
* @deprecated 3.2.12 This method will be removed in 4.0.0. Use inPath() instead.
*/
public function inCakePath($path = '')
{
Expand Down
2 changes: 1 addition & 1 deletion src/I18n/MessagesFileLoader.php
Expand Up @@ -159,7 +159,7 @@ public function translationsFolders()
$searchPaths = [];

$localePaths = App::path('Locale');
if (empty($localePaths)) {
if (empty($localePaths) && defined('APP')) {
$localePaths[] = APP . 'Locale' . DIRECTORY_SEPARATOR;
}
foreach ($localePaths as $path) {
Expand Down
5 changes: 4 additions & 1 deletion src/basics.php
Expand Up @@ -50,7 +50,10 @@ function debug($var, $showHtml = null, $showFrom = true)
$lineInfo = '';
if ($showFrom) {
$trace = Debugger::trace(['start' => 1, 'depth' => 2, 'format' => 'array']);
$search = [ROOT];
$search = [];
if (defined('ROOT')) {
$search = [ROOT];
}
if (defined('CAKE_CORE_INCLUDE_PATH')) {
array_unshift($search, CAKE_CORE_INCLUDE_PATH);
}
Expand Down

0 comments on commit 8603633

Please sign in to comment.