-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 13b8012
Showing
11 changed files
with
217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
return PhpCsFixer\Config::create() | ||
->setRules([ | ||
'@Symfony' => true, | ||
'@Symfony:risky' => true, | ||
'concat_space' => ['spacing' => 'one'], | ||
'array_syntax' => ['syntax' => 'short'], | ||
'simplified_null_return' => false, | ||
'phpdoc_align' => false, | ||
'phpdoc_to_comment' => false, | ||
'cast_spaces' => false, | ||
'blank_line_after_opening_tag' => false, | ||
'single_blank_line_before_namespace' => false, | ||
'space_after_semicolon' => false, | ||
'yoda_style' => false, | ||
'no_break_comment' => false, | ||
]) | ||
->setRiskyAllowed(true) | ||
->setFinder( | ||
PhpCsFixer\Finder::create() | ||
->in(__DIR__ . '/src') | ||
->files()->name('*.php') | ||
) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2018 Mateusz Bieniek | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# ezplatform-form-builder-country-field | ||
## Description | ||
Bundle provides country selection field for the Form Builder in eZ Platform EE. | ||
|
||
## Installation | ||
### 1. Enable EzPublishLegacyBundle and EzSystemsEzPlatformXmlTextFieldTypeBundle | ||
Edit `app/AppKernel.php`, and add | ||
``` | ||
new MateuszBieniek\EzPlatformFormBuilderCountryBundle\EzPlatformFormBuilderCountryBundle(), | ||
``` | ||
at the end of the `$bundles` array. | ||
### 2. Install `mateuszbieniek/ezplatform-form-builder-country-field` | ||
``` | ||
composer require mateuszbieniek/ezplatform-form-builder-country-field | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "mateuszbieniek/ezplatform-form-builder-country-field", | ||
"license": "MIT", | ||
"type": "ezplatform-bundle", | ||
"description": "Bundle providing Country select field for the eZ Platform EE Form Builder", | ||
"repositories": [ | ||
{ | ||
"type": "composer", | ||
"url": "https://updates.ez.no/ttl" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"MateuszBieniek\\EzPlatformFormBuilderCountryBundle\\": "src/bundle/", | ||
"MateuszBieniek\\EzPlatformFormBuilderCountry\\": "src/lib/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"MateuszBieniek\\EzPlatformFormBuilderCountryBundle\\Tests\\": "src/bundle/Tests" | ||
} | ||
}, | ||
"require": { | ||
"php": ">=7.1", | ||
"ezsystems/ezpublish-kernel": "^7.3", | ||
"ezsystems/ezplatform-form-builder": "^1.0" | ||
}, | ||
"require-dev": { | ||
"friendsofphp/php-cs-fixer": "2.7.*", | ||
"phpunit/phpunit": "~7.0" | ||
}, | ||
"scripts": { | ||
"fix-cs": "@php ./vendor/bin/php-cs-fixer fix -v --show-progress=estimating" | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/bundle/DependencyInjection/EzPlatformFormBuilderCountryExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MateuszBieniek\EzPlatformFormBuilderCountryBundle\DependencyInjection; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; | ||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; | ||
use Symfony\Component\Yaml\Yaml; | ||
|
||
class EzPlatformFormBuilderCountryExtension extends Extension implements PrependExtensionInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function load(array $configs, ContainerBuilder $container): void | ||
{ | ||
$loader = new YamlFileLoader( | ||
$container, | ||
new FileLocator(__DIR__ . '/../Resources/config') | ||
); | ||
$loader->load('services.yml'); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function prepend(ContainerBuilder $container): void | ||
{ | ||
$config = Yaml::parseFile( | ||
__DIR__ . '/../Resources/config/config.yml' | ||
); | ||
|
||
foreach ($config as $extension => $settings) { | ||
$container->prependExtensionConfig($extension, $settings); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MateuszBieniek\EzPlatformFormBuilderCountryBundle; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
class EzPlatformFormBuilderCountryBundle extends Bundle | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function build(ContainerBuilder $container): void | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
twig: | ||
form_themes: | ||
- '@EzPlatformFormBuilderCountry/form/fields.html.twig' | ||
|
||
ez_platform_form_builder: | ||
fields: | ||
country: | ||
name: 'Country' | ||
category: 'Basic form fields' | ||
thumbnail: '/bundles/ezplatformadminui/img/ez-icons.svg#languages' | ||
validators: | ||
required: ~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
|
||
MateuszBieniek\EzPlatformFormBuilderCountry\FormBuilder\Field\Mapper\CountryMapper: | ||
arguments: | ||
$fieldIdentifier: 'country' | ||
$formType: 'MateuszBieniek\EzPlatformFormBuilderCountry\Form\Type\CountryFieldType' | ||
tags: | ||
- { name: ezplatform.form_builder.field_mapper } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% block mateuszbieniek_country_widget %} | ||
{{ form_widget(form) }} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace MateuszBieniek\EzPlatformFormBuilderCountry\Form\Type; | ||
|
||
use EzSystems\EzPlatformFormBuilder\Form\Type\Field\AbstractFieldType; | ||
use Symfony\Component\Form\Extension\Core\Type\CountryType; | ||
|
||
class CountryFieldType extends AbstractFieldType | ||
{ | ||
public function getName() | ||
{ | ||
return $this->getBlockPrefix(); | ||
} | ||
|
||
public function getBlockPrefix() | ||
{ | ||
return 'mateuszbieniek_country'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getParent(): string | ||
{ | ||
return CountryType::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MateuszBieniek\EzPlatformFormBuilderCountry\FormBuilder\Field\Mapper; | ||
|
||
use EzSystems\EzPlatformFormBuilder\FieldType\Field\Mapper\GenericFieldMapper; | ||
use EzSystems\EzPlatformFormBuilder\FieldType\Model\Field; | ||
|
||
class CountryMapper extends GenericFieldMapper | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function mapFormOptions(Field $field, array $constraints): array | ||
{ | ||
$options = parent::mapFormOptions($field, $constraints); | ||
$options['field'] = $field; | ||
$options['label'] = $field->getName(); | ||
|
||
return $options; | ||
} | ||
} |