Doctrine Object Select not hydrating as object - doctrine-orm

I have a form with a fieldset which contains a Doctrine ObjectSelect element.
$this->add(array(
'name' => 'vatRate',
'type' => 'DoctrineModule\Form\Element\ObjectSelect',
'options' => array(
'label' => _('VAT Rate:'),
'object_manager' => $this->getEntityManager(),
'target_class' => 'Application\Entity\VatRates',
'property' => 'title',
'is_method' => true,
'find_method' => array(
'name' => 'getVatRatesOrderRate',
),
'label_generator' => function($targetEntity) {
return $targetEntity->getTitle() . ' (' . $targetEntity->getVatRate() . '%)';
},
'disable_inarray_validator' => TRUE,
),
));
In my invoiceItems entity I have
/**
* #var \Application\Entity\VatRates
*
* #ORM\ManyToOne(targetEntity="Application\Entity\VatRates")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="vat_rate_id", referencedColumnName="vat_rate_id")
* })
*/
private $vatRate;
/**
*
* #param VatRates|NULL $vatRate
* #return \Application\Entity\InvoiceItems
*/
public function setVatRate(VatRates $vatRate = NULL)
{
$this->vatRate = $vatRate;
return $this;
}
The problem I am having is that when I validate the form Doctrine's DoctrineObject hydrator is not converting the vatRate to an entity before passing it to the setter. I get the following error.
Catchable fatal error: Argument 1 passed to Application\Entity\InvoiceItems::setVatRate() must be an instance of Application\Entity\VatRates, integer given, called in C:\Users\User\OneDrive\Documents\My Webs\freedomsnew\vendor\doctrine\doctrine-module\src\DoctrineModule\Stdlib\Hydrator\DoctrineObject.php on line 282 and defined in C:\Users\User\OneDrive\Documents\My Webs\freedomsnew\module\Application\src\Application\Entity\InvoiceItems.php on line 339
As can be seen by the error message the integer vatRateId is being sent to the invoiceItems entity setVatRate method.
I have other forms/fieldsets setup in a similar way and all work with no problems. Does anyone know what I have done wrong here?

The problem was that Doctrine had cached the entity. Clearing the cache solved the problem.
php ./vendor/doctrine/doctrine-module/bin/doctrine-module orm:clear-cache:query
php ./vendor/doctrine/doctrine-module/bin/doctrine-module orm:clear-cache:metadata
php ./vendor/doctrine/doctrine-module/bin/doctrine-module orm:clear-cache:result
I setup a batch file to do this from now on.

Related

ZF2 form removing nested collection after validation

I have three related Doctrine entities that I am trying to use with Zend Form collections.
The entities are InvoiceItems -> (one to many) -> InvoiceItemOptions -> (one to many) InvoiceItemOptionValues.
When I add a new item all options and values are populating the entity correctly. However when I edit a item the values are being removed from the options entity. The form displays correctly so the values are being pulled from the database and DoctrineObject hydrator is populating the form. The values are lost after the form is validated.
My entity code
InvoiceItems
/**
* #var \Doctrine\ORM\PersistentCollection
*
* #ORM\OneToMany(targetEntity="Application\Entity\InvoiceItemOptions", cascade={"persist"}, orphanRemoval=true, mappedBy="invoiceItem")
* })
*/
private $options;
InvoiceItemOptions
/**
* #var \Application\Entity\InvoiceItems
*
* #ORM\ManyToOne(targetEntity="Application\Entity\InvoiceItems", cascade={"persist"}, inversedBy="options")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="invoice_item_id", referencedColumnName="invoice_item_id")
* })
*/
private $invoiceItem;
/**
* #var \Doctrine\ORM\PersistentCollection $values
*
* #ORM\OneToMany(targetEntity="Application\Entity\InvoiceItemOptionValues", cascade={"persist"}, orphanRemoval=true, mappedBy="invoiceItemOption")
* })
*/
private $values;
InvoiceItemOptionValues
/**
* #var integer
*
* #ORM\Column(name="invoice_item_option_value_id", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $invoiceItemOptionValueId;
/**
* #var \Application\Entity\InvoiceItemOptions
*
* #ORM\ManyToOne(targetEntity="Application\Entity\InvoiceItemOptions", cascade={"persist"}, inversedBy="values")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="invoice_item_option_id", referencedColumnName="invoice_item_option_id")
* })
*/
private $invoiceItemOption;
/**
* #var string
*
* #ORM\Column(name="value", type="text", length=65536, nullable=false)
*/
private $value;
/**
* #var string
*
* #ORM\Column(name="price", type="decimal", precision=9, scale=2, nullable=false)
*/
private $price;
And in my fieldsets I have
InvoiceItemFieldset
$this->add(array(
'type' => 'Collection',
'name' => 'options',
'options' => array(
'count' => 0,
'should_create_template' => TRUE,
'template_placeholder' => '__OPTION__',
'allow_add' => TRUE,
'allow_remove' => TRUE,
'target_element' => $this->invoiceItemOptionFieldset,
),
));
InvoiceItemOptionFieldset
$this->add(array(
'type' => 'Collection',
'name' => 'values',
'options' => array(
'count' => 0,
'should_create_template' => TRUE,
'template_placeholder' => '__VALUE__',
'target_element' => $this->invoiceItemOptionValuesFieldset,
),
));
InvoiceItemOptionValuesFieldset
public function init()
{
$this->add(array(
'name' => 'invoiceItemOptionValueId',
'type' => 'Hidden'
));
$this->add(array(
'name' => 'value',
'type' => 'Textarea',
'options' => array(
'label' => _('Value:'),
'label_attributes' => array('class' => 'required'),
),
'attributes' => array(
'cols' => 30,
'rows' => 5,
),
));
$this->add(array(
'name' => 'price',
'type' => 'Text',
'options' => array(
'label' => _('Price Inc. VAT:'),
),
'attributes' => array(
'size' => 10,
'maxlength' => 10,
),
));
}
EditItemModel
use Zend\Stdlib\Parameters;
...
public function processForm(Parameters $postData)
{
$entityManager = $this->getEntityManager();
$this->form->setData($postData);
if ($this->form->isValid()) {
// values lost here
$this->form->bind($this->entity);
$this->setFormValid(TRUE);
if ($this->entity->getQuantity() < 1) {
$this->entity->setQuantity(1);
}
$goodsTotal = $this->entity->getPriceEachIncVat() * $this->entity->getQuantity();
$optionsTotal = 0.00;
foreach ($this->entity->getOptions() as $option) {
foreach ($option->getValues() as $value) { // entity has no values
if ($value->getPrice() > 0) {
$optionsTotal = $optionsTotal + ($value->getPrice() * $this->entity->getQuantity());
}
}
}
$this->invoiceModel->calculateItemsVat($this->entity, $goodsTotal, $optionsTotal);
$entityManager->persist($this->entity);
if ($this->flushEntityManager($entityManager)) {
return $this->invoiceModel->calculateInvoiceTotals($this->getInvoice()->getInvoiceId());
}
}
return FALSE;
}
Finally my post data
Array
(
[items] => Array
(
[options] => Array
(
[0] => Array
(
[name] => Test Option 0
[invoiceItemOptionId] => 37
[values] => Array
(
[0] => Array
(
[value] => Test Option 0 Value 0
[price] => 0.00
[invoiceItemOptionValueId] => 37
)
[1] => Array
(
[value] => Test Option 0 Value 1
[price] => 29.99
[invoiceItemOptionValueId] => 38
)
)
)
)
[title] => Title
[sku] =>
[quantity] => 2
[priceEachIncVat] => 1000.00
[vatRate] => 1
[invoiceItemId] => 20
)
)
I am using Zend Framework version 2.5.1 and Doctrine ORM Module version 1.0.0
Hopefully someone knows what is going on here, many thanks in advance.
I have found a solution.
Adding the line $this->form->setBindOnValidate(FormInterface::BIND_MANUAL); before form validation solved the problem. I also added $this->form->bind($this->entity) after validation;
Hope this helps someone.
EDIT
I also found that the array collection for values in InvoiceItemOptions entity was not being cloned during hydration so the InvoiceItemOptionValues were wrong. I solved this issue by adding the magic method __clone() to my InvoiceItemOptions entity.
public function __clone()
{
$this->values = new ArrayCollection();
}

Symfony 2 knplabs form translation - best way to change the referenceColumName

A2lix required 'id' as referenceColumName. But I've entities with a different columName (e.g. ProductID instead of id). So I get error when I try to update my DB via doctrine:schema:update --force.
Example of my entity
class Period
{
use ORMBehaviors\Translatable\Translatable,
ORMBehaviors\Timestampable\Timestampable,
ORMBehaviors\SoftDeletable\SoftDeletable
;
/**
* #var integer
*
* #ORM\Column(name="PeriodID", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
...
Part of the TranslatableSubscriber class of KnpDoctrineBehaviors Package
...
private function mapTranslatable(ClassMetadata $classMetadata)
{
if (!$classMetadata->hasAssociation('translations')) {
$classMetadata->mapOneToMany([
'fieldName' => 'translations',
'mappedBy' => 'translatable',
'indexBy' => 'locale',
'cascade' => ['persist', 'merge', 'remove'],
'fetch' => $this->translatableFetchMode,
'targetEntity' => $classMetadata->getReflectionClass()->getMethod('getTranslationEntityClass')->invoke(null),
'orphanRemoval' => true
]);
}
}
private function mapTranslation(ClassMetadata $classMetadata)
{
if (!$classMetadata->hasAssociation('translatable')) {
$classMetadata->mapManyToOne([
'fieldName' => 'translatable',
'inversedBy' => 'translations',
'fetch' => $this->translationFetchMode,
'joinColumns' => [[
'name' => 'translatable_id',
'referencedColumnName' => 'id',
'onDelete' => 'CASCADE'
]],
'targetEntity' => $classMetadata->getReflectionClass()->getMethod('getTranslatableEntityClass')->invoke(null),
]);
}
$name = $classMetadata->getTableName().'_unique_translation';
if (!$this->hasUniqueTranslationConstraint($classMetadata, $name)) {
$classMetadata->table['uniqueConstraints'][$name] = [
'columns' => ['translatable_id', 'locale' ]
];
}
if (!$classMetadata->hasField('locale')) {
$classMetadata->mapField(array(
'fieldName' => 'locale',
'type' => 'string'
));
}
}
...
Any idea or help would be appreciate.
Many thanks ;-)
You can use:
association override
I tried to override properties but they are created by the subscriber and I got exceptions. You can also re-declare the annotation manyToOne on your entity class.
It works for me.

Doctrine 2: Form field shows Doctrine\Common\Collections\ArrayCollection#00 as value

I am pretty new to Zend Framework 2 and Doctrine 2, so I am not even sure how to search or debug my problem.
I have 3 database tables
1. advert
id
adverttitle
...
2. category
id
categoryname
...
3. advert_category
advert_id
category_id
I have created 2 Entities, Advert and Category. I have now got a Form where I show the Categories to choose from. I use jQuery to display the categories as a list instead of a dropdown, together with a selectable function. So when you click on a category, the value of this listelement gets entered into a hidden input field called categories.
Everything works fine, besides that when I display the form, the hidden categories input field got a value of Doctrine\Common\Collections\ArrayCollection#000000000..... instead of being empty. What am I doing wrong here? I have tried to find a solution, but unsuccessfully.
I have chosen a ManyToMany Relationship because I want to be able to save more then 1 category in the end. Currently it is only working with 1, but this way I should be able to change this at a later time.
Here my Advert entity:
namespace Advert\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use DateTime;
/** Advert
*
* #ORM\Table(name="advert")
* #ORM\Entity(repositoryClass="Advert\Repository\AdvertRepository")
*/
class Advert
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="advert_title", type="string", length=255, nullable=true)
*/
private $advertTitle;
/**
* #ORM\ManyToMany(targetEntity="Category", inversedBy="adverts", cascade={"persist"})
* #ORM\JoinTable(name="advert2category")
*/
private $categories;
public function __construct()
{
$this->categories = new ArrayCollection();
}
/**
* Set categories
*
* #param ArrayCollection $category
* #return Advert
*/
public function setCategories($categories)
{
$this->categories = $categories;
return $this;
}
/**
* Get categories
*
* #return ArrayCollection
*/
public function getCategories()
{
return $this->categories;
}
/**
* #param Collection $categories
*/
public function addCategories($categories)
{
foreach ($categories as $category) {
$this->categories->add($category);
}
}
/**
* #param Collection $categories
*/
public function removeCategories($categories)
{
foreach($categories as $category){
$this->categories->removeElement($category);
}
}
Is there an Error in the Advert Entity which causes this? I hope someone can help. I have this problems since weeks and can not get it to work correctly.
UPDATE -- added my Form and part in controller to call form
The below Form displays 2 Dropdown Elements and 2 Hidden Input Fields. The 2 Dropdown Fields get turned into a selectable List via jQuery. When you click on a List Element from the Maincategory, the Subcategories show up for that chosen Maincategory again as a selectable list. The MaincategoryID gets then entered into the hidden categoryID Field. As soon you choose the Subcategory from the List, the id of that category gets written in the hidden categories field. A click on the "next" button saves the value of $_POST['categories'] together with the advertID in my linking table.
use Zend\Form\Form;
use DoctrineModule\Persistence\ObjectManagerAwareInterface;
use Doctrine\Common\Persistence\ObjectManager;
class CategoryForm extends Form implements ObjectManagerAwareInterface
{
protected $objectManager;
public function __construct()
{
$this->setInputFilter(new AdvertFilter());
parent::__construct('category');
}
public function init()
{
$this->setAttribute('method', 'post');
$this->add(array(
'name' => 'categories',
'attributes' => array(
'type' => 'hidden',
'id' => 'categories',
),
'options'=> array(
'label'=> 'categories',
),
));
$this->add(
array(
'type' => 'DoctrineModule\Form\Element\ObjectSelect',
'name' => 'categoriesList',
'options' => array(
'object_manager' => $this->getObjectManager(),
'label' => 'Main Category',
'target_class' => 'Advert\Entity\Category',
'property' => 'name',
'is_method' => true,
'find_method' => array(
'name' => 'getMainCategories',
),
),
'allow_empty' => true,
'required' => false,
'attributes' => array(
'id' => 'categoryList',
'multiple' => true,
)
)
);
$this->add(
array(
'type' => 'DoctrineModule\Form\Element\ObjectSelect',
'name' => 'subcategoryList',
'options' => array(
'object_manager' => $this->getObjectManager(),
'label' => 'Sub Category',
'target_class' => 'Advert\Entity\Category',
'property' => 'name',
'is_method' => true,
'find_method' => array(
'name' => 'getSubCategories',
),
),
'allow_empty' => true,
'required' => false,
'attributes' => array(
'id' => 'subcategoryList',
'multiple' => true,
)
)
);
$this->add(array(
'type' => 'hidden',
'name' => 'categoryID',
'options'=> array(
'label'=> 'categoryID'),
'attributes' => array(
'id' => 'categoryID',
'value' => '1',
)
));
$this->add(array(
'name' => 'submit',
'attributes' => array(
'type' => 'submit',
'value' => 'Next',
'id' => 'submitbutton',
),
));
}
public function setObjectManager(ObjectManager $objectManager)
{
$this->objectManager = $objectManager;
}
public function getObjectManager()
{
return $this->objectManager;
}
}
In my Controller I call my form the following way:
$sl = $this->getServiceLocator();
$form = $sl->get('FormElementManager')->get('\Advert\Form\CreateForm');
# create a new, empty entity
$advert = new Advert();
# set the hydrator to connect form and entity
$form->setHydrator(new DoctrineHydrator($this->getEntityManager(),'Advert\Entity\Advert'));
# connect form and entity
$form->bind($advert);
The first thing is, bidirectional relationships doesn't uses join tables. Your mapping seems like bi-directional however you're trying to use the third table: advert_category.
I recommend to change mapping of the $categories property of Advert entity to a uni-directional relationship:
class Advert
{
// ...
/**
* #ORM\ManyToMany(targetEntity="Category")
* #ORM\JoinTable(name="advert_category",
* joinColumns={#ORM\JoinColumn(name="advert_id", referencedColumnName="id")},
* inverseJoinColumns={#ORM\JoinColumn(name="category_id", referencedColumnName="id")}
* )
**/
protected $categories;
// ...
}
Also you should implement the addCategories(Collection $categories) and removeCategories(Collection $categories) methods inside Advert entity if you want to take advantage of DoctrineObject hydrator. (I'm assuming that you're using DoctrineORMModule).
At this point, your Category entity shouldn't know anything about Advert and you CAN'T DIRECTLY ACCESS all adverts from a category instance via an entity method like $category->getAdverts(). However when needed, you can easily write a getAdvertsByCategoryId($categoryId) method in your AdvertRepository.
The last detail is, you should have a CategoryFieldset (which also needs to use Category entity as object) and you have to point this fieldset in your form's categories element using target_elementconfiguration key or directly providing instance's itself.
For example:
$formManager = $serviceLocator->get('FormElementManager');
$form = $formManager->get('your\form\name');
$form->add(
array(
'name' => 'categories',
'type' => 'Zend\Form\Element\Collection',
'options' => array(
'target_element' => $formManager->get('your\fieldset\name');
// or you can do this but probably you will also need $entityManager
// inside the CategoryFieldset
// 'target_element' => new CategoryFieldset();
),
)
);
I strongly recommend using of FormElementManager to get form and fieldset instances instaed of directly instantiate them by new AdvertForm() and new CategoryFieldset(). Also writing an AbstractFormElementFactory would be good practice to inject $entityManager like dependencies to your fieldsets and forms, the right way.
Hope it helps.

Zend 2 Doctrine 2 Gedmo Translatable

I am trying to use the Gedmo translatable extension for Doctrine 2 in a Zend Framework 2 application.
I have it setup like this:
'doctrine' => array(
'eventmanager' => array(
'orm_default' => array(
'subscribers' => array(
'Gedmo\Translatable\TranslatableListener'
)
)
),
'driver' => array(
'application_entities' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(__DIR__ . '/../src/Application/Entity')
),
'translatable_metadata_driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(
'vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity',
)
),
'orm_default' => array(
'drivers' => array(
'Application\Entity' => 'application_entities',
'Gedmo\Translatable\Entity' => 'translatable_metadata_driver'
)
)
),
),
Sample Entity:
<?php
namespace Application\Entity;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* #ORM\Entity (repositoryClass="Application\Repository\CategoryRepository")
*/
class Category {
/**
* #ORM\Id
* #ORM\GeneratedValue
* #ORM\Column(type="integer")
*/
private $id;
/**
* #ORM\Column(type="string")
* #Gedmo\Translatable
*/
private $name;
/**
* #Gedmo\Locale
*/
private $locale;
}
Persisting translations works fine and I can get them using the translatable repository.
I have two problems:
I cannot figure out how to get the translatable listener subscribed to the entitymanager. I would like to get it in the Module class to set the default locale on bootstrap.
When I have an entity object I cannot get the translations of translatable columns, only the standard values. As far as I can figure out, I should get a value translated to the default locale, and should be able to override the default locale by setting a variable in the Entity annotated with Locale, but it does not seem to work.
Any help would be greatly appreciated!
public function onBootstrap(MvcEvent $event)
{
$serviceManager = $event->getApplication()->getServiceManager();
$this->prepareGedmoTranslatable($serviceManager);
}
/**
* Does initial config of Gedmo\TranslatableListener
* sets default locale and registers it as service
*
* Reader you can ask why?
* You will understand me if you try to use TranslatableListener yourself ;)
*
* #param ContainerInterface $services
*/
public function prepareGedmoTranslatable(ContainerInterface $services)
{
/**
* #var EventManager $ormEventManager
*/
$ormEventManager = $services->get('doctrine.eventmanager.orm_default');
// assume that postLoad event has TranslatableListener as listener
// it will be if TranslatableListener enabled in doctrine config
// Doctrine\ORM\Events::postLoad
$listeners = $ormEventManager->getListeners(Events::postLoad);
$translatableListener = null;
// search for TranslatableListener cause Gedmo loves hardcore stuff ;)
foreach ($listeners as $listener) {
if ($listener instanceof TranslatableListener) {
$translatableListener = $listener;
break;
}
}
if ($translatableListener instanceof TranslatableListener) {
$translatableListener->setDefaultLocale(
// assume that translator config provides default locale
// e.g locale that have been set in config
$services->get('config')['translator']['locale']
);
// let translations to fallback to default locale
$translatableListener->getTranslationFallback(true);
// lines below adds Listener as a service so you can access it by
// $services->get(TranslatableListener::class)
// everywhere you want
$services->setAllowOverride(true);
$services->setService(TranslatableListener::class, $translatableListener);
$services->setAllowOverride(false);
}
}
Glad to help you!

Possible database configuration problems

I'm a new Zend developper and I have got some conception problem's (especially with doctrine).
I've got a Class which is called MyAuthenticationProcess.
This class is trying to authenticate an User by verifiying his identity on a Database.
As I saw over the internet, I should implement 3 things in order to communicate with my dataBase.
First of all, I have to add those lines in my module.config.php
'doctrine' => array(
'driver' => array(
__NAMESPACE__. '_driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity')
),
'orm_default' => array(
'drivers' => array(
__NAMESPACE__.'\Entity' => __NAMESPACE__.'_driver'
)
)
)
),
Secondly I have to create a file which will contains my Entity. I created this file in Authentification/Entity/User.php
Here is the code of this file :
<?php
namespace Authentification\Entity;
use Doctrine\ORM\Mapping as ORM;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;
/**
* A User table.
*
* #ORM\Entity
* #ORM\Table(name="user")
* #property string $login
* #property string $password
* #property int $id
*/
class User {
/**
* #ORM\Id
* #ORM\Column(type="integer");
* #ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* #ORM\Column(type="string")
*/
protected $login;
/**
* #ORM\Column(type="string")
*/
protected $password;
/**
* Magic getter to expose protected properties.
*
* #param string $property
* #return mixed
*/
public function __get($property)
{
return $this->$property;
}
/**
* Magic setter to save protected properties.
*
* #param string $property
* #param mixed $value
*/
public function __set($property, $value)
{
$this->$property = $value;
}
}
?>
And to finish I added this configuration into this file : config/autoload/local.php
<?php
return array(
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => '3306',
'user' => 'root',
'password' => '',
'dbname' => 'zf2tutorial',
)
)
)
),
);
The problem that I have now is for accessing to my dataBase.
I guess it's a problem of configuration.
In my class MyAuthenticationProcess I'm trying to get all the entries of my table "User". But I can't.
Here is the code that I used to do so :
$users = $this->getEntityManager()->getRepository('Authentification\Entity\User')->findAll() ;
var_dump($users) ;
And here is the error that I get :
<br />
<b>Fatal error</b>: Uncaught exception 'Zend\View\Exception\RuntimeException' with message 'Zend\View\Renderer\PhpRenderer::render: Unable to render template "layout/layout"; resolver could not resolve to a file' in xampp\htdocs\kjsencha\vendor\zendframework\zendframework\library\Zend\View\Renderer\PhpRenderer.php:457
Stack trace:
#0 xampp\htdocs\kjsencha\vendor\zendframework\zendframework\library\Zend\View\View.php(201): Zend\View\Renderer\PhpRenderer->render(Object(Zend\View\Model\ViewModel))
#1 xampp\htdocs\kjsencha\vendor\zendframework\zendframework\library\Zend\Mvc\View\Http\DefaultRenderingStrategy.php(126): Zend\View\View->render(Object(Zend\View\Model\ViewModel))
#2 [internal function]: Zend\Mvc\View\Http\DefaultRenderingStrategy->render(Object(Zend\Mvc\MvcEvent))
#3 xampp\htdocs\kjsencha\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(460): call_user_func(Array, Object(Zend\Mvc\MvcEvent)) in <b>\xampp\htdocs\kjsencha\vendor\zendframework\zendframework\library\Zend\View\Renderer\PhpRenderer.php</b> on line <b>457</b><br />
To make sure that is a problem of configuration I tried to know if the connection was established by using this :
$users = $this->getEntityManager()->getConnection() ;
var_dump($users) ;
I was surprise to see that users equals to NULL.
Do you have any idea where the problem came from ?
Thank you for your help.
I finally found where my problem came from =D
It was my table structure in my database. It was not similar to my entity files, so I change it and now it work.
Hope my post will help someone else which has the same problem.