Orm Entities 8.0.0 / 8.1.0

Permalink
Hello
I tried to copy a block which i developed on 8.0.0 to my new project on 8.1.0. I use some custom doctrine entities within this block but on my new project there was no database table created and no proxy class either.
In 8.0.0 i used the @ORM prefixes in the entity class like so:
namespace Entity;
use Doctrine\ORM\Mapping as ORM;
/**
 * @ORM\Entity
 * @ORM\Table(name="btMyCustomEntity")
 */
class MyCustomEntity{...}


To get the repository i used:
$items = $entityManager->getRepository('Entity\MyCustomEntity')
                ->findBy(array('bId' => $this->bID), array('orderNr' => 'ASC'));


Now on 8.1.0 this doesent seem to work anymore. If i set "appVersionRequired" in package controller to 5.7.13 and use "old" style class definition eg.
namespace Concrete\Package\MyPackage\Src\Entity;
/**
 * @Entity
 * @Table(name="btMyCustomEntity")
 */
class MyCustomEntity{...}

and
$items = $entityManager->getRepository('Concrete\Package\MyPackage\Src\Entity\MyCustomEntity')
->findBy(array('bId' => $this->bID), array('orderNr' => 'ASC'));

everything works fine.

Is anybody else stumbled upon this issue? Any help would be greatly appreciated.

Best Markus

Lemonbrain
 
4t4r1 replied on at Permalink Reply
4t4r1
Having the same issue, have posted a similar question @https://documentation.concrete5.org/developers/packages/custom-datab...
hutman replied on at Permalink Reply
hutman
Here are the changes I had to make when building entities for Version 8

In the controller

use \Concrete\Core\Database\EntityManager\Provider\StandardPackageProvider;
protected $appVersionRequired = '8.0.0';
public function getEntityManagerProvider()
{
    $provider = new StandardPackageProvider($this->app, $this, [
        'src/Concrete/Entity' => 'Concrete\Package\PackageName\Entity'
    ]);
    return $provider;
}

Then in the Entity (which lives in /packages/package_name/src/Concrete/Entity
namespace Concrete\Package\PackageName\Entity;
use \Doctrine\ORM\Mapping as ORM;

Making sure you use the @ORM\ before the definitions.

Then when you want to use the entity you can do
use Concrete\Core\Support\Facade\Database;
$resultss = Database::get()->getEntityManager()->createQuery('SELECT * FROM Concrete\Package\PackageName\Entity\EntityName')->getResult();

I hope this helps.