Example - generate a plugin directory containing the plugin.php file. The file is created from a template, which uses a couple of variables. $structure = [ 'author', 'author/plugin', 'author/plugin/plugin.php' => 'plugin.php.tpl' ]; $generator = new FilesystemGenerator('$', $structure, '$/Author/Plugin/templates/plugin'); $variables = [ 'namespace' => 'Author/Plugin' ]; $generator->setVariables($variables); $generator->generate();
Автор: Alexey Bobkov, Samuel Georges
 /**
  * @expectedException        October\Rain\Exception\SystemException
  * @expectedExceptionMessage found
  */
 public function testTemplateNotFound()
 {
     $generatedDir = $this->getFixturesDir('temporary/generated');
     $this->assertFileNotExists($generatedDir);
     File::makeDirectory($generatedDir, 0777, true, true);
     $this->assertFileExists($generatedDir);
     $structure = ['plugin.php' => 'null.tpl'];
     $generator = new FilesystemGenerator($generatedDir, $structure);
     $generator->generate();
 }
Пример #2
0
 public function save()
 {
     $this->validate();
     $modelFilePath = $this->getFilePath();
     $namespace = $this->getPluginCodeObj()->toPluginNamespace() . '\\Models';
     $structure = [$modelFilePath => 'model.php.tpl'];
     $variables = ['namespace' => $namespace, 'classname' => $this->className, 'table' => $this->databaseTable];
     $generator = new FilesystemGenerator('$', $structure, '$/rainlab/builder/classes/modelmodel/templates');
     $generator->setVariables($variables);
     $generator->generate();
 }
Пример #3
0
 protected function initPluginStructure()
 {
     $basePath = $this->getPluginPath();
     $defaultLanguage = LocalizationModel::getDefaultLanguage();
     $structure = [$basePath . '/Plugin.php' => 'plugin.php.tpl', $basePath . '/updates/version.yaml' => 'version.yaml.tpl', $basePath . '/classes', $basePath . '/lang/' . $defaultLanguage . '/lang.php' => 'lang.php.tpl'];
     $variables = ['authorNamespace' => $this->author_namespace, 'pluginNamespace' => $this->namespace, 'pluginNameSanitized' => $this->sanitizePHPString($this->localizedName), 'pluginDescriptionSanitized' => $this->sanitizePHPString($this->localizedDescription)];
     $generator = new FilesystemGenerator('$', $structure, '$/rainlab/builder/classes/pluginbasemodel/templates');
     $generator->setVariables($variables);
     $generator->generate();
 }