setVariables() публичный Метод

public setVariables ( $variables )
Пример #1
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();
 }
 public function testGenerate()
 {
     $generatedDir = $this->getFixturesDir('temporary/generated');
     $this->assertFileNotExists($generatedDir);
     File::makeDirectory($generatedDir, 0777, true, true);
     $this->assertFileExists($generatedDir);
     $structure = ['author', 'author/plugin', 'author/plugin/plugin.php' => 'plugin.php.tpl', 'author/plugin/classes'];
     $templatesDir = $this->getFixturesDir('templates');
     $generator = new FilesystemGenerator($generatedDir, $structure, $templatesDir);
     $variables = ['authorNamespace' => 'Author', 'pluginNamespace' => 'Plugin'];
     $generator->setVariables($variables);
     $generator->setVariable('className', 'TestClass');
     $generator->generate();
     $this->assertFileExists($generatedDir . '/author/plugin/plugin.php');
     $this->assertFileExists($generatedDir . '/author/plugin/classes');
     $content = file_get_contents($generatedDir . '/author/plugin/plugin.php');
     $this->assertContains('Author\\Plugin', $content);
     $this->assertContains('TestClass', $content);
 }
Пример #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();
 }