Skip to content

Commit

Permalink
clean up formatting, comments and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gggeek committed Apr 15, 2021
1 parent 654abb1 commit e5be42a
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 45 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
KaliopEzOptionFieldTypeBundle
==================
=============================

Introduction
------------
Expand All @@ -9,7 +9,7 @@ This bundle provides eZOption field type for eZPlatform.
Documentation
-------------

Usage examples can be found [here](USAGE.md).
Usage examples can be found [here](USAGE.md).

License
-------
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/ez_field_templates.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
system:
default:
field_templates:
- {template: KaliopEzOptionFieldTypeBundle:fields:ezoption.html.twig}
- {template: KaliopEzOptionFieldTypeBundle:fields:ezoption.html.twig}
2 changes: 1 addition & 1 deletion Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ services:
ezpublish.fieldType.ezoption.converter:
class: Kaliop\EzOptionFieldTypeBundle\eZ\Publish\FieldType\Option\OptionConverter
tags:
- { name: ezpublish.storageEngine.legacy.converter, alias: ezoption }
- { name: ezpublish.storageEngine.legacy.converter, alias: ezoption }
2 changes: 1 addition & 1 deletion Resources/views/fields/ezoption.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
</select>
</div>
{% endspaceless %}
{% endblock %}
{% endblock %}
24 changes: 11 additions & 13 deletions USAGE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Usage
==================
=====

Save an ez_option value in eZ Publish 5
------------

```php
<?php

Expand All @@ -14,15 +14,15 @@ $userService = $repository->getUserService();
$contentService = $repository->getContentService();
$locationService = $repository->getLocationService();
$contentTypeService = $repository->getContentTypeService();

// Identifying to the repository with a login and a password
$user = $userService->loadUserByLogin($login);
$repository->setCurrentUser($user);

// The ContentCreateStruct
$contentType = $contentTypeService->loadContentTypeByIdentifier('survey');
$contentCreateStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB');

// Create ez option
$option = new Option\Value();
$option->setName('Question - saved in eZ 5');
Expand All @@ -31,7 +31,7 @@ $option->addOption(new Option\OptionElement('test-2'));
$option->addOption(new Option\OptionElement('test-3', null, 1000)); // id = 1000 -> 1000
$option->addOption(new Option\OptionElement('test-4', 10)); // id = -1 -> 1001
$option->addOption(new Option\OptionElement('test-5', 20, 5)); // id = 5 -> 5

/*
It is equivalent to this code :
$options = array(
Expand All @@ -42,9 +42,9 @@ $options = array(
new Option\OptionElement('test-5', 20, 5),
);
$option = new Option\Value('Question - saved in eZ 5', $options);

or

$options = array(
'test-1',
'test-2',
Expand All @@ -57,17 +57,15 @@ $options = array(
);
$option->addOptions($options);
*/

// Setting the fields values
$contentCreateStruct->setField('expiry', new \DateTime());
$contentCreateStruct->setField('question_answers', $option);

// Setting the Location
$locationCreateStruct = $locationService->newLocationCreateStruct(274);

// Creating and publishing
$draft = $contentService->createContent($contentCreateStruct, array( $locationCreateStruct ));
$content = $contentService->publishVersion($draft->versionInfo);

```

14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kaliop/ezoptionfieldtypebundle",
"description": "EzOption FieldType for eZ Publish Platform",
"description": "EzOption FieldType for eZPublishPlatform / eZPlatform",
"license": "GPL-2.0",
"keywords": ["ezpublish", "ezoption"],
"authors": [
Expand All @@ -16,10 +16,10 @@
"autoload": {
"psr-4": {"Kaliop\\EzOptionFieldTypeBundle\\": ""}
},
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/tanoconsulting"
}
]
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/tanoconsulting"
}
]
}
5 changes: 0 additions & 5 deletions eZ/Publish/FieldType/Option/OptionConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
use eZ\Publish\SPI\Persistence\Content\FieldValue;
use eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition;

/**
* Class LegacyConverter
*
* @package Kaliop\EzOptionFieldTypeBundle\eZ\Publish\FieldType\Option
*/
class OptionConverter implements Converter
{
public static function create()
Expand Down
5 changes: 0 additions & 5 deletions eZ/Publish/FieldType/Option/OptionElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

namespace Kaliop\EzOptionFieldTypeBundle\eZ\Publish\FieldType\Option;

/**
* Class OptionElement
*
* @package Kaliop\EzOptionFieldTypeBundle\eZ\Publish\FieldType\Option
*/
class OptionElement
{
/**
Expand Down
7 changes: 2 additions & 5 deletions eZ/Publish/FieldType/Option/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
use eZ\Publish\SPI\FieldType\Value as SPIValue;
use eZ\Publish\SPI\Persistence\Content\FieldValue as PersistenceValue;
use Kaliop\EzOptionFieldTypeBundle\eZ\Publish\FieldType\Option\Value as OptionValue;
/**
* Class Type
*
* @package Kaliop\EzOptionFieldTypeBundle\eZ\Publish\FieldType\Option
*/


class Type extends FieldType
{
/**
Expand Down
5 changes: 0 additions & 5 deletions eZ/Publish/FieldType/Option/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
use eZ\Publish\Core\FieldType\Value as BaseValue;
use Symfony\Component\Config\Definition\Exception\DuplicateKeyException;

/**
* Class Value for ezOption field type
*
* @package Kaliop\EzOptionFieldTypeBundle\eZ\Publish\FieldType\Option
*/
class Value extends BaseValue
{

Expand Down

0 comments on commit e5be42a

Please sign in to comment.