Skip to content

Instantly share code, notes, and snippets.

@sunel
Created June 28, 2016 04:29
Show Gist options
  • Save sunel/fb4551be185eddfa9c45be94168613c4 to your computer and use it in GitHub Desktop.
Save sunel/fb4551be185eddfa9c45be94168613c4 to your computer and use it in GitHub Desktop.
Autoload problem
{
"name": "thl/admin-module",
"type": "thl-module",
"description": "The admin module.",
"keywords": [
"thl",
"core"
],
"license": "MIT",
"authors": [
{
"name": "Sunel TR",
"email": "sunelbe@gmail.com"
}
],
"require": {
"php": ">=5.5",
"thl/composer-installer": "dev-master"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"suggest": {
},
"autoload-dev": {
"psr-4": {
"Modules\\Admin\\": "src/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
<?php
namespace THL\Installer;
class ThlInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'Modules/{$name}/',
'theme' => 'Themes/{$name}/'
);
/**
* Format package name.
*
* For package type asgard-module, cut off a trailing '-plugin' if present.
*
* For package type asgard-theme, cut off a trailing '-theme' if present.
*
*/
public function inflectPackageVars($vars)
{
if ($vars['type'] === 'thl-module') {
return $this->inflectPluginVars($vars);
}
if ($vars['type'] === 'thl-theme') {
return $this->inflectThemeVars($vars);
}
return $vars;
}
protected function inflectPluginVars($vars)
{
$vars['name'] = ucfirst(preg_replace('/-module/', '', $vars['name']));
return $vars;
}
protected function inflectThemeVars($vars)
{
$vars['name'] = ucfirst(preg_replace('/-theme$/', '', $vars['name']));
return $vars;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment