ssossossosso

Forums

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

This topic contains 3 replies, has 2 voices, and was last updated by  Yurii Muratov 1 year, 9 months ago.

  • Creator
    Topic
  • #13349

    Neal Vanmeert
    Participant

    Hi, I created a custom bundle with a custom entity.

    In my migrations I added AttachmentExtensionAwareInterface

    /**
    * {@inheritdoc}
    */
    public function up(Schema $schema, QueryBag $queries)
    {
    $table = $schema->createTable('emuse_businesscard');
    $table->addColumn('id', 'integer', ['autoincrement' => true]);
    $table->addColumn('owner_id', 'integer', ['notnull' => false]);
    $table->addColumn('createdAt', 'datetime', []);
    $table->addColumn('updatedAt', 'datetime', ['notnull' => false]);
    $table->setPrimaryKey(['id']);
    $table->addIndex(['owner_id'], 'IDX_2F32390A7E3C61F9', []);
    self::addUploadToBusinessCard($schema, $this->attachmentExtension);
    }

    /**
    * @param Schema $schema
    * @param AttachmentExtension $attachmentExtension
    */
    public static function addUploadToBusinessCard(Schema $schema, AttachmentExtension $attachmentExtension)
    {
    $attachmentExtension->addImageRelation(
    $schema,
    'emuse_businesscard',
    'businesscard_upload',
    [],
    2,
    1024,
    768
    );
    }

    But when I run my migrations I get an error:

    php app/console oro:migration:load --dry-run --show-queries

    An extend field "businesscard_upload" cannot be added to non extend entity "eMuse\Bundle\BusinessCardBundle\Entity\BusinessCardEntity".

    How can I make my entity extendable, or what is the best way to add an attachement ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #13354

    Yurii Muratov
    Oro Core

    Hi, @neal_vanmeert.

    To make your entity extenable, your entity should extends from empty class eMuse\Bundle\BusinessCardBundle\Model\ExtendBusinessCardEntity.
    And another thing, your entity should be configurable (should have @Config annotation).

    For example, please look how it was done for Account entity https://github.com/orocrm/crm/blob/master/src/OroCRM/Bundle/AccountBundle/Entity/Account.php.
    Here, at line 28 we have Config annotation and at line 60 we have extends from empty OroCRM\Bundle\AccountBundle\Model\ExtendAccount class.

    #13358

    Neal Vanmeert
    Participant

    Hi, This indeed helped, I don’t really understand how an extend of an empty class makes this work. Is there info to be found ?

    We are interested in OroCRM and creating modules for it, but we are lacking information to really create quality code.

    #13377

    Yurii Muratov
    Oro Core

    Hi, @neal_vanmeert.
    We have some documentation about extend entities here http://www.orocrm.com/documentation/index/current/book/entities

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

You must be logged in to reply to this topic.