Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added FieldHandler for field type ezlandingpage #153

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions Core/FieldHandler/EzLandingPage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
namespace Kaliop\eZMigrationBundle\Core\FieldHandler;

use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Value as PageValue;
use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Type as PageType;
use Kaliop\eZMigrationBundle\API\FieldValueImporterInterface;
use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\XmlConverter;

class EzLandingPage extends AbstractFieldHandler implements FieldValueImporterInterface
{

/** @var PageType $pageType */
protected $pageType;

/** @var XmlConverter $xmlConverter */
protected $xmlConverter;

public function __construct(PageType $pageType, XmlConverter $xmlConverter)
{
$this->pageType = $pageType;
$this->xmlConverter = $xmlConverter;
}

/**
* Creates a value object to use as the field value when setting an ez page field type.
*
* @param XML string $fieldValue The definition of the field value, structured in the yml file
* @param array $context The context for execution of the current migrations. Contains f.e. the path to the migration
* @return PageValue
*/
public function hashToFieldValue($fieldValue, array $context = array())
{
$page = $this->xmlConverter->fromXml($fieldValue);
$value = new PageValue($page);
return $value;
}
}
10 changes: 10 additions & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ parameters:
ez_migration_bundle.complex_field.ezdate.class: Kaliop\eZMigrationBundle\Core\FieldHandler\EzDate
ez_migration_bundle.complex_field.ezdatetime.class: Kaliop\eZMigrationBundle\Core\FieldHandler\EzDateAndTime
ez_migration_bundle.complex_field.ezimage.class: Kaliop\eZMigrationBundle\Core\FieldHandler\EzImage
ez_migration_bundle.complex_field.ezlandingpage.class: Kaliop\eZMigrationBundle\Core\FieldHandler\EzLandingPage
ez_migration_bundle.complex_field.ezmedia.class: Kaliop\eZMigrationBundle\Core\FieldHandler\EzMedia
ez_migration_bundle.complex_field.ezpage.class: Kaliop\eZMigrationBundle\Core\FieldHandler\EzPage
ez_migration_bundle.complex_field.ezrelation.class: Kaliop\eZMigrationBundle\Core\FieldHandler\EzRelation
Expand Down Expand Up @@ -529,6 +530,15 @@ services:
tags:
- { name: ez_migration_bundle.complex_field, fieldtype: ezimage, priority: 0 }

ez_migration_bundle.complex_field.ezlandingpage:
parent: ez_migration_bundle.complex_field
class: '%ez_migration_bundle.complex_field.ezlandingpage.class%'
arguments:
- '@ezpublish.fieldtype.ezlandingpage'
- '@ezpublish.fieldtype.ezlandingpage.xml_converter'
tags:
- { name: ez_migration_bundle.complex_field, fieldtype: ezlandingpage, priority: 0 }

ez_migration_bundle.complex_field.ezmedia:
parent: ez_migration_bundle.complex_field
class: '%ez_migration_bundle.complex_field.ezmedia.class%'
Expand Down