Closed TheCadien closed 1 year ago
@TheCadien should mostly be change route definition to ::
: sulu_news.controller:indexAction
-> sulu_news.controller::indexAction
;)
@alexander-schranz your absolute right ! thanks !! :)
@TheCadien your dev dependencies blocks the updates in the CI.
You need to update phpstan and php-cs-fixer so CI runs on Symfony 6. Currently it runs in mixed mode which make things failing:
Hi.
I'm just testing the bundle with this branch and I came up with an issue:
I've created a pretty simple news/index.html.twig
:
{% block content %}
<h2>{{ news.title }}</h2>
{% set header = sulu_resolve_media(news.header, 'de') %}
<img src="{{ header.thumbnails['sulu-260x'] }}" alt="{{ header.title }}" title="{{ header.title }}" />
<p>{{ news.teaser }}</p>
{% for contentItem in news.content %}
{% if contentItem.type == 'editor' %}
<p>{{ contentItem.text | raw }}</p>
{% endif %}
{% endfor %}
{% endblock %}
In the preview pane I get the following error:
Sulu\Bundle\PreviewBundle\Preview\Exception\TwigException:
An exception has been thrown during the rendering of a template ("Warning: foreach() argument must be of type array|object, null given"). (/Users/oroessner/Development/my/project/templates/news/index.html.twig line 5)
at vendor/sulu/sulu/src/Sulu/Bundle/PreviewBundle/Preview/Renderer/PreviewRenderer.php:199
at Sulu\Bundle\PreviewBundle\Preview\Renderer\PreviewRenderer->render(object(News), '1', false, array('webspaceKey' => 'my-webspace', 'locale' => 'de', 'targetGroupId' => '-1'))
(vendor/sulu/sulu/src/Sulu/Bundle/PreviewBundle/Preview/Preview.php:152)
at Sulu\Bundle\PreviewBundle\Preview\Preview->render('3a5782230389e5b89c95f4e109b59942', array('webspaceKey' => 'my-webspace', 'locale' => 'de', 'targetGroupId' => '-1'))
(vendor/sulu/sulu/src/Sulu/Bundle/PreviewBundle/UserInterface/Controller/PreviewController.php:78)
at Sulu\Bundle\PreviewBundle\UserInterface\Controller\PreviewController->renderAction(object(Request))
(vendor/symfony/http-kernel/HttpKernel.php:163)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
(vendor/symfony/http-kernel/HttpKernel.php:75)
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
(vendor/symfony/http-kernel/Kernel.php:202)
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
(public/index.php:68)
If I dig deeper, its in \Sulu\Bundle\MediaBundle\Api\Media::getFileVersion() $this->entity->getFiles()
is empty. Don't know if its related to the media bundle or your \TheCadien\Bundle\SuluNewsBundle\Controller\NewsWebsiteController::renderPreview
.
But if I publish it or create a preview and open it in the browser, it renders fine.
package-versions:
@Basster , thanks for reporting. Please try it again with the ID not the Media Object. Like that way
{% block content %}
<h2>{{ news.title }}</h2>
{% set header = sulu_resolve_media(news.header.id, 'de') %}
<img src="{{ header.thumbnails['sulu-260x'] }}" alt="{{ header.title }}" title="{{ header.title }}" />
<p>{{ news.teaser }}</p>
{% for contentItem in news.content %}
{% if contentItem.type == 'editor' %}
<p>{{ contentItem.text | raw }}</p>
{% endif %}
{% endfor %}
{% endblock %}
Please try it again with the ID not the Media Object. Like that way
@TheCadien works like a charm. Thank you.
Need to fix at next
The controller for URI "/_sulu_preview" is not callable: Controller "sulu_news.controller:indexAction" does neither exist as service nor as class.