/**
* Install the project class files
*
* @param \Pop\Config $install
* @param string $installDir
* @return void
*/
public static function install($install, $installDir)
{
// Create the project class file
$projectCls = new Generator($install->project->base . '/module/' . $install->project->name . '/src/' . $install->project->name . '/Project.php', Generator::CREATE_CLASS);
// Set namespace
$ns = new NamespaceGenerator($install->project->name);
$ns->setUse('Pop\\Project\\Project', 'P');
// Create 'run' method
$run = new MethodGenerator('run');
$run->setDesc('Add any project specific code to this method for run-time use here.');
$run->appendToBody('parent::run();', false);
$run->getDocblock()->setReturn('void');
// Finalize the project config file and save it
$projectCls->setNamespace($ns);
$projectCls->code()->setParent('P')->addMethod($run);
$projectCls->save();
$input = self::installWeb();
// Install any web config and controller files
if ($input != 'n') {
if (file_exists(__DIR__ . '/Web/index.php')) {
$index = new Generator(__DIR__ . '/Web/index.php');
$contents = $index->read() . '// Run the project' . PHP_EOL . 'try {' . PHP_EOL . ' $project->run();' . PHP_EOL . '} catch (\\Exception $e) {' . PHP_EOL . ' echo $e->getMessage();' . PHP_EOL . '}' . PHP_EOL;
file_put_contents($install->project->docroot . '/index.php', $contents);
}
if ($input == 'a') {
if (file_exists(__DIR__ . '/Web/ht.access')) {
copy(__DIR__ . '/Web/ht.access', $install->project->docroot . '/.htaccess');
}
} else {
if ($input == 'i') {
if (file_exists(__DIR__ . '/Web/web.config')) {
copy(__DIR__ . '/Web/web.config', $install->project->docroot . '/web.config');
}
} else {
echo \Pop\I18n\I18n::factory()->__('You will have to install your web server rewrite configuration manually.') . PHP_EOL;
}
}
}
}