Symfony2: problems rendering the translation-form with A2lixTranslationFormBundle and Gedmo\DoctrineExtensions Translatable - forms

I'm using gedmo/doctrine-translations and a2lix/translation-form-bundle: 2.*#dev to translate my entities.
The translation form always renders a Field and Content but my entity itself doesn't contain a Field or Content field.
The form type
$builder->add('translations', 'a2lix_translations');

The 2.0 version of the TranslationFormBundle
isn't compatible with the current gedmo/doctrine-extensions version.
See the bundle's upgrade notes.
You'll need to use the currently unstable branches wip-v2.4.0 and .
solution:
Either update gedmo/doctrine-extensions ...
composer require gedmo/doctrine-extensions:wip-v2.4.0#dev
composer update gedmo/doctrine-extensions
... or downgrade your a2lix/translation-form-bundle version:
composer require a2lix/translation-form-bundle:~1.2
composer update a2lix/translation-form-bundle
important notice for the 1.x version of a2lix/TranslationFormBundle:
You need to use the a2lix_translations_gedmo field-type as described in the documentation.
Further you need to specify the translatable class in the options-array like this:
$builder->add('translations', 'a2lix_translations_gedmo', array(
'translatable_class' => "Your\Entity"
);

Related

The annotation "#ODM\Document" in class ... was never imported

Annotation doesn't work any more after upgrading php7.4 to 8.1.
I upgrade a php7.4 project to php8.1.9, then annotations don't work:
The annotation "#ODM\Document" in class ... was never imported.
Some examples of annotations are:
use Zend\Form\Annotation;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
/**
* #ODM\Document
* #Annotation\Name("client")
* #Annotation\Attributes({"novalidate": "true"})
*/
I have checked the above two classes exist under vendor/.
I have also run composer dumpautoload.
There also exist AnnotationDriver of Doctrine:
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php;
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php
In addition, the version of their packages are not changed.
My questions:
Firstly what's the most effective way to make the system work or identify problems ?
I'm considering, do I have to replace all the annotations to PHP8 attributes ? But this doesn't look necessary or practical. There're huge amount of annotations. Even if I can replace those annotations of my project, the vendor packages still use annotations and definitely I can't change them.
Just wondering, which version of Doctrine Mongodb ODM support PHP8 attributes ?
Just guessing, is it because PHP8 makes the current Zend framework 2 and Doctrine ODM broken and thus causing annotation not work any more? If so, how to fix?
The related packages are as the following:
"zendframework/zendframework" : "2.3.10"
"doctrine/annotations" : "1.2.8",
"doctrine/mongodb": "1.2.2" (There's no version for PHP8, so I have to install it as github VCS package )
"mongodb/mongodb" : "^1.0.1",
"doctrine/mongodb-odm" : "1.0.0-BETA14",
"doctrine/doctrine-mongo-odm-module" : "0.8.0",
"doctrine/annotations" : "1.2.8",
"doctrine/common": "2.4.4",
"doctrine/doctrine-module": "0.8.2",
If you need further resources, please let me know. Thanks!

Multiple extension extend one extension in TYPO3 10

Szenario:
I have two extensions, which extend ext:news with some specific fields. Up to TYPO3 9 I had to configure the dependency to the news extension with the following TypoScript configuration:
config.tx_extbase {
persistence {
classes {
GeorgRinger\News\Domain\Model\News {
subclasses {
GeorgRinger\News\Domain\Model\News = Vendor\Extension\Domain\Model\News
}
}
Vendor\Extension\Domain\Model\News {
mapping {
tableName = tx_news_domain_model_news
}
}
}
}
}
The model Vendor\Extension\Domain\Model\News extends the model of the "base" extension:
class News extends \GeorgRinger\News\Domain\Model\News
In TYPO3 10 the TypoScript configuration was replaced with the following configuration in Configuration/Extbase/Persistence/Classes.php (Breaking: #87623):
\Vendor\Extension\Domain\Model\News::class => [
'tableName' => 'tx_news_domain_model_news',
'recordType' => 0,
],
This works as long, as you have just one extension which extends the news extension. If you have a second extension and enable the TYPO3 cache you will get an error, that the fields which are added in the first extension are not available in the templates of the news extension. The strange part is, that this problem only occurs, when enabling the cache!
So my question is:
What is the right way to add some fields to an existing extension in TYPO3 10?
As the changelog says, in TYPO3 versions below 10, your overriding configuration was located in typoscript. Since 10 LTS, it is located in a PHP class. As a consequence, the mechanism which controls loading order is no more the one for typoscript but the one for PHP.
Authoritative for the PHP loading order is the constraints section in the ext_emconf.php files of your extensions. They are parsed at first run and cached afterwards. The composer.json files do not control loading order - currently they only serve the purpose of resolving dependencies in composer itself.
In contrast to composer.json, the ext_emconf.php allows you to specify not only hard but also "soft" dependencies, which you can set using the suggests keyword. This way, you can specify loading order between extensions without them having to be installed in any case. This allows you to install each extension independently from the other, while you can still specify correct loading order in case they are both installed.
So, in your case, the second extension needs to have a soft "suggests" dependency to the first one:
constraints' => [
'depends' => [
],
'conflicts' => [
],
'suggests' => [
'news' => ''
'first_news_extension' => ''
],
]
See the complete explanation of constraints in ext_emconf here.

Typo3: Put modules of different extensions in one Module group in the typo3 backend module list

Currently I'm trying to create a module group in the typo3 backend module list on the left hand side. My group works fine for modules within the same extension. But when I try to add modules from other extensions to it, it simply doesn't work.
I have created this Module group (mainmodule) in the ext_tables.php file in one of my other extensions like this:
/**
* Creates a Backend Module Category
*/
$GLOBALS['TBE_MODULES'] = array_slice($GLOBALS['TBE_MODULES'], 0, 1, true) +
['mainmodule' => ''] +
array_slice($GLOBALS['TBE_MODULES'], 1, count($GLOBALS['TBE_MODULES']) - 1, true);
$GLOBALS['TBE_MODULES']['_configuration']['mainmodule'] = [
'iconIdentifier' => 'module',
'labels' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_myExt.xlf:mlang_key',
'name' => 'mainmodule',
];
I'm trying to use the mainmodule in a different extension as follows:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
'VEN.' . $extKey,
'mainmodule', // Make module a submodule of 'mainmodule'
'randomkey', // Submodule key
'',
...
The module is always created inside its "own" mainmodule.
I have tried all of the solutions given here on stackoverflow and spent hours of trying to solve this issue. I just can't get it to work..
It seems other extensions are loaded before this extensions which defines the new backend module category. So \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule will fail because of the missing category. To check this have a look at the loading order of the extensions in typo3conf/PackageStates.php.
To resolve the issue, add this extension to the constraint in ext_em.conf and require in composer.json to force it's loaded before the other extensions with the dependency to the new backend module category. See https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ExtensionArchitecture/DeclarationFile/Index.html and https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ExtensionArchitecture/ComposerJson/Index.html.
Other solution could be adding the new category in each extension if it does not already exist.

Symfony 2 form in eZ Publish 5, CSRF intuition

I'm working on a eZ publish 5 project. This CMS is based on symfony 2.
I have built a form without class as described in tge page : http://symfony.com/doc/current/book/forms.html#using-a-form-without-a-class
On the eZ publish 5 documentation (https://confluence.ez.no/display/EZP/Legacy+configuration+injection) I read that I need to set the CSRF intention parameter to 'legacy'. I can't figure how to do this. I tried to use the add method on my formBuilder :
$this->createFormBuilder()->add('_token', 'csrf', array('intention'=>'legacy');
But I get an error 'could not load type csrf'.
Can someone help me on this ?
Thanks.
Okay, I have given this a try.
My first answer is actually a question: If you don't intend to execute any legacy kernel code as a follow-up to your form, you don't need to care about the intention, I believe.
Intentions between the Symfony and legacy kernels only need to match if the Legacy Kernel is booted (in which case it will check if there is a token, and if it is valid).
If you need to use the Legacy Kernel, you can set the intention to legacy by passing custom form options:
$formOptions = array( 'intention' => 'legacy' );
$form = $this->createFormBuilder( null, $formOptions )
->add( 'text', 'text' )
->getForm();
Setting the default intention is explained in http://symfony.com/doc/current/book/forms.html#csrf-protection, but I wouldn't really advise this, unless you intend to only rely on the legacy kernel.

Laravel 4 using vendor classes

I have installed Laravel 4 after using 3, love it.
I used to be able to use the Zend framework as such:
$yt = new Zend_Gdata_YouTube();
for instance
I have used composer to install Zend and everything is installed in the Vendor folder..
Problem:
How to address the individual classes i.e. Zend Gdata etc.
I can't find any documentation on calling classes from a vendor in L4.
Any help is appreciated.
Take a look at your vendor\composer\autoload_classmap.php file. In there you will find a list of all vendor classes that are being autoloaded. I think all classes will have to be called using their full namespaced name.
E.g.
I'm using Zizaco's Entrust package. This is what it looks like in the vendor\composer\autoload_classmap.php file.
'Zizaco\\Entrust\\Entrust' => $vendorDir . /zizaco/entrust/src/Zizaco/Entrust/Entrust.php',
If I wanted to access the Entrust.php class I have to call
$en = new Zizaco\Entrust\Entrust();
Alternatively you could alias certain classes in your app\config\app.php file.
E.g.
'Ent' => 'Zizaco\Entrust\Entrust'
In your case you'll need to do something like this:
$yt = new Zend\namespace\Zend_Gdata_YouTube();