Skip to content

Commit

Permalink
fix kernel and preview configuration fr example preview
Browse files Browse the repository at this point in the history
  • Loading branch information
wachterjohannes committed Sep 29, 2021
1 parent 35cf9dd commit 45fd9fa
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 48 deletions.
11 changes: 11 additions & 0 deletions Tests/Application/ExampleTestBundle/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,14 @@ services:
- Sulu\Bundle\ContentBundle\Tests\Application\ExampleTestBundle\Entity\Example
tags:
- 'massive_search.metadata.provider'

example_test.example_preview_object_provider:
class: Sulu\Bundle\ContentBundle\Content\Infrastructure\Sulu\Preview\ContentObjectProvider
arguments:
- '@doctrine.orm.entity_manager'
- '@sulu_content.content_resolver'
- '@sulu_content.content_data_mapper'
- Sulu\Bundle\ContentBundle\Tests\Application\ExampleTestBundle\Entity\Example
tags:
- { name: 'sulu.context', context: 'admin' }
- { name: 'sulu_preview.object_provider', provider-key: 'examples' }
8 changes: 8 additions & 0 deletions Tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public function registerContainerConfiguration(LoaderInterface $loader)
{
parent::registerContainerConfiguration($loader);
$loader->load(__DIR__ . '/config/config_' . $this->getContext() . '.yml');

$devConfigFile = __DIR__ . '/config/config_' . $this->getContext() . '_' . $this->getEnvironment() . '.yml';
if (is_file($devConfigFile)) {
$loader->load($devConfigFile);
}
}

protected function getKernelParameters()
Expand All @@ -59,3 +64,6 @@ protected function getKernelParameters()
return $parameters;
}
}

// Needed for preview PreviewKernelFactory
class_alias(Kernel::class, 'App\\Kernel');
13 changes: 13 additions & 0 deletions Tests/Application/PreviewKernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Sulu\Bundle\ContentBundle\Tests\Application;

use Sulu\Bundle\PreviewBundle\Preview\Renderer\PreviewKernel as SuluPreviewKernel;

class PreviewKernel extends SuluPreviewKernel
{
public function getProjectDir(): string
{
return __DIR__;
}
}
17 changes: 17 additions & 0 deletions Tests/Application/PreviewKernelFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Sulu\Bundle\ContentBundle\Tests\Application;

use Sulu\Bundle\PreviewBundle\Preview\Renderer\KernelFactoryInterface;
use Sulu\Component\HttpKernel\SuluKernel;

class PreviewKernelFactory implements KernelFactoryInterface
{
public function create($environment)
{
$kernel = new PreviewKernel($environment, 'dev' === $environment, SuluKernel::CONTEXT_WEBSITE);
$kernel->boot();

return $kernel;
}
}
4 changes: 4 additions & 0 deletions Tests/Application/config/config_admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ imports:

framework:
router: { resource: "%kernel.project_dir%/config/routing_admin.yml" }

services:
sulu_preview.preview.kernel_factory:
class: Sulu\Bundle\ContentBundle\Tests\Application\PreviewKernelFactory
4 changes: 4 additions & 0 deletions Tests/Application/config/config_admin_dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
security:
providers:
testprovider:
id: sulu_security.user_provider
46 changes: 0 additions & 46 deletions Tests/Application/config/templates/pages/default-2.xml

This file was deleted.

2 changes: 1 addition & 1 deletion Tests/Application/config/webspaces/sulu.io.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<default-templates>
<default-template type="homepage">default</default-template>
<default-template type="page">default-2</default-template>
<default-template type="page">default</default-template>
</default-templates>

<templates>
Expand Down
2 changes: 1 addition & 1 deletion Tests/Application/templates/pages/default.html.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% block content %}
<h1>{{ content.title }}</h1>

{{ content.description|raw }}
{{ content.article|raw }}
{% endblock %}

0 comments on commit 45fd9fa

Please sign in to comment.