Can Doctrine generated models have a prefix? - doctrine

Is there an option in Doctrine that would specify a prefix for any classes generated by doctrine?
I'm having trouble with the new Zend autoloader and autoloading models, the doctrine autoloader doesn't help either.
Ideally I'd have the doctrine generated classes prefixed with 'Model_', as in 'Model_User'.
I ran into this issue while trying to generate migrations using generate-migrations-diff, it says Fatal error: Cannot redeclare class BaseUser in /tmp/fromprfx_doctrine_tmp_dirs/generated/BaseUser.php on line 38
Because the actual model is loaded before the newly generated class.

Sorry, I was to hasty about asking the question and found the answer seconds later.
Adding:
Doctrine_Manager::getInstance()->setAttribute('model_loading', 'conservative');
Fixed the issue.

Related

Laravel RouteServiceProvider.php file

I'm relatively new to Laravel; using 8.26.1
just after creating a project, I noticed that I have RouteServiceProvider.php exists in two locations:
app\providers\ and \vendor\laravel\framework\src\Illuminate\
can someone explain which one should I use to make my changes or guide me to a document where I can read about how and which file is used by Laravel ?
You would be using the one in your application which is everything that isn't in vendor as that is all packages and you should not touch any of that. The App\Providers\RouteServiceProvider (app/Providers/RouteServiceProvider.php) is the provider that is loaded by your configuration in config/app.php. This extends the base one from Laravel to give it the features it needs.

PrestaShop working with Doctrine & Entites

Hello :) On start: I use PrestaShop 1.7.6.2 and MySQL 5.6 and PHP 7.2
I want to create a module on new way with Symfony Controller and Entites without ObjectModel (beacouse like say one of develoeper of PrestaShop: Pablo Borowicz - ObjectModel is deprecated)
So on start I create simple module available at the link
https://github.com/DarkSidePro/testmodule
Controller and routing works perfect the problem is when I try use enity manager
$entityManager = $this->container->get('doctrine.orm.entity_manager');
$testRepository = $entityManager->getRepository(TestmoduleTest::class);
$test = $testRepository->findAll();
And I have error like that:
The class 'DarkSide\Testmodule\Entity\TestmoduleTest' was not found in the chain configured namespaces PrestaShopBundle\Entity
Maybe I doing something wrong? But doc of prestashop of coures is suck about new way of creating a PrestaShop modules
Looking 4 help :)
Thx all :)
The PrestaShop documentation is a completely mess concerning the handling of the Symfony repositories.
Doctrine is looking (by the auto_mapping orm configuration attribute) for the presence of your entity under the Prestashop Entity namespace, so given that your TestmoduleTest entity isn't there, it cannot be found and therefore loaded.
You may have to register your entity under the following namespace : namespace PrestaShop\Module\Testmodule\Entity;
You'll be able to find more about how to create your own repository class inside the official productcomments module here.
Ok the problem is on other way :)
In this case i have problem with my Repository class (probably with constructor of this class)
when I deleted them module start work
Problem solved :)

Laravel Auditing AuditableTransitionException Error on Morphmap on transitionTo()

I am able to successfully record changes to classes, and return what has been changed (not including many-to-many). However, I am unable to revert back any change using the built-in new transitionTo() method.
I get the following error on all classes:
Expected Auditable type App\XYZ, got XYZ instead
I have all of my morphable classes (which are all I am using for tracking audits) attached correctly within AppServiceProvider in a morphmap like so:
\Illuminate\Database\Eloquent\Relations\Relation::morphMap([
'Employee' => \App\Employee::class,
];
All classes work correctly with all other Laravel morphTo methods.
The auditable code looks like it is tripping the error in line 467 of the Auditable class:
if (!$this instanceof $audit->auditable_type) {}
It doesn't appear to be looking to the map for any of the morphed classes. Or, I could be totally missing something of course!
Any help on how to get this to work using the auditing method -- has anyone gotten this to work with standard morph classes? (It will of course revert the class manually by looping on the old fields and saving the object).
Using Laravel 5.5 and the latest version (5.0) of Laravel-Auditing.
Sent a note to the developer - this was in fact a bug. Vendor code was needed to include morphMapped objects.
Developer at Laravel Auditing responded within an hour and had a fix a few hours later. I can confirm this is now functioning as expected. Outstanding support.

Doctrine:generate-migrations-diff symfony 1.4

I'm having some problems with doctrine-migration.
Changed the code in my schema.yml to add a new column:
filesAttached: {type: array}
After that, I ran doctrine:generate-migrations-diff, and although the message says "Generated migration classes successfully from difference" and a temporary doctrine_schema.yml is created, there is no migration class under my /lib/migration/doctrine folder.
Even if I try to run doctrine:migrate, it tells me that my migration is at the latest version.
I've used migrations before (2 days ago, I think) and everything worked just fine.
Any idea on what I'm doing wrong?
Unfortunately the auto generated migrations sometimes behave in such way (I never felt like diving into it and finding the reason).
What I would suggest if you have some other migrations classes is to write your own classes based on what you have. Just remember to change the class name to the next version number and give the file a name which is "greater" than the last file you have.
E.g. if you have class version_3 in file version3_334455.php just name it version_4 and put in version4_334456.php.
As to the syntax of the migration you should use this shouldn't be very difficult to figure it out based on the files you already have generated.

Loading PSR-0 incompatible libraries in Laravel 3

I need to use an old library in Laravel which is not PSR-0 compliant.
It consists of several files and directories with a lot of "require", "include" and "require_once" stuff inside. So, I tried to put it into the "libraries/subfolder" and autoload an entry script but it breaks the framework and I constantly get "Class 'Laravel\Response' not found" error. I can't find the reason of this error but I guess that it somehow breaks Laravel's autoloading system.
How to fix this? How can I load this kind of library and keep things working?
Thank you!
If anybody else faces the same problem with Laximo API and Laravel, just use nusoap instead of nusoap_utf8 class.

Resources