When you have finished development register your extension at packagist.org.
EOD;
$return = $output1 . '' . highlight_string($code1, true) . '
';
$return .= $output2 . '' . highlight_string($code2, true) . '
';
$return .= $output3 . '' . highlight_string($code3, true) . '
';
$return .= $output4 . '' . highlight_string($code4, true) . '
';
$return .= $output5;
return $return;
}
/**
* {@inheritdoc}
*/
public function requiredTemplates()
{
return ['composer.json', 'AutoloadExample.php', 'README.md'];
}
/**
* {@inheritdoc}
*/
public function generate()
{
$files = [];
$modulePath = $this->getOutputPath();
$files[] = new CodeFile(
$modulePath . '/' . $this->packageName . '/composer.json',
$this->render("composer.json")
);
$files[] = new CodeFile(
$modulePath . '/' . $this->packageName . '/AutoloadExample.php',
$this->render("AutoloadExample.php")
);
$files[] = new CodeFile(
$modulePath . '/' . $this->packageName . '/README.md',
$this->render("README.md")
);
return $files;
}
/**
* @return bool the directory that contains the module class
*/
public function getOutputPath()
{
return Yii::getAlias(str_replace('\\', '/', $this->outputPath));
}
/**
* @return string a json encoded array with the given keywords
*/
public function getKeywordsArrayJson()
{
return json_encode(explode(',', $this->keywords), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}
/**
* @return array options for type drop-down
*/
public function optsType()
{
$types = [
'yii2-extension',
'library',
];
return array_combine($types, $types);
}
/**
* @return array options for license drop-down
*/
public function optsLicense()
{
$licenses = [
'Apache-2.0',
'BSD-2-Clause',
'BSD-3-Clause',
'BSD-4-Clause',
'GPL-2.0',
'GPL-2.0+',
'GPL-3.0',
'GPL-3.0+',
'LGPL-2.1',
'LGPL-2.1+',
'LGPL-3.0',
'LGPL-3.0+',
'MIT'
];
return array_combine($licenses, $licenses);
}
}