-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
autocomplete for phpcr_odm_path #112
Comments
what kind of autocomplete were you looking for? Select2? |
hm, indeed that bundle looks exactly like what we would need. it currently seems to depend on doctrine orm which for our case makes no sense. if i got it right, we could provide a controller that searches through a phpcr repository either in this bundle or in the AutocompleteBundle (but you seem to not provide an orm controller either, so maybe we rather have it here). |
hm you're right, I forgot about the fact that it's hard coded to ORM at the moment :) I think it shouldn't be too hard to add some flexibility though. It doesn't actually work with controllers, but instead throws a response to the client in one of the form listeners at exactly the right moment. This minimized custom effort on the client side. The ResultFetcher class would need some tweaking for compatibility with other QB classes. It could then accept a list of handlers which would do the magic, so for instance and ORMResultFetcher and a PHPCR-ODM result fetcher could then be attached through a DIC tag handled by a CompilerPass... If you're interested I'll investigate deeper |
i think the query builder for phpcr-odm is not even that different. the question will be what to search on however. one thing to search on could be the node names or even the path, so that i type "/cms/content/ab" and get proposed the "/cms/content/about" document. phpcr ids are like filesystem paths. if we use the slashes, we would need to split things as phpcr does never query on a full path, but can do things like ISDESCENDANTOF("/cms/content") AND NAME LIKE "ab*". how can the form listener handle this? do you dump all possible results and there is no livesearch? with phpcr this could be very expensive, as you would dump the whole database. but then, that would be like the |
and thanks a lot for your motivation to look into these things, really appreciate it! |
No problem! What the bundle does is it appends a where and a limit to a query builder you pass to it (or you can let it create the query builder for you, works just like the It searches for all words you're searching for split by So for example you have a query builder like this: $em->getRepository("FooBundle:Bar")->createQueryBuilder("bar")->innerJoin("bar.baz", "baz"); and you type "some words" into the select2 box, the final query builder will be something like: $em->getRepository("FooBundle:Bar")->createQueryBuilder("bar")->innerJoin("bar.baz", "baz")
->where("bar.name LIKE %some% OR bar.name LIKE %words%")
->setMaxResults(10); So it won't select the whole database. This is done in that same ResultFetcher, though, so basically, if the result fetcher can be configured, so can do anything with the QueryBuilder you like |
I set up a very basic preview version here: https://github.com/Burgov/symfony-cmf-standard/tree/autocomplete currently it only searches for the title. I haven't done much with PHPCR yet, so I'm not really sure how to search for paths for example. You can just setup the project like normally with CMF-standard and load the fixtures. Then go to What do you think of it? |
that was fast! i will try to have a look, but i fear i won't be able to before going to the php benelux conference. but for sure when i am back! |
ping |
the phpcr_odm_path form type could use an autocomplete functionality to make it easier to type a correct path.
The text was updated successfully, but these errors were encountered: