From 21f591162e9eb531986a0e4a86d136b38d587e90 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 6 Nov 2014 15:28:51 +0100 Subject: [PATCH] Make resource loader modules work from /vendor/, too --- DataValuesJavascript.php | 9 ++++++--- lib/resources.php | 9 ++++++--- src/resources.php | 9 ++++++--- src/valueFormatters/resources.php | 9 ++++++--- src/valueParsers/resources.php | 9 ++++++--- 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/DataValuesJavascript.php b/DataValuesJavascript.php index e4abbe2..a442596 100644 --- a/DataValuesJavascript.php +++ b/DataValuesJavascript.php @@ -48,13 +48,16 @@ array &$testModules, \ResourceLoader &$resourceLoader ) { - $remoteExtPathParts = explode( - DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR, __DIR__, 2 + preg_match( + '+^.*?' . preg_quote( DIRECTORY_SEPARATOR, '+' ) . '((?:vendor|extensions)' . + preg_quote( DIRECTORY_SEPARATOR, '+' ) . '.*)$+', + __DIR__, + $remoteExtPathParts ); $moduleTemplate = array( 'localBasePath' => __DIR__ . '/tests', - 'remoteExtPath' => $remoteExtPathParts[1] . '/tests', + 'remoteExtPath' => '..' . DIRECTORY_SEPARATOR . $remoteExtPathParts[1] . DIRECTORY_SEPARATOR . 'tests', ); $testModuleTemplates = array( diff --git a/lib/resources.php b/lib/resources.php index 456ff89..ba5eca1 100644 --- a/lib/resources.php +++ b/lib/resources.php @@ -7,13 +7,16 @@ * @codeCoverageIgnoreStart */ return call_user_func( function() { - $remoteExtPathParts = explode( - DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR, __DIR__, 2 + preg_match( + '+^.*?' . preg_quote( DIRECTORY_SEPARATOR, '+' ) . '((?:vendor|extensions)' . + preg_quote( DIRECTORY_SEPARATOR, '+' ) . '.*)$+', + __DIR__, + $remoteExtPathParts ); $moduleTemplate = array( 'localBasePath' => __DIR__, - 'remoteExtPath' => $remoteExtPathParts[1] + 'remoteExtPath' => '..' . DIRECTORY_SEPARATOR . $remoteExtPathParts[1] ); return array( diff --git a/src/resources.php b/src/resources.php index 6d091d3..1bed3b4 100644 --- a/src/resources.php +++ b/src/resources.php @@ -7,13 +7,16 @@ * @codeCoverageIgnoreStart */ return call_user_func( function() { - $remoteExtPathParts = explode( - DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR, __DIR__, 2 + preg_match( + '+^.*?' . preg_quote( DIRECTORY_SEPARATOR, '+' ) . '((?:vendor|extensions)' . + preg_quote( DIRECTORY_SEPARATOR, '+' ) . '.*)$+', + __DIR__, + $remoteExtPathParts ); $moduleTemplate = array( 'localBasePath' => __DIR__, - 'remoteExtPath' => $remoteExtPathParts[1], + 'remoteExtPath' => '..' . DIRECTORY_SEPARATOR . $remoteExtPathParts[1], ); $modules = array( diff --git a/src/valueFormatters/resources.php b/src/valueFormatters/resources.php index b4d44c5..a8b0a63 100644 --- a/src/valueFormatters/resources.php +++ b/src/valueFormatters/resources.php @@ -6,13 +6,16 @@ * @codeCoverageIgnoreStart */ return call_user_func( function() { - $remoteExtPathParts = explode( - DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR, __DIR__, 2 + preg_match( + '+^.*?' . preg_quote( DIRECTORY_SEPARATOR, '+' ) . '((?:vendor|extensions)' . + preg_quote( DIRECTORY_SEPARATOR, '+' ) . '.*)$+', + __DIR__, + $remoteExtPathParts ); $moduleTemplate = array( 'localBasePath' => __DIR__, - 'remoteExtPath' => $remoteExtPathParts[1], + 'remoteExtPath' => '..' . DIRECTORY_SEPARATOR . $remoteExtPathParts[1], ); return array( diff --git a/src/valueParsers/resources.php b/src/valueParsers/resources.php index c4fb13d..45077f2 100644 --- a/src/valueParsers/resources.php +++ b/src/valueParsers/resources.php @@ -7,13 +7,16 @@ * @codeCoverageIgnoreStart */ return call_user_func( function() { - $remoteExtPathParts = explode( - DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR, __DIR__, 2 + preg_match( + '+^.*?' . preg_quote( DIRECTORY_SEPARATOR, '+' ) . '((?:vendor|extensions)' . + preg_quote( DIRECTORY_SEPARATOR, '+' ) . '.*)$+', + __DIR__, + $remoteExtPathParts ); $moduleTemplate = array( 'localBasePath' => __DIR__, - 'remoteExtPath' => $remoteExtPathParts[1], + 'remoteExtPath' => '..' . DIRECTORY_SEPARATOR . $remoteExtPathParts[1], ); return array(