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
Related
I have a question I ask myself since Symfony 2 and it is still the case on 3.2
When you use the console to generate formType of entity :
doctrine:generate:form
The EntityType is in the \Form folder but not in \Form\Type
Why ?
Sensiolabs itself recommand to put it in the Type folder....
There is a way to adapt this one?
No it doesn't recommend that.
As you can see in either Symfony Doc examples or Symfony Best Practices Guide, it both use Form and not Type folder/namespace.
The second one even straightly says:
Best Practice
Put the form type classes in the AppBundle\Form namespace, unless you use other custom form classes like data transformers.
Namespace of course, means also path at the same time.
In addition, best practices recommends creating a sub namespace if other custom form classes are used (like DataTransformer).
For example, i always use :
---Form
-----------DataTransformer
-----------Type
In this case all form classes are stored in Type folder (and namespace).
I am struggling with some Drupal 8 form/entity type coding.
Basically here is a short summary of the task:
I have entity types which are from the eck module, so say three fields:
Name:
Email:
Phone:
So I have created a custom form using the FormBase class for users to fill in and that's fine but, I don't know how to save the post data to the entity.
If it was a node I would use the Node::create function but this is an entity so I need another way.
So I guess my task is:
1. Get the ID of the entity I want to save too
2. Find a way to save the form data to the entity
I am very new to Drupal 8 (just like most people I guess), I have tried Googling for info but I can't find anything that I understand, any help with this would be amazing, it should be a simple task I would have thought?
I personally don't use the ECK module, so I don't know how it works exactly, I can only imagine. I build my entities by myself.
But what I do know is that the FormBase class is the wrong (not wrong per se, but there's another class which handles exactly what you want) one to use to save entities. You're supposed to use the ContentEntityForm class for that.
Docs: https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!ContentEntityForm.php/class/ContentEntityForm/8.2.x
The FormBase class is the generic form class, you use it basically for custom and simple stuff, where you only need the buildForm, validateForm and submitForm implementations (more or less).
I used the suggested approach in this question to return HATEOAS formatted outputs that match those returned by spring-data-rest. It works good, but is there a way to avoid boiler plate code to create entity resource assemblers like the QuestionResourceAssembler in the referenced question, if I only want to add 'self' links using the id to all entities? Perhaps using ResourceAssemblerSupport?
The easiest way is to simply use the Resource wrapper type:
Resource<Person> personResource = new Resource<>(person);
personResource.addLink(…);
personResource.addLink(…);
Links can be created either by simply instantiating them (i.e. new Link("http://localhost/foo", "relation") or by using the ControllerLinkBuilder which allows you to point to Controller methods for obtain a reverse mapping. See this section of the Readme for details.
Not sure if i'm using the right vocabulary. In the browsable api that comes for free with django-rest-framework, I was wondering if there was a way to autogenerate a form similar to how we define ModelForms. This would allow us to more easily test input to the API in some cases.
I'm currently using ModelSerializers and the generic view APIView in case that makes a difference.
I have read the documentation (several times at this point) but didn't see it mentioned anywhere.
If you're using the generic class-based-views you'll get that for free. Try the live tutorial at http://restframework.herokuapp.com logging in as one of the users, so that you can create some snippets. eg user: 'max', password: 'max'.
Any views subclassing GenericAPIView and setting a serializer_class will get that behavior, as REST framework can determine what the form should look like.
For example:
(Note the form input at the bottom of the screen shot)
If you're just working from APIView you'll get the generic content input (such as json), like the once you've included a screenshot of, which is also useful, but not quite as convenient as the forms.
Create a serialiser class that fits the form input fields you want and set it on your APIView like so;
class MyView(APIView):
serializer_class = MySerializer # Used for the form in the browsable api
That works just perfectly.
Example of a serializer class based on a model:
from rest_framework import serializers
class MySerializer(serializers.ModelSerializer):
class Meta:
model = MyModel
class MyApiView(APIView):
"""My Demo API View"""
serializer_class = serializers.MySerializers
Make sure you're using the name "serializer_class" and not any other name like serializers_class.
using the exact "serializer_class" will autogenerate form in the browseable API
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/