ssossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

This topic contains 8 replies, has 2 voices, and was last updated by adriwan_kenoby adriwan_kenoby 1 year, 5 months ago.

  • Creator
    Topic
  • #17607
    adriwan_kenoby
    adriwan_kenoby
    Participant

    Hi,
    I use a migration file to extend Account of the OroCRMAccountBundle.

    When i run it the first time i have this errors:

    [LogicException]
    A new model can be created for custom entity only. Class: Sinabs\MonitoringBundle\Entity\WebSite.

    /…

    [RuntimeException]
    Failed migrations: Oro\Bundle\EntityExtendBundle\Migration\UpdateExtendConfigMigration.

    But the database have changed accordingly.

    Then when i run doctrine:schema:update it erase the changes done by the migration script.

    Here my code

    :

    It seems like i have forgot some steps before define migration script correctly.

    Sorry for my english… I am french

Viewing 8 replies - 1 through 8 (of 8 total)
  • Author
    Replies
  • #17645

    Vova Soroka
    Oro Core

    Hi @adriwan_kenoby,

    To get it work you need to make your WebSite entity as configurable one, or even extendable one if you want to allow adding new fields to it by an administrator or by another bundle.
    Some details about configurable and extendable entities you can find in The Oro Book. Look at Configure Entities and Extending Entities sections.

    #17646
    adriwan_kenoby
    adriwan_kenoby
    Participant

    Hi @Vova Soroka,

    Thanks for your reply.

    I have add config annotation and create extend entity.

    Now all works fine after a doctrine:schema:update command.

    #17647
    adriwan_kenoby
    adriwan_kenoby
    Participant

    I have found the solution yesterday.

    Am I right ?

    – The extend entity allow to use migration for the entity

    – the config annotation display the entity in the entiy manager and allow user to manage it

    – create extension for config dumper, the entity generator and the migrations allow to manage association throught th UI.

    #17648
    adriwan_kenoby
    adriwan_kenoby
    Participant

    I have also add the annotation

    @ORM\ManyToOne(targetEntity=”OroCRM\Bundle\AccountBundle\Entity\Account”, inversedBy=”webSites”)

    to the $account attribute of my WebSite class to make the relation bidirectionnal

    but i am not sure that is necessary.

    #17650

    Vova Soroka
    Oro Core

    Am I right ?
    – The extend entity allow to use migration for the entity
    – the config annotation display the entity in the entiy manager and allow user to manage it
    – create extension for config dumper, the entity generator and the migrations allow to manage association throught th UI.

    – The extended entity can be changed by someone, not only by author. For example an administrator can add new fields to this entity throught the UI. Or any developer can do the same using the migrations.
    – Yes, if an entity has the config annotation it will be shown on the entity management and an administrator can change some metadata of this entity. But only author of such entity can add new fields.
    – Usually you do not need to create the config dumper and entity generator extensions. They are used if a new functionality is added, for example in case if you need to implement some not standard relationship between entities.

    I have also add the annotation
    @ORM\ManyToOne(targetEntity=”OroCRM\Bundle\AccountBundle\Entity\Account”, inversedBy=”webSites”)
    to the $account attribute of my WebSite class to make the relation bidirectionnal
    but i am not sure that is necessary.

    If you create the association using Oro\Bundle\EntityExtendBundle\Migration\Extension\ExtendExtension::addOneToManyRelation, you do not need to add the $account property at all, it will be generated automatically.
    But if you need regular unidirectional relation to the Account entity, you can use standard Doctrine way. In this case the WebSite entity may be or may not be configurable.

    #17660
    adriwan_kenoby
    adriwan_kenoby
    Participant

    Thanks a lot @Vova Soroka

    #17661
    adriwan_kenoby
    adriwan_kenoby
    Participant

    But if i haven’t the $account property in my website class then i haven’t getter and setter…

    And the account_id doesn’t appear on the website table, it s look like their is no relation.

    Moreover i always have error the first time i run oro:migration:load

    [RuntimeException]
    Unknown auxiliary section: _website.

    [RuntimeException]
    Failed migrations: Oro\Bundle\EntityExtendBundle\Migration\UpdateExtendConfigMigration.

    The second time their is no error

    #17662
    adriwan_kenoby
    adriwan_kenoby
    Participant

    I have changed the table name of WebSite in _website.

    Remove $account from WebSite.

    Remove the config dumper, entity generator, migration Extensions.

    I confirm that i want a bidirectionnal relation between an account an my WebSite entity.

Viewing 8 replies - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.