PrestaShop working with Doctrine & Entites - doctrine

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 :)

Related

How to override any Model of vendor folder in laravel

I am using MongoDB as database so I need to change model of package tzsk\payu as using original is giving me following error
Call to a member function prepare() on null
I tried excluding original model and overriding using composer it doesn't work.
The only way would be if the package offered the option to use a custom model, like Passport is doing.
As far as I can see, there does not seem to be a way to do that. Thus you'd need to fork the package and edit the Model yourself.

Loading composer package into Laravel 5.2

I am trying to add the following package to my Laravel 5.2 project. At the top of my class I have added
use PhpImap\Mailbox as ImapMailbox;
use PhpImap\IncomingMail;
use PhpImap\IncomingMailAttachment;
I then do something like this
$mailbox = new ImapMailbox('{imap.gmail.com:993/imap/ssl}INBOX', 'some#gmail.com', '*********', __DIR__);
At the moment, when I visit the page I get
Class 'PhpImap\Mailbox' not found
I have tried many different ways to load it with the same result. Because this package is not Laravel specific, I don't know if I need to add anything else? Normally when I add Laravel packages I create a provider and alias, do I need to do that here?
Any information appreciated.
Thanks

CakePHP, Helper class AjaxHelper could not be found

I am trying to do this cakePHP ajax tutorial found at this site: http://poli.bonzahost.net/2010/07/17/simple-ajax-call-in-cakephp/
But it doesn't work. I made the database for it and made the table brokers with the needed fields, id, name, and last_name and added created and modified as 2 extra fields to the table. I set the settings in the database.php file to point it to my host and user and database schema with the right password and all that. I changed some things such as form->create, form->input, and ajax->submit to this->Form->create, this->form->Input and this->Ajax->submit, because I am working with CakePHP 2.1.2, not CakePHP 1.3.
But I get in my app: Helper class AjaxHelper could not be found.
Error: An Internal Error Has Occurred.,
I think the AjaxHelper.php file is missing from my download of cakePHP. I think it should be in: www\cakeAjax\app\View\Helper, but its missing from there. Is that the cause of this problem?
If so where can I find a copy of the AjaxHelper.php file, and is www\cakeAjax\app\View\Helper where I would put it? If not, how to I solve this problem?
Ajax helper is deprecated since CakePHP 1.3. You can now use the CakePHP's JsHelper for Ajax stuff.

Can I extend the DB library of CodeIgniter 2?

I want to add custom data to the insert method of the db library to automatically do some timestamp work and other processing. I know I can extend controller and model defaults with MY_, but what about the DB?
This isnt the right answer, because you can extend your CI Database class, i did it!
Just follow this tut and you will get it working!
https://github.com/EllisLab/CodeIgniter/wiki/Extending-Database-Drivers
im just have problems trying to use two database connections when the second connection is loaded with $this->db->load(), just had this problem, everyelse work like a charm!
No: see http://codeigniter.com/user_guide/general/creating_libraries.html, there is an explicit warning that the DB class can't be extended.

using doctrine with codeigniter

I am planning to use doctrine to write a module of my app which is built with codeigniter.
I have a very basic question :
lets say I have a table called "user", with doctrine generate-models from db, 3 classes are generated BaseUser.php, User.php and UserTable.php. Now as I saw in the examples they use User class straigtaway. Should I be doing this ? I need additional business functionality for the user objects. So should I create a codeigniter model user_model and then use User class inside it (aggregation) or somehow extend user class ( i dont know how this will be done as user_model extends model)
Am little confused on this one and cannot locate any appropriate literature for the same.
Any help would be appreciated.
thanks in advance,
For anyone who is interested - I’ve posted up a project starter on my blog - a dev ready incorporation of the following technologies:
ExtJS : client side JS library,
CodeIgniter : presentation + domain tier,
Doctrine : ORM data layer framework
Some features of this project starter are:
- CodeIgniter Models have been replaced with Doctrine Records
- Doctrine is loaded into CI as a plugin
- RoR type before and after filters….
- Doctrine transactions automatically wrapped around every action at execution time (ATOMIC db updates)
Basic Role based security (I think Redux may be in there as well?)
Simply extract, hook up the database.php config file and viola…. You can start coding your layouts, views and models. Probably a few things to iron out - but enjoy!
Hope it helps
GET IT AT: http://thecodeabode.blogspot.com
Check out this info on Doctrine_Table class.
To your 3 generated files:
BaseXXX.php:
Holds the definition of your models so that Doctrine is able to handle the operations on the database. This class tells the ORM what colums are available, their types, advaned functions (like Timestampable,...) and more. You should not put your own data into this file since it will be over-written when re-creating the models from the database.
XXX.php:
Your actual model. This won't be re-created with each new generation process and this is were you keep most of your code. You can overwrite functions of the BaseXXX.php if you have to.
XXXTable.php:
Check my link from the top, This gives you access to the table itself. Personally, I do not use it that often since I put most of the code into XXX.php.
Of course you can create new classes and use them inside your XXX.php file. In order to actually do something with the data (save, read,...) you need classes that are connected (exteneded) from Doctrine's classes.
edit: also check this on a more infos with extending from the Doctrine_Table class

Resources