I'm currently trying to add file relation to an entity of my OroPlatform project. The goal is to give the opportunity to the user to upload files on the create/update view of a specific entity.
I have read in the OroPlatform documentation that I have to create a new migration : https://doc.oroinc.com/master/backend/bundles/platform/AttachmentBundle/attachment-bundle-config/#attachment-bundle-file-types
Here is the migration I have created :
<?php
namespace Baltimore\Bundle\AppBundle\Migrations\Schema\v1_1_1;
use Doctrine\DBAL\Schema\Schema;
use Oro\Bundle\AttachmentBundle\Migration\Extension\AttachmentExtension;
use Oro\Bundle\AttachmentBundle\Migration\Extension\AttachmentExtensionAwareInterface;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;
class AddAttachmentToBusinessUnit implements Migration, AttachmentExtensionAwareInterface
{
/** @var AttachmentExtension */
protected $attachmentExtension;
/**
* {@inheritdoc}
*/
public function setAttachmentExtension(AttachmentExtension $attachmentExtension)
{
$this->attachmentExtension = $attachmentExtension;
}
/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
$this->attachmentExtension->addFileRelation(
$schema,
'oro_business_unit',
'document',
[],
15
);
}
}
And I have added this line to the update.html.twig
of my entity: form_row(form.document)
When I try to access the update page, I have the following error :
"Neither the property "document" nor one of the methods "document()", "getdocument()"/"isdocument()"/"hasdocument()" or "__call()" exist and have public access in class "Symfony\Component\Form\FormView"."
I have warmup the cache in order to generate the accessors for my class and the method getDocument()
exist in the generated file EX_OroOrganizationBundle_BusinessUnit.php
Also, it seems that the property has been successfully added to my entity :
Finally my needs has changed, but I think I have the answer to solve this problem.
Here is what I will do:
/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
$this->attachmentExtension->addFileRelation(
$schema,
'oro_business_unit',
'document',
[
'extend' => [
'owner' => ExtendScope::OWNER_CUSTOM,
'is_extend' => true
],
'entity' => ['label'=>'oro.organization.businessunit.entity_label'],
],
15
);
}