diff --git a/assets/enhavo/lib/Nginx/Components/IndexComponent.vue b/assets/enhavo/lib/Nginx/Components/IndexComponent.vue
new file mode 100644
index 0000000..b022d0e
--- /dev/null
+++ b/assets/enhavo/lib/Nginx/Components/IndexComponent.vue
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
diff --git a/assets/enhavo/media-library.ts b/assets/enhavo/media-library.ts
deleted file mode 100644
index 9f403aa..0000000
--- a/assets/enhavo/media-library.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import Application from "@enhavo/media/MediaLibrary/MediaLibraryApplication";
-Application.getVueLoader().load(() => import("@enhavo/media/MediaLibrary/Components/ApplicationComponent.vue"));
\ No newline at end of file
diff --git a/assets/enhavo/nginx.ts b/assets/enhavo/nginx.ts
new file mode 100644
index 0000000..650b7dc
--- /dev/null
+++ b/assets/enhavo/nginx.ts
@@ -0,0 +1,7 @@
+import Application from "@enhavo/app/Index/IndexApplication";
+import ActionRegistryPackage from "./registry/action";
+import ModalRegistryPackage from "./registry/modal";
+
+Application.getActionRegistry().registerPackage(new ActionRegistryPackage(Application));
+Application.getModalRegistry().registerPackage(new ModalRegistryPackage(Application));
+Application.getVueLoader().load(() => import("./lib/Nginx/Components/IndexComponent.vue"));
\ No newline at end of file
diff --git a/assets/enhavo/registry/action.ts b/assets/enhavo/registry/action.ts
new file mode 100644
index 0000000..c56b864
--- /dev/null
+++ b/assets/enhavo/registry/action.ts
@@ -0,0 +1,11 @@
+import RegistryPackage from "@enhavo/core/RegistryPackage";
+import ApplicationInterface from "@enhavo/app/ApplicationInterface";
+import AppActionRegistryPackage from "@enhavo/app/Action/ActionRegistryPackage";
+
+export default class ActionRegistryPackage extends RegistryPackage
+{
+ constructor(application: ApplicationInterface) {
+ super();
+ this.registerPackage(new AppActionRegistryPackage(application));
+ }
+}
\ No newline at end of file
diff --git a/assets/enhavo/registry/batch.ts b/assets/enhavo/registry/batch.ts
new file mode 100644
index 0000000..20eeaeb
--- /dev/null
+++ b/assets/enhavo/registry/batch.ts
@@ -0,0 +1,11 @@
+import RegistryPackage from "@enhavo/core/RegistryPackage";
+import ApplicationInterface from "@enhavo/app/ApplicationInterface";
+import AppBatchRegistryPackage from "@enhavo/app/Grid/Batch/BatchRegistryPackage";
+
+export default class BatchRegistryPackage extends RegistryPackage
+{
+ constructor(application: ApplicationInterface) {
+ super();
+ this.registerPackage(new AppBatchRegistryPackage(application));
+ }
+}
\ No newline at end of file
diff --git a/assets/enhavo/registry/column.ts b/assets/enhavo/registry/column.ts
new file mode 100644
index 0000000..630f84d
--- /dev/null
+++ b/assets/enhavo/registry/column.ts
@@ -0,0 +1,11 @@
+import RegistryPackage from "@enhavo/core/RegistryPackage";
+import ApplicationInterface from "@enhavo/app/ApplicationInterface";
+import AppColumnRegistryPackage from "@enhavo/app/Grid/Column/ColumnRegistryPackage";
+
+export default class ColumnRegistryPackage extends RegistryPackage
+{
+ constructor(application: ApplicationInterface) {
+ super();
+ this.registerPackage(new AppColumnRegistryPackage(application));
+ }
+}
\ No newline at end of file
diff --git a/assets/enhavo/registry/filter.ts b/assets/enhavo/registry/filter.ts
new file mode 100644
index 0000000..e1827e7
--- /dev/null
+++ b/assets/enhavo/registry/filter.ts
@@ -0,0 +1,11 @@
+import RegistryPackage from "@enhavo/core/RegistryPackage";
+import ApplicationInterface from "@enhavo/app/ApplicationInterface";
+import AppFilterRegistryPackage from "@enhavo/app/Grid/Filter/FilterRegistryPackage";
+
+export default class FilterRegistryPackage extends RegistryPackage
+{
+ constructor(application: ApplicationInterface) {
+ super();
+ this.registerPackage(new AppFilterRegistryPackage(application));
+ }
+}
\ No newline at end of file
diff --git a/assets/enhavo/registry/form.ts b/assets/enhavo/registry/form.ts
new file mode 100644
index 0000000..ad24f0a
--- /dev/null
+++ b/assets/enhavo/registry/form.ts
@@ -0,0 +1,13 @@
+import RegistryPackage from "@enhavo/app/Form/RegistryPackage";
+import ApplicationInterface from "@enhavo/app/ApplicationInterface";
+import FormFormRegistryPackage from "@enhavo/form/FormRegistryPackage";
+import MediaFormRegistryPackage from "@enhavo/media/FormRegistryPackage";
+
+export default class FormRegistryPackage extends RegistryPackage
+{
+ constructor(application: ApplicationInterface) {
+ super();
+ this.registerPackage(new FormFormRegistryPackage(application));
+ this.registerPackage(new MediaFormRegistryPackage(application));
+ }
+}
\ No newline at end of file
diff --git a/assets/enhavo/registry/menu.ts b/assets/enhavo/registry/menu.ts
new file mode 100644
index 0000000..d9f9f4a
--- /dev/null
+++ b/assets/enhavo/registry/menu.ts
@@ -0,0 +1,11 @@
+import RegistryPackage from "@enhavo/core/RegistryPackage";
+import ApplicationInterface from "@enhavo/app/ApplicationInterface";
+import AppMenuRegistryPackage from "@enhavo/app/Menu/MenuRegistryPackage";
+
+export default class MenuRegistryPackage extends RegistryPackage
+{
+ constructor(application: ApplicationInterface) {
+ super();
+ this.registerPackage(new AppMenuRegistryPackage(application));
+ }
+}
\ No newline at end of file
diff --git a/assets/enhavo/registry/modal.ts b/assets/enhavo/registry/modal.ts
new file mode 100644
index 0000000..5b74f9f
--- /dev/null
+++ b/assets/enhavo/registry/modal.ts
@@ -0,0 +1,11 @@
+import RegistryPackage from "@enhavo/core/RegistryPackage";
+import ApplicationInterface from "@enhavo/app/ApplicationInterface";
+import AppModalRegistryPackage from "@enhavo/app/Modal/ModalRegistryPackage";
+
+export default class ModalRegistryPackage extends RegistryPackage
+{
+ constructor(application: ApplicationInterface) {
+ super();
+ this.registerPackage(new AppModalRegistryPackage(application));
+ }
+}
\ No newline at end of file
diff --git a/assets/enhavo/registry/view.ts b/assets/enhavo/registry/view.ts
new file mode 100644
index 0000000..bf20cd3
--- /dev/null
+++ b/assets/enhavo/registry/view.ts
@@ -0,0 +1,11 @@
+import RegistryPackage from "@enhavo/core/RegistryPackage";
+import ApplicationInterface from "@enhavo/app/ApplicationInterface";
+import AppViewRegistryPackage from "@enhavo/app/ViewStack/ViewRegistryPackage";
+
+export default class ViewRegistryPackage extends RegistryPackage
+{
+ constructor(application: ApplicationInterface) {
+ super();
+ this.registerPackage(new AppViewRegistryPackage(application));
+ }
+}
\ No newline at end of file
diff --git a/config/routes/app_host.yml b/config/routes/app_host.yml
index 7ba7075..5c9f6ee 100644
--- a/config/routes/app_host.yml
+++ b/config/routes/app_host.yml
@@ -14,6 +14,7 @@ app_host_create:
defaults:
_controller: app.controller.host:createAction
_sylius:
+ redirect: app_host_update
viewer:
tabs:
main:
@@ -39,7 +40,7 @@ app_host_update:
label: Host
template: admin/resource/host/main.html.twig
backend:
- label: Host
+ label: Backend
template: admin/resource/host/backend.html.twig
certificate:
label: Certificate
diff --git a/config/routes/app_nginx.yml b/config/routes/app_nginx.yml
index 0496ae8..5f1ff9e 100644
--- a/config/routes/app_nginx.yml
+++ b/config/routes/app_nginx.yml
@@ -1,23 +1,28 @@
-project_nginx_well_known:
+app_nginx_index:
+ path: /nginx/index
+ defaults:
+ _controller: App\Controller\NginxController:indexAction
+
+app_nginx_well_known:
options:
expose: true
path: /.well-known/acme-challenge/{token}
methods: [GET]
defaults:
- _controller: App:Nginx:wellKnown
+ _controller: App\Controller\NginxController:wellKnownAction
-project_nginx_restart:
+app_nginx_restart:
options:
expose: true
path: /nginx/restart
methods: [GET]
defaults:
- _controller: App:Nginx:restart
+ _controller: App\Controller\NginxController:restartAction
-project_nginx_compile:
+app_nginx_compile:
options:
expose: true
path: /nginx/compile
methods: [GET]
defaults:
- _controller: App:Nginx:compile
\ No newline at end of file
+ _controller: App\Controller\NginxController:compileAction
\ No newline at end of file
diff --git a/config/services.yaml b/config/services.yaml
index 2b81fc5..06bfd1a 100644
--- a/config/services.yaml
+++ b/config/services.yaml
@@ -2,6 +2,7 @@ parameters:
locale: 'en'
imports:
+ - { resource: services/command.yml }
- { resource: services/generel.yml }
- { resource: services/form.yml }
- { resource: services/manager.yml }
diff --git a/config/services/command.yml b/config/services/command.yml
new file mode 100644
index 0000000..8e09595
--- /dev/null
+++ b/config/services/command.yml
@@ -0,0 +1,63 @@
+services:
+ App\Command\CertificateCheckCommand:
+ calls:
+ - ['setContainer', ['@service_container']]
+ - ['setLogger', ['@logger']]
+ tags:
+ - { name: console.command }
+
+ App\Command\CertificateCronJobCommand:
+ calls:
+ - ['setContainer', ['@service_container']]
+ - ['setLogger', ['@logger']]
+ tags:
+ - { name: console.command }
+
+ App\Command\CertificateDumpCommand:
+ calls:
+ - ['setContainer', ['@service_container']]
+ - ['setLogger', ['@logger']]
+ tags:
+ - { name: console.command }
+
+ App\Command\CertificateRenewCommand:
+ calls:
+ - ['setContainer', ['@service_container']]
+ - ['setLogger', ['@logger']]
+ tags:
+ - { name: console.command }
+
+ App\Command\NginxCompileCommand:
+ calls:
+ - ['setContainer', ['@service_container']]
+ - ['setLogger', ['@logger']]
+ tags:
+ - { name: console.command }
+
+ App\Command\NginxRestartCommand:
+ calls:
+ - ['setContainer', ['@service_container']]
+ - ['setLogger', ['@logger']]
+ tags:
+ - { name: console.command }
+
+ App\Command\VarnishCompileCommand:
+ calls:
+ - ['setContainer', ['@service_container']]
+ - ['setLogger', ['@logger']]
+ tags:
+ - { name: console.command }
+
+ App\Command\VarnishCreateSecretCommand:
+ calls:
+ - ['setContainer', ['@service_container']]
+ - ['setLogger', ['@logger']]
+ tags:
+ - { name: console.command }
+
+ App\Command\VarnishRestartCommand:
+ calls:
+ - ['setContainer', ['@service_container']]
+ - ['setLogger', ['@logger']]
+ tags:
+ - { name: console.command }
\ No newline at end of file
diff --git a/config/services/generel.yml b/config/services/generel.yml
index 441bd0c..27bf748 100644
--- a/config/services/generel.yml
+++ b/config/services/generel.yml
@@ -22,3 +22,37 @@ services:
App\Certificate\CertificateFactory:
public: true
+ App\Controller\NginxController:
+ public: true
+ arguments:
+ - '@view.factory'
+ - '@fos_rest.view_handler'
+ calls:
+ - ['setContainer', ['@service_container']]
+ tags:
+ - { name: controller.service_arguments }
+
+ App\Controller\VarnishController:
+ public: true
+ calls:
+ - ['setContainer', ['@service_container']]
+ tags:
+ - { name: controller.service_arguments }
+
+ App\Viewer\VarnishViewer:
+ public: true
+ arguments:
+ - '@enhavo_app.action_manager'
+ calls:
+ - ['setContainer', ['@service_container']]
+ tags:
+ - { name: enhavo.viewer, alias: 'varnish' }
+
+ App\Viewer\NginxViewer:
+ public: true
+ arguments:
+ - '@enhavo_app.action_manager'
+ calls:
+ - ['setContainer', ['@service_container']]
+ tags:
+ - { name: enhavo.viewer, alias: 'nginx' }
diff --git a/config/services/manager.yml b/config/services/manager.yml
index acdf24e..9eadb54 100644
--- a/config/services/manager.yml
+++ b/config/services/manager.yml
@@ -3,20 +3,24 @@ services:
public: true:
calls:
- ['setContainer', ['@service_container']]
+ - ['setLogger', ['@logger']]
App\Manager\VarnishManager:
public: true
calls:
- ['setContainer', ['@service_container']]
+ - ['setLogger', ['@logger']]
App\Manager\NginxManager:
public: true
calls:
- ['setContainer', ['@service_container']]
+ - ['setLogger', ['@logger']]
App\Manager\CertificateManager:
public: true
calls:
- ['setContainer', ['@service_container']]
+ - ['setLogger', ['@logger']]
diff --git a/src/Command/AbstractCommand.php b/src/Command/AbstractCommand.php
index 1ac5f75..f879224 100644
--- a/src/Command/AbstractCommand.php
+++ b/src/Command/AbstractCommand.php
@@ -9,6 +9,8 @@
namespace App\Command;
use App\Logger\OutputHandler;
+use Monolog\Logger;
+use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
@@ -17,15 +19,36 @@ abstract class AbstractCommand extends Command
{
use ContainerAwareTrait;
+ /**
+ * @var Logger
+ */
+ private $logger;
+
+ /**
+ * @return LoggerInterface
+ */
+ public function getLogger(): LoggerInterface
+ {
+ return $this->logger;
+ }
+
+ /**
+ * @param LoggerInterface $logger
+ */
+ public function setLogger(LoggerInterface $logger): void
+ {
+ $this->logger = $logger;
+ }
+
public function pushOutputHandler(OutputInterface $output)
{
$handler = new OutputHandler();
$handler->setOutput($output);
- $this->container->get('logger')->pushHandler($handler);
+ $this->logger->pushHandler($handler);
}
public function popHandler()
{
- $this->container->get('logger')->popHandler();
+ $this->logger->popHandler();
}
}
diff --git a/src/Controller/NginxController.php b/src/Controller/NginxController.php
index ddb9be1..82c938c 100644
--- a/src/Controller/NginxController.php
+++ b/src/Controller/NginxController.php
@@ -10,12 +10,26 @@
use App\Manager\CertificateManager;
use App\Manager\NginxManager;
+use Enhavo\Bundle\AppBundle\Controller\AbstractViewController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\StreamedResponse;
+use Enhavo\Bundle\AppBundle\Output\EchoStreamOutput;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Bundle\FrameworkBundle\Console\Application;
+use Symfony\Component\Console\Input\ArrayInput;
-class NginxController extends AbstractController
+class NginxController extends AbstractViewController
{
+ public function indexAction()
+ {
+ $view = $this->viewFactory->create('nginx', [
+
+ ]);
+
+ return $this->viewHandler->handle($view);
+ }
+
public function wellKnownAction(Request $request)
{
$token = $request->get('token');
@@ -28,21 +42,33 @@ public function wellKnownAction(Request $request)
public function restartAction()
{
- $controller = $this;
- return new StreamedResponse(function() use ($controller) {
- $controller->pushEchoHandler();
- $controller->getManager()->reload();
- $controller->popHandler();
+ $application = new Application($this->container->get('kernel'));
+ $application->setAutoExit(false);
+
+ return new StreamedResponse(function() use ($application) {
+
+ $input = new ArrayInput([
+ 'command' => 'proxy:nginx:restart',
+ ]);
+
+ $output = new EchoStreamOutput(fopen('php://stdout', 'w'), OutputInterface::VERBOSITY_NORMAL, true);
+ $application->run($input, $output);
});
}
public function compileAction()
{
- $controller = $this;
- return new StreamedResponse(function() use ($controller) {
- $controller->pushEchoHandler();
- $controller->getManager()->compile();
- $controller->popHandler();
+ $application = new Application($this->container->get('kernel'));
+ $application->setAutoExit(false);
+
+ return new StreamedResponse(function() use ($application) {
+
+ $input = new ArrayInput([
+ 'command' => 'proxy:nginx:compile',
+ ]);
+
+ $output = new EchoStreamOutput(fopen('php://stdout', 'w'), OutputInterface::VERBOSITY_NORMAL, true);
+ $application->run($input, $output);
});
}
@@ -51,6 +77,6 @@ public function compileAction()
*/
private function getManager()
{
- return $this->container->get('manager.nginx');
+ return $this->container->get(NginxManager::class);
}
}
diff --git a/src/Form/Type/HostType.php b/src/Form/Type/HostType.php
index aa6fc1e..b3e7896 100644
--- a/src/Form/Type/HostType.php
+++ b/src/Form/Type/HostType.php
@@ -8,7 +8,6 @@
namespace App\Form\Type;
-
use Enhavo\Bundle\FormBundle\Form\Type\BooleanType;
use Enhavo\Bundle\FormBundle\Form\Type\ListType;
use App\Entity\Host;
@@ -55,9 +54,9 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder->add('certificateKey', TextareaType::class);
$builder->add('certificateType', ChoiceType::class, [
'choices'=> [
- 'None' => Host::CERTIFICATE_TYPE_NONE,
+ 'SSL' => Host::CERTIFICATE_TYPE_NONE,
'Lets Encrypt' => Host::CERTIFICATE_TYPE_LETS_ENCRYPT,
]
]);
}
-}
\ No newline at end of file
+}
diff --git a/src/Manager/AbstractManager.php b/src/Manager/AbstractManager.php
index e635f7c..13aea93 100644
--- a/src/Manager/AbstractManager.php
+++ b/src/Manager/AbstractManager.php
@@ -8,6 +8,7 @@
namespace App\Manager;
+use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\Process;
@@ -21,6 +22,11 @@ abstract class AbstractManager
*/
private $fs;
+ /**
+ * @var LoggerInterface
+ */
+ private $logger;
+
/**
* @param string $command
* @return string
@@ -28,7 +34,7 @@ abstract class AbstractManager
protected function executeCommand($command)
{
$this->getLogger()->error(sprintf('Execute command "%s"', $command));
- $process = new Process($command);
+ $process = new Process([$command]);
$process->run();
if (!$process->isSuccessful()) {
@@ -47,9 +53,20 @@ protected function render($template, $parameters = [])
return $this->container->get('templating')->render($template, $parameters);
}
- protected function getLogger()
+ /**
+ * @return LoggerInterface
+ */
+ public function getLogger(): LoggerInterface
+ {
+ return $this->logger;
+ }
+
+ /**
+ * @param LoggerInterface $logger
+ */
+ public function setLogger(LoggerInterface $logger): void
{
- return $this->container->get('logger');
+ $this->logger = $logger;
}
protected function getFilesystem()
@@ -59,4 +76,4 @@ protected function getFilesystem()
}
return $this->fs;
}
-}
\ No newline at end of file
+}
diff --git a/src/Manager/NginxManager.php b/src/Manager/NginxManager.php
index fde21c9..f21b552 100644
--- a/src/Manager/NginxManager.php
+++ b/src/Manager/NginxManager.php
@@ -20,7 +20,7 @@ public function compileHosts($hosts)
{
$this->getLogger()->info('compile nginx file');
- $content = $this->render('App:Nginx:nginx.conf.twig', [
+ $content = $this->render('Nginx/nginx.conf.twig', [
'hosts' => $hosts
]);
@@ -37,7 +37,7 @@ public function compileHosts($hosts)
*/
public function compile()
{
- $hosts = $this->container->get('project.repository.host')->findAll();
+ $hosts = $this->container->get('app.repository.host')->findAll();
$content = $this->compileHosts($hosts);
return $content;
}
@@ -56,4 +56,4 @@ private function getConfigPath()
{
return $this->container->getParameter('nginx_config');
}
-}
\ No newline at end of file
+}
diff --git a/src/Viewer/NginxViewer.php b/src/Viewer/NginxViewer.php
new file mode 100644
index 0000000..46d5f0e
--- /dev/null
+++ b/src/Viewer/NginxViewer.php
@@ -0,0 +1,51 @@
+ [
+ 'type' => 'output_stream',
+ 'route' => 'app_nginx_restart',
+ 'label' => 'Restart',
+ 'icon' => 'replay'
+ ],
+ 'compile' => [
+ 'type' => 'output_stream',
+ 'route' => 'app_nginx_compile',
+ 'label' => 'Compile',
+ 'icon' => 'build'
+ ]
+ ];
+ }
+
+ public function configureOptions(OptionsResolver $optionsResolver)
+ {
+ parent::configureOptions($optionsResolver);
+ $optionsResolver->setDefaults([
+ 'stylesheets' => [
+ 'enhavo/nginx'
+ ],
+ 'javascripts' => [
+ 'enhavo/nginx'
+ ],
+ ]);
+ }
+
+ public function getType()
+ {
+ return 'nginx';
+ }
+}
diff --git a/webpack.config.js b/webpack.config.js
index 747a103..0b18726 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -21,6 +21,8 @@ Encore
.addEntry('enhavo/delete', './assets/enhavo/delete')
.addEntry('enhavo/list', './assets/enhavo/list')
.addEntry('enhavo/login', './assets/enhavo/login')
+ .addEntry('enhavo/varnish', './assets/enhavo/varnish')
+ .addEntry('enhavo/nginx', './assets/enhavo/nginx')
;
enhavoConfig = EnhavoEncore.getWebpackConfig(Encore.getWebpackConfig());