Как обрабатывать возврат renderTags() в пентатрионеPhp

Кемеровские программисты php общаются здесь
Ответить
Anonymous
 Как обрабатывать возврат renderTags() в пентатрионе

Сообщение Anonymous »

Я использую пентатрион для установки Vite в свой проект Symfony. Я выполнил действия, описанные в документации по пентатриону (https://symfony-vite.pentatrion.com/ext ... ation.html), но все равно получаю эту ошибку:

Код: Выделить всё

Return value of Pentatrion\ViteBundle\Service\EntrypointRenderer::renderTags() must be an instance of Pentatrion\ViteBundle\Service\mixed, string returned
Вот ошибка в моем журнале:

Код: Выделить всё

[2024-06-20T22:39:48.201801+02:00] php.CRITICAL: Uncaught Error: Return value of Pentatrion\ViteBundle\Service\EntrypointRenderer::renderTags() must be an instance of Pentatrion\ViteBundle\Service\mixed, string returned {"exception":"[object] (TypeError(code: 0): Return value of Pentatrion\\ViteBundle\\Service\\EntrypointRenderer::renderTags() must be an instance of Pentatrion\\ViteBundle\\Service\\mixed, string returned at /.../myapp/vendor/pentatrion/vite-bundle/src/Service/EntrypointRenderer.php:289)"} []
[2024-06-20T22:39:48.303733+02:00] request.CRITICAL: Uncaught PHP Exception TypeError: "Return value of Pentatrion\ViteBundle\Service\EntrypointRenderer::renderTags() must be an instance of Pentatrion\ViteBundle\Service\mixed, string returned" at /.../myapp/vendor/pentatrion/vite-bundle/src/Service/EntrypointRenderer.php line 289 {"exception":"[object] (TypeError(code: 0): Return value of Pentatrion\\ViteBundle\\Service\\EntrypointRenderer::renderTags() must be an instance of Pentatrion\\ViteBundle\\Service\\mixed, string returned at /.../myapp/vendor/pentatrion/vite-bundle/src/Service/EntrypointRenderer.php:289)"} []
Это функция в EntrypointRenderer.php:

Код: Выделить всё

/**
* @return string|array
*/
public function renderTags(array $tags, bool $isBuild, bool $toString): mixed
{
if (null !== $this->eventDispatcher) {
foreach ($tags as $tag) {
$this->eventDispatcher->dispatch(new RenderAssetTagEvent($isBuild, $tag));
}
}

if ('link-tag' !== $this->preload) {
$tags = array_filter($tags, function (Tag $tag) {
return !$tag->isModulePreload();
});
}

return $toString
? implode('', array_map(function ($tagEvent) {
return TagRenderer::generateTag($tagEvent);
}, $tags))
: $tags;  // line 289
}
Это версия: «pentatrion/vite-bundle»: «^6.3»,

Код: Выделить всё

{
"name": "pentatrion/vite-bundle",
"version": "v6.3.4",
"source": {
"type": "git",
"url": "https://github.com/lhapaipai/vite-bundle.git",
"reference": "c46fa23e33064e087d178d79be9f117b411fff0c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/lhapaipai/vite-bundle/zipball/c46fa23e33064e087d178d79be9f117b411fff0c",
"reference": "c46fa23e33064e087d178d79be9f117b411fff0c",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0",
"symfony/asset": "^4.4 || ^5.0 || ^6.0 || ^7.0",
"symfony/config": "^4.4 || ^5.0 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0 || ^7.0",
"symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0 || ^7.0",
"symfony/http-client": "^4.4 || ^5.0 || ^6.0 || ^7.0",
"symfony/http-kernel": "^4.4 || ^5.0 || ^6.0 || ^7.0",
"symfony/twig-bundle": "^4.4 || ^5.0 || ^6.0 || ^7.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.9",
"phpstan/phpstan": "^1.8",
"phpunit/phpunit": "^9.5",
"symfony/phpunit-bridge": "^4.4 || ^5.0 || ^6.0 || ^7.0",
"symfony/web-link": "^4.4 || ^5.0 || ^6.0 || ^7.0"
},
"type": "symfony-bundle",
"autoload": {
"psr-4": {
"Pentatrion\\ViteBundle\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Hugues Tavernier",
"email": "hugues.tavernier@protonmail.com"
}
],
"description": "Vite integration for your Symfony app",
"keywords": [
"bundle",
"symfony",
"vite",
"vitejs"
],
"support": {
"issues": "https://github.com/lhapaipai/vite-bundle/issues",
"source": "https://github.com/lhapaipai/vite-bundle/tree/v6.3.4"
},
"time": "2024-01-25T22:11:09+00:00"
}
Ветка:

Код: Выделить всё

    



{% block title %}Welcome!{% endblock %}

{% block stylesheets %}
{{ vite_entry_link_tags('app') }}
{% endblock %}







{% block body %}{% endblock %}
{% block javascripts %}
{{ vite_entry_script_tags('app') }}
{% endblock %}



Снимок экрана:
Изображение

Изображение


Подробнее здесь: https://stackoverflow.com/questions/786 ... pentatrion
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Php»