Serialized Fields

OroPlatform provides the ability to create custom entities or custom fields for extended entities. This package provides a possibility to avoid schema update when you create custom fields.

However, these fields have some restrictions. Their data is stores in the serialized_data column as a serialized array but field serialized_data is hidden from the UI on entity config page.

Not supported features:

  • grid filtering and sorting
  • segments and reports
  • charts
  • search
  • relations, enums and option set field types
  • data audit
  • usage of such fields in Doctrine query builder

The Serialized Fields bundle adds a new field called Storage Type within New field creation page where you need choose one of two storage types:

  • Table Column option will allow to create custom field as usual;

  • Serialized field option means that you can avoid schema update and start to use this field immediately. Keep in mind that in this case field types are limited to the following:

    • BigInt
    • Boolean
    • Date
    • DateTime
    • Decimal
    • Float
    • Integer
    • Money
    • Percent
    • SmallInt
    • String
    • Text
    • WYSIWYG
Basic properties available when creating a new field for an entity

To create a serialized field via migration, use SerializedFieldsExtension. For example:

namespace Acme\Bundle\AppBundle\Migrations\Schema\v1_1;

use Doctrine\DBAL\Schema\Schema;

use Oro\Bundle\EntityExtendBundle\EntityConfig\ExtendScope;
use Oro\Bundle\EntitySerializedFieldsBundle\Migration\Extension\SerializedFieldsExtension;
use Oro\Bundle\EntitySerializedFieldsBundle\Migration\Extension\SerializedFieldsExtensionAwareInterface;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;

class AddSerializedFieldMigration implements
    Migration,
    SerializedFieldsExtensionAwareInterface
{
    /** @var SerializedFieldsExtension */
    protected $serializedFieldsExtension;

    /**
     * {@inheritdoc}
     */
    public function setSerializedFieldsExtension(SerializedFieldsExtension $serializedFieldsExtension)
    {
        $this->serializedFieldsExtension = $serializedFieldsExtension;
    }

    /**
     * {@inheritdoc}
     */
    public function up(Schema $schema, QueryBag $queries)
    {
        $this->serializedFieldsExtension->addSerializedField(
            $schema->getTable('my_table'),
            'my_serialized_field',
            'string',
            [
                'extend'    => [
                    'owner' => ExtendScope::OWNER_CUSTOM,
                ]
            ]
        );
    }
}

Serialized files support the same set of config options as other configurable fields.