pluginDirectory = $pluginDirectory; } public function write($manifests) { $this ->doWrite('autoload.php', $this->createLoader($manifests)) ->doWrite('services.php', $this->createServices($manifests)) ->doWrite('commands.php', $this->createCommands($manifests)) ->doWrite('twig-paths.php', $this->createTwigPathsMap($manifests)) ->doWrite('login.scss', $this->createLoginStylesheet($manifests)) ->doWrite('account.scss', $this->createAccountStylesheet($manifests)); return $this; } /** * @param Manifest[] $manifests * @return string */ private function createLoginStylesheet($manifests) { $buffer = <<pluginDirectory . DIRECTORY_SEPARATOR . $manifest->getName() . DIRECTORY_SEPARATOR . 'scss' . DIRECTORY_SEPARATOR . 'login.scss'; if (is_file($filepath)) { $relativePath = $manifest->getName() . DIRECTORY_SEPARATOR . 'scss' . DIRECTORY_SEPARATOR . 'login.scss'; $buffer .= <<pluginDirectory . DIRECTORY_SEPARATOR . $manifest->getName() . DIRECTORY_SEPARATOR . 'scss' . DIRECTORY_SEPARATOR . 'account.scss'; if (is_file($filepath)) { $relativePath = $manifest->getName() . DIRECTORY_SEPARATOR . 'scss' . DIRECTORY_SEPARATOR . 'account.scss'; $buffer .= <<pluginDirectory . DIRECTORY_SEPARATOR . $file, $data)) { throw new RegistrationFailureException(sprintf('Failed to write %s', $file)); } return $this; } /** * @param Manifest[] $manifests * @return string */ private function createLoader($manifests) { $buffer = <<getName() . DIRECTORY_SEPARATOR . "vendor" . DIRECTORY_SEPARATOR . "autoload.php"; $buffer .= <<getPluginBaseDir($manifest) . DIRECTORY_SEPARATOR . 'locale'; $textdomain = 'plugin-' . $manifest->getName(); if (is_dir($this->pluginDirectory . $localePath)) { $quotedName = $this->quote($manifest->getName()); $quotedPath = $this->quote($localePath); $pluginBuffer .= <<getServices() as $service) { $class = $service['class']; $pluginBuffer .= <<register($class::create(\$app)); EOF; } $buffer .= $this->wrapWithConditionnal($manifest, $pluginBuffer); } $buffer .= <<getName(); return " if (\$app['plugins.manager']->isEnabled('$name')) {\n" . $wrapped . " }\n"; } /** * @param Manifest[] $manifests * @return string */ private function createCommands($manifests) { $buffer = <<getCommands() as $command) { $class = $command['class']; $pluginBuffer .= <<command($class::create()); EOF; } $buffer .= $this->wrapWithConditionnal($manifest, $pluginBuffer); } $buffer .= <<quote('plugin-' . $manifest->getName()); $path = DIRECTORY_SEPARATOR . $manifest->getName() . DIRECTORY_SEPARATOR . 'views'; if (is_dir($this->pluginDirectory . $path)) { $path = $this->quote($path); $pluginBuffer .= " \$paths[$namespace] = __DIR__ . $path;\n"; } foreach ($manifest->getTwigPaths() as $path) { $path = $this->quote(DIRECTORY_SEPARATOR . $manifest->getName() . DIRECTORY_SEPARATOR . $path); $pluginBuffer .= " \$paths[] = __DIR__ . $path;\n"; } $buffer .= $this->wrapWithConditionnal($manifest, $pluginBuffer); } $buffer .= <<getName(); } }