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/
Related
I'm using the Automapper (v10) and Automapper EF6 (v2) library for the first time (I've used AutoMapper successfully before) with EF6.4 and I'm getting a weird issue with the following line of code
using (DashboardEntities db = new DashboardEntities())
return db.Dashboards.ProjectToList<DTO.Dashboard>();
Really just want to get all entities from the DB, but mapped to DTO objects so I can keep the UI and Data projects distinct and not have an EF6 reference in my UI project.
The above snippet builds but throws a runtime exception:
System.MissingMethodException: 'Method not found: System.Linq.IQueryable`1<System.__Canon>
AutoMapper.QueryableExtensions.Extensions.ProjectTo(System.Linq.IQueryable,
System.Linq.Expressions.Expression`1<System.Func`2<System.__Canon,System.Object>>[])
The documentation gives an example using an Async version of the above method, but in my scenario, I don't want this.
I don't get why I'm getting this MissingMethodException at runtime
I could use the basic Automapper library and add some lines of code, but that defeats the purpose of the AutoMapper EF6 plugin and also reminds of this blog post I saw a while back
Thanks in advance for any insights
In the ProjectToList method, try to pass in the IConfigurationProvider. For example:
db.Dashboards.ProjectToList<DTO.Dashboard>(Mapper.ConfigurationProvider);
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.
org.dozer.MappingException: No read or write method found for field
(tarShipMethodCode.lmCourier.courierName) in class (class
com.essilor.ong.domain.inventory.POLocationEntity)
I am getting this error when i build my war file and try to run Tomcat.
I am using JPA and dozer mapping.
Can anyone tell me how to fix it?
Check your Beans and your Dozer-Mapping-File.
There are multiple (more or less common) errors possible:
Typo in the mappingfile. Check the package and field names in your POLocationEntity, does it have a field named tarShipMethodCode, and does this have an ImCourier field, and this a courierName field?
Lack of getters / setters. Again check the beans, Dozer usually expects getFieldName and setFieldName methods, unless you specified others (which I do not assume, maybe post your mapping file).
Narrow the problem down: Is this the only field that is not working? Or is this field not specified at all? Dozer tends to try to map-by-name fields that do not have corresponding entries in the mapping file, which could lead to unexpected errors.
tl;dr
With some more information (mapping xml, bean code) this would be easier to analize, but the above pointers are the ones that solve these kinds of problems in my experience.
i have big Trouble using the EntityFramework 5.0. After updating EF in our Project from EF4.2 to EF5.0. The Framework throws InvalidOperationExceptions in the TypeInitializer of InsertHistoryOperation during initializing of the database. (In the InnerException it says: "The List does not contain any element").
I tried using DropCreateAlwaysInitializer as well as DropWhenModelChanges. We don't need the Migration Feature (Sure, would be nice to have, but not recommend). Is there a way to disable the Migration Feature so the exception is not thrown. Or can somebody give me a hint what i did wrong?
The Model is very complex, so i think its not very useful to post it here.
best regards,
Chris
I tried with .Net4.0 and .Net4.5
Ok, i got it.
The Problem is that the EntityFramework since V5.0 is not able to work correctly if you merge it into (e.g. a Datalayer Assembly) or use it from a merged assembly. (ILMerge).
I am using Dozer to map my JAXB objects that come off a WebService interface to my domain objects. One of the elements or properties in my JAXB is a String set/setLocation(). This would be the description of the location. What I need in the backend is the to take that String and map it to a code which will be stored in my database. I've looked in the Dozer website and junit tests and I don't see anything that I can use as an example. I was hoping I could create some custom setter mapper to do this but I am looking for an example that I can start with. Any help would be appreciated.
With a little investigation I found a way to resolve my problem with a field level converter.
Here is the Dozer documentation for those interested: http://dozer.sourceforge.net/documentation/customconverter.html