Foxtrott has uploaded a new change for review.
https://gerrit.wikimedia.org/r/172105
Change subject: Use relative paths
......................................................................
Use relative paths
This will enable installation of the extension in other directories then the
standard .../extensions. However it still expects some layout assumptions to be
true. The expected layout is
+- extensions
| +- Bootstrap
+- vendor
+- twitter
+- bootstrap
This patch enables bundling the extension and its dependencies as a package (tar
file or whatever).
Change-Id: Ib2d68a3ba3e7e27fa2c0da65c82586a00aaef713
---
M Bootstrap.php
M src/Hooks/SetupAfterCache.php
M tests/phpunit/Hooks/SetupAfterCacheTest.php
3 files changed, 17 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Bootstrap
refs/changes/05/172105/1
diff --git a/Bootstrap.php b/Bootstrap.php
index 1e474d7..96ee9a7 100644
--- a/Bootstrap.php
+++ b/Bootstrap.php
@@ -49,7 +49,7 @@
/**
* The extension version
*/
- define( 'BS_VERSION', '1.0.1' );
+ define( 'BS_VERSION', '1.0.2-alpha' );
// register the extension
$GLOBALS[ 'wgExtensionCredits' ][ 'other' ][ ] = array(
@@ -74,10 +74,9 @@
$GLOBALS[ 'wgHooks' ][ 'SetupAfterCache' ][ ] = function() {
- $configuration = array(
- 'localBasePath' => $GLOBALS[ 'IP' ] .
'/vendor/twitter/bootstrap',
- 'remoteBasePath' => $GLOBALS[ 'wgScriptPath' ] .
'/vendor/twitter/bootstrap'
- );
+ $configuration = array();
+ $configuration[ 'localBasePath' ] = str_replace(
DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR . 'Bootstrap',
'/vendor/twitter/bootstrap', __DIR__ );
+ $configuration[ 'remoteBasePath' ] = str_replace( $GLOBALS[
'IP' ], $GLOBALS[ 'wgScriptPath' ], $configuration[ 'localBasePath' ] );
$setupAfterCache = new \Bootstrap\Hooks\SetupAfterCache(
$configuration );
$setupAfterCache->process();
diff --git a/src/Hooks/SetupAfterCache.php b/src/Hooks/SetupAfterCache.php
index 6eecfb5..1554b0d 100644
--- a/src/Hooks/SetupAfterCache.php
+++ b/src/Hooks/SetupAfterCache.php
@@ -76,6 +76,8 @@
/**
* Add paths to resource modules if they are not there yet (e.g. set in
LocalSettings.php)
+ * @param string $localBasePath
+ * @param string $remoteBasePath
*/
protected function registerBootstrapResourcePaths( $localBasePath,
$remoteBasePath ) {
@@ -121,10 +123,19 @@
}
+ /**
+ * @param string $id
+ * @return bool
+ */
protected function hasConfiguration( $id ) {
return isset( $this->configuration[ $id ] );
}
+ /**
+ * @param string $localBasePath
+ * @return string
+ * @throws RuntimeException
+ */
protected function isReadablePath( $localBasePath ) {
$localBasePath = str_replace( array( '\\', '/' ),
DIRECTORY_SEPARATOR, $localBasePath );
diff --git a/tests/phpunit/Hooks/SetupAfterCacheTest.php
b/tests/phpunit/Hooks/SetupAfterCacheTest.php
index 2067bae..f3549f5 100644
--- a/tests/phpunit/Hooks/SetupAfterCacheTest.php
+++ b/tests/phpunit/Hooks/SetupAfterCacheTest.php
@@ -20,10 +20,11 @@
class SetupAfterCacheTest extends \PHPUnit_Framework_TestCase {
protected $localBasePath = null;
+ protected $localBootstrapVendorPath = null;
protected function setUp() {
parent::setUp();
- $this->localBootstrapVendorPath = $GLOBALS[ 'IP' ] .
'/vendor/twitter/bootstrap';
+ $this->localBootstrapVendorPath = __DIR__ .
'/../../../../../vendor/twitter/bootstrap';
}
public function testCanConstruct() {
--
To view, visit https://gerrit.wikimedia.org/r/172105
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib2d68a3ba3e7e27fa2c0da65c82586a00aaef713
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Bootstrap
Gerrit-Branch: master
Gerrit-Owner: Foxtrott <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits