i am struggling a little challenge and i am wondering what the solution might be as I couldn't find an answer in the documentation.
Here is my current working query (part):
$constraints[] = $query->like('kategorie', '%'.$kategorie.'%');
What I want to do is something like:
$constraints[] = $query->like(CONCAT(',', kategorie, ','), '%,'.$kategorie.',%');
Which obviously doesn't work at all. : -)
Every Help is really appriciated. Hope someone know the right syntax. TYPO3 Version is latest 6.1
Thank's alot!
First of all, Extbase query generation didn't change in 6.0, so it's the same for 4.x and 6.x.
Maybe you misunderstand the way Extbase is builing the query.
$query->like('property', '%value%');
will return an object when %value% is contained in "property". Such a property must be defined in the domain model. You can only query properties that have a "getProperty" method in their domain model.
Looking at your code, I think you're finding a way to query for a value being present in a comma-separated value list? Then you would use
$query->in('kategorien', $kategorie);
EDIT:
Your specific problem seems to be that you are not using a true relation for assigning "Kategorien" to your entity. You're using a comma-separated list to hold references to another model. You're discouraged to do so, but it is technically possible and used in the TYPO3 core: The FrontendUser model has a property "usergroup" that works in the same way.
Please have a look at the FrontendUser model: https://git.typo3.org/Packages/TYPO3.CMS.git/blob/HEAD:/typo3/sysext/extbase/Classes/Domain/Model/FrontendUser.php
The annotation of your Kategorien must be correct, e.g.:
/**
* #var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\My\Extension\Domain\Model\Kategorien>
*/
protected $kategorien;
Also make sure that getKategorien is correct.
If you still have problems, keep in mind that the TCA definition must be working to have Extbase work correctly.
In my opinion, a best practise would be to use the category API introduced in TYPO3 6.0:
http://wiki.typo3.org/TYPO3_6.0#Category
Related
Im upgrading an extension to work with TYPO3 v10. Since command controllers can not be used anymore, im migrating them to symfony commands as pointed by the documentation. Everything works smooth as heck except for the usage of extbase repository classes. No matter what i query, i never get a result. Since i can't find any useful information on the web and the documentation i hope this may be just something minor.
After debugging for a while i found out that the pid is not determined correctly while building the query settings. I find that kind of strange since my root template has these lines:
plugin.tx_myext.persistence.storagePid = 15403
module.tx_myext.persistence.storagePid = 15403
The repository instances are correctly injected by injectMyRepository() methods. I've tried using the extbase ObjectManager to fetch the class instances instead but the "error" stays the same.
Am i doing something wrong or is it not possible to use extbase repository classes in symfony commands?
After more research i found out that there is some bootstraping missing which results in extension settings (the storageID in my case) not being loaded. From what i've been reading, that behaviour seems intended to prevent extbase booting, i guess?
There is a reference to something similiar in the official documentation: https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/CommandControllers/Index.html#initialize-backend-user
Knowing that, i tried to find a method to initialize the missing settings which i could not find. So this does indeed seem like a missing feature.
I developed a workaround which i'm not too proud of, but it's better than nothing (or rebuilding everything to doctrine for that matter). If you stumble upon the same issue, here you go. Just insert and call this method before you fire your query:
public static function initializeConfigurationManager(): void
{
/** #var ConfigurationManager $configurationManager */
$configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
$tmpConfiguration = $configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK,
'myExtensionName'
);
$configurationManager->setConfiguration($tmpConfiguration);
}
That approach exploits the singleton state of the ConfigurationManager. You simply inject the static template of your extension manually and every extbase compound (like repositories) will then use these settings from there on. Lovely.
Be aware however, this is prone to break with future internal changes.
There are 2 functions in TYPO3 which seem to more or less do the same:
ExtensionManagementUtility::addModule
/**
* Adds a module (main or sub) to the backend interface
* FOR USE IN ext_tables.php FILES
ExtensionUtility::registerModule
/**
* Registers an Extbase module (main or sub) to the backend interface.
* FOR USE IN ext_tables.php FILES
So, according to the comments, they basically do the same, but one registers and one adds and for one it's an Extbase module. I have seen examples for both online and seen TYPO3 extensions use one or the other methods.
Which of these methods should be use to create a TYPO3 backend-module and what is the difference?
I can just use one or the other methods, but I would like to get some more guidance on these general things and what is the best practice for the future.
The obvious answer is probably, if you use Extbase, you use registerModule, if not, you use addModule. Ok, but then, why does the core do it this way in some cases and that way in the other?
Another obvious answer is that registerModule calls addModule.
See also this comment.
With addModule you just add a new Module into the left navigation bar.
With registerModule you do some pre-configuration for extbase. Have a look into the code, all controller->action combinations will be registered globally. A vender will be set and please have a look at the very last line: It calls addModule from above.
Additionally, it looks like ExtensionUtility::registerModule() is used for modules based on Extbase, and ExtensionManagementUtility::addModule() otherwise (see BackendModuleApi)
Is it possible to get SqlFunctions to work with Dynamic Linq? I noticed this post from the SO site which seems to suggest that it is possible, however, every time I run this query below in a .NET project (not .NET Core):
query.Where("SqlFunctions.StringConvert((double?)Property).Contains(\"x\")");
It spits back a message that:
No property or field 'SqlFunctions' exists in type 'Entity'
Worked for me. Check you have created your own custom DLinq with added SqlFunctions type to predefinedTypes as per the post.
Personally I'm adding SqlFunctions dynamically to my DLinq. See https://stackoverflow.com/a/18313782/525788 for guidance.
My name is Denis and I really need your help or advice or anything :)
I am developing my project in Zend Framework 1.11 and am using Doctrine 2.1.
I have successfully integrated Doctrine in my ZF project and everything works. I also integrated Gedmo extensions and some my custom extensions.
The problem is with validation. I want to have validation of doctrine entities by using annotations. Because I sometimes need to validate my entities sometimes don't, I want that sort of validation, for example:
$user = new Entity\User; $user->setName('user'); $user->validate();
I don't want to change doctrine generated entities at all, so I won't change setters or use doctrine events for this.#HasLifecycleCallbacks.
I run into example at http://www.spiffyjr.me/2011/07/15/more-doctrine-2-and-zend-framework-integration-goodies/.
I downloaded code but didn't managed to put it in work. I followed instructions from that page, made my entities extend AbstractEntity, but when try to use for example isValid() i recieve following error:
[Semantical Error] The annotation "#Column" in property Bild\Entity\TestTest::$id was never imported. Did you maybe forget to add a "use" statement for this annotation?
I use doctrine annotations without #ORM\, just #, (for example #Column, not #ORM\Column). I even tried to add ORM but no luck it continues to throw errors.
I can recieve metadata for my entity, get field mappings and associating mappings, but when I try to getPropertyAnnotation
// validator annotations
$vAnnotations = self::_getPropertyAnnotation($property, self::ZENDVALIDATION);
var_dump($vAnnotations);die;
I recieve mentioned semantic error.
I tracked the errors down to Doctrine\Common\Annotations\AnnotationReader::getPropertyAnnotations($property); not returning annotations but throwing errors.
What do you think it can be?
It seems like I am not doing something properly but can't figure out what.
So, I need to make abstract entity, make my entities extend it, and make functions to validate my entities by using annotations.
So please, help me with this, if you can. I really need for my project but couldn't find a solution.
Thanks in advance.
Best regards.
The problem is caused by the configuration of the annotation reader. I went through the same problems while integrating the Symfony2 validator service for my Doctrine2 models in ZF1, more on the blog post here http://ssmusoke.wordpress.com/2012/03/04/doctrine-2-day-2-model-validation-using-symfony-validator-service-in-zend-framework/
i have a kohana-based website, and i want to use zend-lucene search.
as i have seen in the documentation here https://github.com/evopix/kohana-search/blob/master/README.markdown but i do not understand: must i re-create the models i already have in order to be able to use it? the model should extend the ORM_Searchable (it is a must)? and where can i find the ORM_Searchable class in kohana?
thanks a lot!
You don't have to recreate the models. You extend from a new class, implement its methods which specify what data you want to be indexed by Zend Lucene. The documentation is really straight forward.
the model should extend the ORM_Searchable (it is a must)? and where can i find the ORM_Searchable class in kohana?
This is in the code repository you linked to. classes/kohana/orm/searchable.php