Closed pixel-paul closed 7 years ago
From https://github.com/twigphp/Twig/blob/1.x/lib/Twig/Loader/String.php#L12
The Twig_Loader_String class is deprecated since version 1.18.1 and will be removed in 2.0. Use Twig_Loader_Array instead or Twig_Environment::createTemplate().
I picked the first solution, but the second might be the right one, see https://github.com/twigphp/Twig/blob/2.x/lib/Twig/Environment.php#L400
The comment line https://github.com/twigphp/Twig/blob/2.x/lib/Twig/Environment.php#L391 is not very reassuring though...
This one is not very reassuring either https://github.com/twigphp/Twig/blob/1.x/lib/Twig/Loader/String.php#L17
Neither is this one : https://github.com/twigphp/Twig/blob/2.x/lib/Twig/Loader/Array.php#L15
But the least reassuring comment is this one : https://github.com/twigphp/Twig/blob/1.x/lib/Twig/Loader/String.php#L17
From @sstok : https://twig.sensiolabs.org/doc/2.x/functions/template_from_string.html
https://symfony-devs.slack.com/archives/C3FUK4U22/p1491984607472393, which confirms that the way to go would probably be to use createTemplate
, see https://github.com/twigphp/Twig/blob/5527658f0863d18d3cb7035ce250dbdcf830ad88/lib/Twig/Extension/StringLoader.php#L36
I have the same error, I reuse this issue.
I have the same result with field...
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('content', 'sonata_formatter_type', array(
'event_dispatcher' => $formMapper->getFormBuilder()->getEventDispatcher(),
'format_field' => 'contentFormatter',
'format_field_options' => array(
'choices' => array('text', 'markdown'),
'data' => 'markdown',
),
'source_field' => 'rawContent',
'source_field_options' => array(
'attr' => array('class' => 'span10', 'rows' => 20)
),
'listener' => true,
'target_field' => 'content'
))
I update my project symfony3.2 ... and now it doesnt work. I am doing some wrong ? I need update some code of formatter ? Are there any solution temporaly ?
And when I create a entity I get the result:
Template "
asdasdasd
" is not defined. 500 Internal Server Error - Twig_Error_Loader
My composer.json is
"php" : ">=7",
"symfony/symfony" : "v3.2.6",
"doctrine/orm" : "~2.4,>=2.4.5",
"doctrine/doctrine-bundle" : "~1.3@dev",
"twig/extensions" : "1.0.*",
"symfony/assetic-bundle" : "^2.8",
"symfony/swiftmailer-bundle" : "^2.5",
"symfony/monolog-bundle" : "v3.1.*",
"sensio/distribution-bundle" : "^5.0",
"sensio/framework-extra-bundle" : "^3.0.2",
"incenteev/composer-parameter-handler" : "~2.0",
"sonata-project/admin-bundle" : "3.16.0",
"sonata-project/doctrine-orm-admin-bundle" : "3.1.4",
"sonata-project/doctrine-extensions" : "1.0.2",
"sonata-project/exporter" : "1.7.1",
"sonata-project/core-bundle" : "3.3.0",
"sonata-project/cache" : "1.0.7",
"sonata-project/datagrid-bundle" : "2.2.1",
"sonata-project/google-authenticator" : "1.0.2",
"sonata-project/easy-extends-bundle" : "2.1.10",
"sonata-project/block-bundle" : "3.3.2",
"sonata-project/user-bundle" : "dev-add_support_for_fos_user2",
"sonata-project/formatter-bundle" : "3.2.1",
"shtumi/useful-bundle" : "dev-master",
"knplabs/knp-menu" : "^2.1",
"stof/doctrine-extensions-bundle" : "^1.2",
"ocramius/proxy-manager" : "~1.0",
"doctrine/doctrine-migrations-bundle" : "^1.0",
"vich/uploader-bundle" : "^1.3",
"knplabs/knp-gaufrette-bundle" : "^0.3.0",
"liip/imagine-bundle" : "^1.6",
"aws/aws-sdk-php" : "^3.19",
"snc/redis-bundle" : "2.x-dev",
"predis/predis" : "^1.0",
"sabre/xml" : "^1.5",
"jms/serializer-bundle" : "1.2.1"
},
"require-dev" : {
"sensio/generator-bundle" : "3.1.4",
"symfony/phpunit-bridge" : "v3.2.6",
"symfony/var-dumper" : "^3.2",
"behat/behat" : "^3.1",
"behat/symfony2-extension" : "^2.1",
"behat/mink" : "^1.7",
"phpunit/phpunit" : "^5.5",
"behat/mink-extension" : "^2.2",
"behat/mink-browserkit-driver" : "^1.3",
"behat/mink-selenium2-driver" : "1.3.1"
},
I have in my composer.lock twig version:
"version": "1.x-dev",
Thanks in advance !
I am doing some wrong ? I need update some code of formatter ?
No, no
Are there any solution temporaly ?
Blacklist this version of SonataFormatterBundle in Composer
"version": "1.x-dev",
You shouldn't rely on development versions
i had similar issue , downgrade my packaged to "version": "3.2.0" of sonata formatter bundle solve my issue for symfony 2.8
I'm in 3.2.0 version with symfony 2.8 and I had similar issue.. Any solution ?
@wallforfry As mentioned by @idhard you can revert to version 3.2.0. If that doesn't do you can use the patch I shared which reverts the BC commit. You can find it in PR https://github.com/sonata-project/SonataFormatterBundle/pull/239#issuecomment-293290193.
But we should look into the fixes suggested by gregoire to make sure our beloved bundle gets fixed too.
Reverting version to 3.2.0 fixes problem on symfony 2.8. But in my case, it arises another error on edit:
Attempted to call an undefined method named "validateBlock" of class "Sonata\FormatterBundle\Block\FormatterBlockService".
I applied patch which @Neodork mentions, and now it works without any problem: https://github.com/sonata-project/SonataFormatterBundle/pull/235/commits/6f528100276b6508fbceddb9127cc5c9e28d3bad
Could you provide a PR with a fix @ersah123
Environment
Sonata packages
Symfony packages
PHP version
Subject
Sonata composer will not update a rich text block
Steps to reproduce
Edit a page Select composer Select a block Add 'Rich Text' Click 'Create'
Expected results
Content is created successfully
Actual results
An error is generated from the ajax update:
Template "<b>Insert your custom content here</b>" is not defined. 500 Internal Server Error - Twig_Error_Loader
Stack trace
`Twig_Error_Loader: Template "Insert your custom content here" is not defined. at n/a in /var/www/html/sonata3/vendor/twig/twig/lib/Twig/Loader/Array.php line 80
Referencing #239