2017 © Pedro Peláez
 

ezplatform-bundle ez-matrix-bundle

EzMatrix FieldType for eZ Publish Platform

image

ezsystems/ez-matrix-bundle

EzMatrix FieldType for eZ Publish Platform

  • Friday, February 16, 2018
  • by bdunogier
  • Repository
  • 13 Watchers
  • 4 Stars
  • 19,805 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 10 Forks
  • 5 Open issues
  • 2 Versions
  • 5 % Grown

The README.md

EzMatrixFieldTypeBundle

Build Status Downloads Latest version License, (*1)

Bundle provides ezmatrix field type for eZ Publish Platform 5.x and higher, (*2)

⛔️ Status DEPRECATED: As of 2.5 there is now bundled a newer version avaiable from eZ with full support, migration, UI editing and more. ⛔️, (*3)

This bundle can and should be used on earlier versions, but will not recive support for use in 1.x or 2.x UI or full API support, so UI editing is limited to use via legacy bridge/bundle., (*4)

Install

From your eZ Publish Platform install root with composer installed:, (*5)

php -d memory_limit=-1 composer.phar require --prefer-dist ezsystems/ez-matrix-bundle:dev-master

Add the following in your app/AppKernel.php file:, (*6)

public function registerBundles()
{
    ...

    $bundles[] = new EzSystems\MatrixBundle\EzSystemsMatrixBundle();

    return $bundles;
}

How to update content programmatically

Here's an example on how to update the value of a matrix field for a content item. The field has two columns, and we are creating two rows of content:, (*7)

$repository = $this->getContainer()->get( 'ezpublish.api.repository' );
$contentService = $repository->getContentService();

// This example for setting a current user is valid for 5.x and early versions of 6.x installs
// This is deprecated from 6.6, and you should use PermissionResolver::setCurrentUserReference() instead
$repository->setCurrentUser( $repository->getUserService()->loadUser( 14 ) );

$contentId = 26926;
$newTitle = 'My updated title 2';

try
{
    // create a content draft from the current published version
    $contentInfo = $contentService->loadContentInfo( $contentId );
    $contentDraft = $contentService->createContentDraft( $contentInfo );

    // instantiate a content update struct and set the new fields
    $contentUpdateStruct = $contentService->newContentUpdateStruct();
    $contentUpdateStruct->initialLanguageCode = 'eng-US'; // set language for new version
    $matrixValue = new \EzSystems\MatrixBundle\FieldType\Matrix\Value(
        array(
            new \EzSystems\MatrixBundle\FieldType\Matrix\Row( array( 'col1' => 'row1col1', 'col2' => 'row1col2' ) ),
            new \EzSystems\MatrixBundle\FieldType\Matrix\Row( array( 'col1' => 'row2col2', 'col2' => 'row2col2' ) ),
        ),
        array(
            new \EzSystems\MatrixBundle\FieldType\Matrix\Column( array( 'name' => 'Column 1', 'id' => 'col1', 'num' => 0 ) ),
            new \EzSystems\MatrixBundle\FieldType\Matrix\Column( array( 'name' => 'Column 2', 'id' => 'col2', 'num' => 1 ) ),
        )
    );
    $contentUpdateStruct->setField( 'title', $newTitle );
    $contentUpdateStruct->setField( 'matrix', $matrixValue );
    // update and publish draft
    $contentDraft = $contentService->updateContent( $contentDraft->versionInfo, $contentUpdateStruct );
    $content = $contentService->publishVersion( $contentDraft->versionInfo );
}
catch ( \eZ\Publish\API\Repository\Exceptions\NotFoundException $e )
{
    $output->writeln( $e->getMessage() );
}
catch( \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException $e )
{
    $output->writeln( $e->getMessage() );
}
catch( \eZ\Publish\API\Repository\Exceptions\ContentValidationException $e )
{
    $output->writeln( $e->getMessage() );
}

See LICENSE file., (*8)

Contributors

https://github.com/ezcommunity/EzMatrixFieldTypeBundle/graphs/contributors, (*9)

The Versions

16/02 2018

dev-master

9999999-dev

EzMatrix FieldType for eZ Publish Platform

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

ezpublish ezmatrix

18/11 2014

0.1.0

0.1.0.0

EzMatrix FieldType for eZ Publish Platform

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

ezpublish ezmatrix