Skip to content

Commit

Permalink
Make resource loader modules work from /vendor/, too
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianheine committed Nov 6, 2014
1 parent b42e6ef commit 21f5911
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
9 changes: 6 additions & 3 deletions DataValuesJavascript.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 6 additions & 3 deletions lib/resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 6 additions & 3 deletions src/resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 6 additions & 3 deletions src/valueFormatters/resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 6 additions & 3 deletions src/valueParsers/resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 21f5911

Please sign in to comment.