Reputation: 11
So I should add Image attribute to oro_brand, so I followed https://doc.oroinc.com/bundles/platform/AttachmentBundle/attachment-bundle-config/#use-migration-extension-example.
When I use bin/console oro:migration:load --force -vvv
I get :
Process migrations...
> Oro\Bundle\EntityExtendBundle\Migration\LoadEntityConfigStateMigration
> Test\Bundle\BrandBundle\Migrations\Schema\TestBrandBundleInstaller
In AddLogoToBrand.php line 42:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Call to a member function addImageRelation() on null
$this->attachmentExtension
seems null. But I don't know why, It's look like the documentation and the vendor usage I found.
Here my code
//src/Test/Bundle/BrandBundle/Migrations/Schema/v1_0/AddLogoToBrand.php
use Doctrine\DBAL\Schema\Schema;
use Oro\Bundle\AttachmentBundle\Migration\Extension\AttachmentExtensionAwareInterface;
use Oro\Bundle\AttachmentBundle\Migration\Extension\AttachmentExtensionAwareTrait;
use Oro\Bundle\EntityExtendBundle\EntityConfig\ExtendScope;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\OrderedMigrationInterface;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;
class AddLogoToBrand implements Migration, OrderedMigrationInterface, AttachmentExtensionAwareInterface
{
use AttachmentExtensionAwareTrait;
public const LOGO_SIZE = 10;
public const BRAND_TABLE = 'oro_brand';
public const FIELD_NAME = 'logo';
/**
* {@inheritdoc}
*/
public function getOrder(): int
{
return 10;
}
/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries): void
{
$this->addLogoBrandAssociation($schema);
}
/**
* @param Schema $schema
*/
public function addLogoBrandAssociation(Schema $schema)
{
$this->attachmentExtension->addImageRelation(
$schema,
self::BRAND_TABLE,
self::FIELD_NAME,
[
'extend' => ['owner' => ExtendScope::OWNER_CUSTOM]
],
);
}
SOLVED :
I removed my TestBrandBundleInstaller
and it is working now.
Upvotes: 1
Views: 56