Why maps bundle class when should not? #6191

Open
opened 2026-01-22 15:28:33 +01:00 by admin · 0 comments
Owner

Originally created by @BonBonSlick on GitHub (Mar 1, 2019).

Originally assigned to: @Ocramius on GitHub.

Q A
doctrine/annotations                   v1.6.0                           Docblock Annotations Parser
doctrine/cache                         v1.8.0                           Caching library offering an object-oriented API for many cache backends
doctrine/collections                   v1.5.0                           Collections Abstraction library
doctrine/common                        v2.10.0                          PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as better reflection support, ...
doctrine/data-fixtures                 v1.3.1                           Data Fixtures for all Doctrine Object Managers
doctrine/dbal                          v2.9.2                           Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
doctrine/doctrine-bundle               1.10.2                           Symfony DoctrineBundle
doctrine/doctrine-cache-bundle         1.3.5                            Symfony Bundle for Doctrine Cache
doctrine/doctrine-fixtures-bundle      3.1.0                            Symfony DoctrineFixturesBundle
doctrine/doctrine-migrations-bundle    v2.0.0                           Symfony DoctrineMigrationsBundle
doctrine/event-manager                 v1.0.0                           Doctrine Event Manager component
doctrine/inflector                     v1.3.0                           Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator                  1.1.0                            A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                         v1.0.1                           Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
doctrine/migrations                    v2.0.0                           PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and eas...
doctrine/orm                           v2.6.3                           Object-Relational-Mapper for PHP
doctrine/persistence                   v1.1.0                           The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.

Support Question

We have own package bundle with abstract entity and default preset fields.

...
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Uuid;

/**
 * Class AbstractFaq.
 */
abstract class AbstractFaq implements FaqInterface, TimeStampableInterface, AuditLoggableInterface
{
    use TimestampableTrait;
    use AuditLoggableTrait;

    /**
     * @var string
     *
     * @ORM\Column(type="text")
     */
    protected $category;

    /**
     * AbstractFaq constructor.
     *
     * @param string $category
     *
     * @throws \Exception
     */
    public function __construct(
        string $category
    ) {
        $this->id = Uuid::uuid4();
        $this
            ->setCategory($category)
            ->setSequence($sequence);
    }

    /**
     * @return string
     */
    public function __toString(): string
    {
        return $this->getQuestion();
    }

    /**
     * {@inheritdoc}
     */
    public function getCategory(): string
    {
        return $this->category;
    }

To make it work in project we create entity eg

namespace App\Entity;

use PackageName\BundleName\Entity\AbstractFaq;
use Doctrine\ORM\Mapping as ORM;

/**
 * Class Faq.
 *
 * @ORM\Table(name="faq")
 * @ORM\Entity
 */
class Faq extends AbstractFaq
{
}
 

Exception during migration diff

[2019-03-01 15:14:29] request.CRITICAL: Uncaught PHP Exception Doctrine\ORM\Mapping\MappingException: "Class "PackageName\BundleName\Entity\AbstractFaq" is not a valid entity or mapped super class." at /srv/oppasland/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php line 346 {"exception":"[object] (Doctrine\\ORM\\Mapping\\MappingException(code: 0): Class ....

Tell me please what I am missing?

Originally created by @BonBonSlick on GitHub (Mar 1, 2019). Originally assigned to: @Ocramius on GitHub. <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ----- ``` doctrine/annotations v1.6.0 Docblock Annotations Parser doctrine/cache v1.8.0 Caching library offering an object-oriented API for many cache backends doctrine/collections v1.5.0 Collections Abstraction library doctrine/common v2.10.0 PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as better reflection support, ... doctrine/data-fixtures v1.3.1 Data Fixtures for all Doctrine Object Managers doctrine/dbal v2.9.2 Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management. doctrine/doctrine-bundle 1.10.2 Symfony DoctrineBundle doctrine/doctrine-cache-bundle 1.3.5 Symfony Bundle for Doctrine Cache doctrine/doctrine-fixtures-bundle 3.1.0 Symfony DoctrineFixturesBundle doctrine/doctrine-migrations-bundle v2.0.0 Symfony DoctrineMigrationsBundle doctrine/event-manager v1.0.0 Doctrine Event Manager component doctrine/inflector v1.3.0 Common String Manipulations with regard to casing and singular/plural rules. doctrine/instantiator 1.1.0 A small, lightweight utility to instantiate objects in PHP without invoking their constructors doctrine/lexer v1.0.1 Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers. doctrine/migrations v2.0.0 PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and eas... doctrine/orm v2.6.3 Object-Relational-Mapper for PHP doctrine/persistence v1.1.0 The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share. ``` <!-- Before asking question here, please try asking on Gitter or Slack first. Find out more about Doctrine support channels here: https://www.doctrine-project.org/community/ Keep in mind that GitHub is primarily an issue tracker. --> ### Support Question <!-- Describe the issue you are facing here. --> We have own package bundle with abstract entity and default preset fields. ``` ... use Doctrine\ORM\Mapping as ORM; use Ramsey\Uuid\Uuid; /** * Class AbstractFaq. */ abstract class AbstractFaq implements FaqInterface, TimeStampableInterface, AuditLoggableInterface { use TimestampableTrait; use AuditLoggableTrait; /** * @var string * * @ORM\Column(type="text") */ protected $category; /** * AbstractFaq constructor. * * @param string $category * * @throws \Exception */ public function __construct( string $category ) { $this->id = Uuid::uuid4(); $this ->setCategory($category) ->setSequence($sequence); } /** * @return string */ public function __toString(): string { return $this->getQuestion(); } /** * {@inheritdoc} */ public function getCategory(): string { return $this->category; } ``` To make it work in project we create entity eg namespace App\Entity; use PackageName\BundleName\Entity\AbstractFaq; use Doctrine\ORM\Mapping as ORM; ``` /** * Class Faq. * * @ORM\Table(name="faq") * @ORM\Entity */ class Faq extends AbstractFaq { } ``` Exception during migration diff `[2019-03-01 15:14:29] request.CRITICAL: Uncaught PHP Exception Doctrine\ORM\Mapping\MappingException: "Class "PackageName\BundleName\Entity\AbstractFaq" is not a valid entity or mapped super class." at /srv/oppasland/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php line 346 {"exception":"[object] (Doctrine\\ORM\\Mapping\\MappingException(code: 0): Class ....` Tell me please what I am missing?
admin added the Question label 2026-01-22 15:28:33 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6191