Skip to content

Commit

Permalink
Initial commit to test composer installation
Browse files Browse the repository at this point in the history
  • Loading branch information
axyr committed Nov 15, 2013
1 parent c132d01 commit 750fcff
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
3 changes: 3 additions & 0 deletions _config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

Requirements::set_backend(new ModuleRequirements_Backend());
37 changes: 37 additions & 0 deletions code/ModuleRequirements_Backend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

class ModuleRequirements_Backend extends Requirements_Backend {

protected function path_for_file($fileOrUrl) {
if(preg_match('{^//|http[s]?}', $fileOrUrl)) {
return $fileOrUrl;

} else {
if(!Director::fileExists($fileOrUrl)) {
$fileOrUrl = MODULES_DIR . '/' . $fileOrUrl;
}
if(Director::fileExists($fileOrUrl)) {
$filePath = preg_replace('/\?.*/', '', Director::baseFolder() . '/' . $fileOrUrl);
$prefix = Director::baseURL();
$mtimesuffix = "";
$suffix = '';
if($this->suffix_requirements) {
$mtimesuffix = "?m=" . filemtime($filePath);
$suffix = '&';
}
if(strpos($fileOrUrl, '?') !== false) {
if (strlen($suffix) == 0) {
$suffix = '?';
}
$suffix .= substr($fileOrUrl, strpos($fileOrUrl, '?')+1);
$fileOrUrl = substr($fileOrUrl, 0, strpos($fileOrUrl, '?'));
} else {
$suffix = '';
}
return "{$prefix}{$fileOrUrl}{$mtimesuffix}{$suffix}";
} else {
return false;
}
}
}
}
25 changes: 25 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "axyr/silverstripe-modulefolder",
"description": "Install modules in the 'modules' folder instead of root",
"type": "silverstripe-module",
"keywords": ["silverstripe", "module", "cms"],
"license": "BSD-3-Clause",
"authors": [
{
"name": "Martijn van Nieuwenhoven",
"email": "[email protected]"
}
],
"require":
{
"silverstripe/framework": "~3.1"
},
"extra": {
"installer-paths": {
"cms/": ["silverstripe/cms"],
"framework/": ["silverstripe/framework"],
"modules/": ["axyr/silverstripe-modulefolder"],
"modules/{$name}/": ["type:silverstripe-module"]
}
}
}

0 comments on commit 750fcff

Please sign in to comment.