Skip to content

Commit

Permalink
Fix the definition of ezimage, ezbinaryfile complex fields to be comp…
Browse files Browse the repository at this point in the history
…atible w. ezplatform
  • Loading branch information
gggeek committed Feb 5, 2017
1 parent 510a237 commit 8afc7f4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
11 changes: 7 additions & 4 deletions Core/ComplexField/EzBinaryFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@

use eZ\Publish\Core\FieldType\BinaryFile\Value as BinaryFileValue;
use Kaliop\eZMigrationBundle\API\FieldValueConverterInterface;
use eZ\Publish\Core\IO\UrlDecorator;

class EzBinaryFile extends AbstractComplexField implements FieldValueConverterInterface
{
protected $legacyRootDir;
protected $ioRootDir;
protected $ioDecorator;

public function __construct($legacyRootDir)
public function __construct(UrlDecorator $ioDecorator, $ioRootDir)
{
$this->legacyRootDir = $legacyRootDir;
$this->ioRootDir = $ioRootDir;
$this->ioDecorator = $ioDecorator;
}

/**
Expand Down Expand Up @@ -66,7 +69,7 @@ public function hashToFieldValue($fieldValue, array $context = array())
public function fieldValueToHash($fieldValue, array $context = array())
{
return array(
'path' => realpath($this->legacyRootDir) . $fieldValue->uri,
'path' => realpath($this->ioRootDir) . '/' . $this->ioDecorator->undecorate($fieldValue->uri),
'filename'=> $fieldValue->fileName,
'mimeType' => $fieldValue->mimeType
);
Expand Down
11 changes: 7 additions & 4 deletions Core/ComplexField/EzImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@

use eZ\Publish\Core\FieldType\Image\Value as ImageValue;
use Kaliop\eZMigrationBundle\API\FieldValueConverterInterface;
use eZ\Publish\Core\IO\UrlDecorator;

class EzImage extends AbstractComplexField implements FieldValueConverterInterface
{
protected $legacyRootDir;
protected $ioRootDir;
protected $ioDecorator;

public function __construct($legacyRootDir)
public function __construct(UrlDecorator $ioDecorator, $ioRootDir)
{
$this->legacyRootDir = $legacyRootDir;
$this->ioRootDir = $ioRootDir;
$this->ioDecorator = $ioDecorator;
}

/**
Expand Down Expand Up @@ -68,7 +71,7 @@ public function hashToFieldValue($fieldValue, array $context = array())
public function fieldValueToHash($fieldValue, array $context = array())
{
return array(
'path' => realpath($this->legacyRootDir) . $fieldValue->uri,
'path' => realpath($this->ioRootDir) . '/' . $this->ioDecorator->undecorate($fieldValue->uri),
'filename'=> $fieldValue->fileName,
'alternativeText' => $fieldValue->alternativeText
);
Expand Down
6 changes: 4 additions & 2 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ services:
parent: ez_migration_bundle.complex_field
class: '%ez_migration_bundle.complex_field.ezbinaryfile.class%'
arguments:
- "%ezpublish_legacy.root_dir%"
- "@ezpublish.core.io.prefix_url_decorator"
- "$io.root_dir$"
tags:
- { name: ez_migration_bundle.complex_field, fieldtype: ezbinaryfile, priority: 0 }

Expand All @@ -375,7 +376,8 @@ services:
parent: ez_migration_bundle.complex_field
class: '%ez_migration_bundle.complex_field.ezimage.class%'
arguments:
- "%ezpublish_legacy.root_dir%"
- "@ezpublish.core.io.prefix_url_decorator"
- "$io.root_dir$"
tags:
- { name: ez_migration_bundle.complex_field, fieldtype: ezimage, priority: 0 }

Expand Down
24 changes: 20 additions & 4 deletions WHATSNEW.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
Version 3.2.0
=============

* Extend the GenerateCommand to generate migrations for existing Contents and Content Types besides Roles;
it is also possible to generate both _create_, _update_ and _delete_ migrations, and to have a single migration
generated for many items

* Allow setting a remote_id when creating/updating User Group(s)

* Allow matching on "content_remote_id" for User Group update/delete
Expand Down Expand Up @@ -45,6 +41,26 @@ Version 3.2.0

NB: it is not yet possible to match Content, Location or Tag using the `not` condition

* Extend the `generate` Command to generate migrations for existing Contents and ContentTypes besides Roles;
it is also possible to generate both _create_, _update_ and _delete_ migrations, and to have a single migration
generated for many items.

*NB* this feature is to be considered _experimental_, as there are some quirks in the generated migration files.
In other words: not all migration files generated with the Generate command will work as is; some manual editing
might be required before they are accepted as valid for execution.

Known problems include, but are not limited to:
- the field-settings generated for some field types when creating a ContentType migration might be invalid. Fe. in
some eZPublish versions a field-setting `defaultLayout` for an ezpage field with a value of empty string will
be generated but not be executable
- when creating a ContentType migration, having a field of type ezuser set to 'searchable' will also cause the
generated migration not to be executable
- the export + reimport of content fields of type ezuser seems to be problematic
- the export + reimport of content fields of type image and binaryfile has not been tested on eZPlatform

Some of these problems originate within the eZPublish kernel, and are hard to work around in the bundle.
For more details see: https://jira.ez.no/browse/EZP-26916


Version 3.1.0
=============
Expand Down

0 comments on commit 8afc7f4

Please sign in to comment.