V8 ORM EntityManagerProvider

Permalink
Hello everyone

I've been struggeling to create a package with custom Entities in V8-style. I've created several packages in the legacy V7-style. This time I would want to add a custom attribute category as described inhttps://documentation.concrete5.org/developers/attributes/advanced-c...

I've followed the following tutorial for the ORM Entities and mapping the PHP namespaces:
https://documentation.concrete5.org/developers/packages/custom-datab...

I realized that apparently the entities are not being written to the DB. Therfore I created a test package (mypack) with just one entity in order to figure out the correct syntax:

File packages/mypack/controller.php:
<?php
namespace Concrete\Package\Mypack;
use Concrete\Core\Package\Package;
use Concrete\Core\Database\EntityManager\Provider\ProviderAggregateInterface;
use Concrete\Core\Database\EntityManager\Provider\StandardPackageProvider;
defined('C5_EXECUTE') or die(_("Access Denied."));
class Controller extends Package implements ProviderAggregateInterface
{
    protected $pkgHandle = 'mypack';
    protected $appVersionRequired = '8.0.0';
    //Increase this value if changes are made!
    protected $pkgVersion = '0.0.0';
    public function getPackageName()
    {
        return t("Test Package");


File packages/mypack/src/Concrete/Entity/Test.php
<?php
namespace Concrete\Package\Mypack\Entity;
use Core;
use \Doctrine\ORM\Mapping as ORM;
/**
 * Represents a message for the Debriefing package.
 *
 * @ORM\Entity
 * @ORM\Table(
 *     name="MypackTest",
 *     options={"comment": "Messages of the Debriefing package"}
 * )
 */
class Test
{


As soon as I put $appVersionRequired to '7.0.0' the table 'MypackTest' will be created on installation of the package but I can't get it to work for '8.0.0'!

Thank you in advance

Mario

simpit
 
linuxoid replied on at Permalink Reply
linuxoid
You've already set your path to 'Concrete\Package\MyPack\Entity', so your namespace has to be simply 'Entity' in this case.

And you don't need to use ProviderAggregateInterface.

Please have a look at my package controller:
namespace Concrete\Package\AbSimpleComments;
use Package;
use Asset;
use AssetList;
use Concrete\Core\Database\EntityManager\Provider\StandardPackageProvider;
use SimpleComments\Install\Installer;
class Controller extends Package {
    protected $pkgHandle = 'ab_simple_comments';
    protected $appVersionRequired = '8.3.2';
    protected $pkgVersion = '0.9.11';
    protected $pkgAutoloaderMapCoreExtensions = true;
    protected $pkgAutoloaderRegistries = [
        'src/SimpleComments' => 'SimpleComments'
    ];
    public function getPackageDescription()

and the class:
namespace SimpleComments\Comment;
use Doctrine\ORM\Mapping as ORM;
/**
 * @ORM\Entity
 * @ORM\Table(name="AbSimpleComments")
 */
class Comment
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
    public function getID()