Skip to content

Commit

Permalink
Merge pull request #48 from swagindustries/feature/disable-forms-by-d…
Browse files Browse the repository at this point in the history
…efault
  • Loading branch information
Nek- authored Nov 26, 2021
2 parents 5467423 + c7c2da7 commit 22ad2fd
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 10 deletions.
27 changes: 24 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,30 @@ on:
- cron: '0 0 * * *'

jobs:
static-analyse:
name: Code style

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0

- uses: actions/cache@v2
id: cache-composer
with:
path: ~/.composer/cache
key: composer-php-8.0-${{ github.sha }}
restore-keys: composer-php-8.0-

- name: Install dependencies
run: composer update --prefer-dist --no-progress --no-suggest

- name: Run PHP CS Fixer
run: make test.phpcs

unit-test:
name: Unit tests
strategy:
Expand Down Expand Up @@ -45,9 +69,6 @@ jobs:
- name: Install dependencies
run: composer update --prefer-dist --no-progress --no-suggest ${{ matrix.composer-flag }}

- name: Run PHP CS Fixer
run: make test.phpcs

- name: Run PHPUnit tests
run: make test.phpunit

Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed
- Removed hard dependency to the form component (it is still required for many features)

## [0.7.3] 2020-12-18

### Added
Expand Down
12 changes: 10 additions & 2 deletions src/DependencyInjection/MelodiiaExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\Form\Form;
use Twig\Environment;

class MelodiiaExtension extends Extension
Expand All @@ -30,9 +31,16 @@ public function load(array $configs, ContainerBuilder $container)
if (class_exists(AbstractManagerRegistry::class)) {
$loader->load('doctrine.yaml');
}
if ($container->hasAlias('melodiia.data_provider')) {
$loader->load('crud.yaml');

if (class_exists(Form::class)) {
$loader->load('form.yaml');

// The CRUD features requires forms as well as doctrine to be enabled
if ($container->hasAlias('melodiia.data_provider')) {
$loader->load('crud.yaml');
}
}

if (class_exists(Environment::class)) {
$loader->load('twig.yaml');
}
Expand Down
1 change: 1 addition & 0 deletions src/Form/Factory/ApiFormFactory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace SwagIndustries\Melodiia\Form\Factory;
Expand Down
2 changes: 2 additions & 0 deletions src/Form/Factory/ApiFormFactoryInterface.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

declare(strict_types=1);

namespace SwagIndustries\Melodiia\Form\Factory;

use SwagIndustries\Melodiia\Form\Type\ApiType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormFactoryInterface as FormFactoryInterfaceBase;
Expand Down
2 changes: 0 additions & 2 deletions src/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,3 @@ services:
arguments:
$builders: !tagged_iterator melodiia.context_builder

imports:
- 'form.yaml'
7 changes: 4 additions & 3 deletions tests/Behat/Form/Factory/ApiFormFactoryTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

declare(strict_types=1);

namespace SwagIndustries\Melodiia\Tests\Behat\Form\Factory;

use SwagIndustries\Melodiia\Form\Factory\ApiFormFactory;
use PHPUnit\Framework\TestCase;
use SwagIndustries\Melodiia\Form\Factory\ApiFormFactory;
use SwagIndustries\Melodiia\Form\Type\ApiType;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormRegistry;
use Symfony\Component\Form\FormRegistryInterface;
use Symfony\Component\Form\ResolvedFormTypeFactory;

class ApiFormFactoryTest extends TestCase
Expand All @@ -20,6 +20,7 @@ public function testThatCreateApiReturnAFormWithoutNameAndApiTypeIsDefault()
$this->assertInstanceOf(ApiType::class, $form->getConfig()->getType()->getInnerType());
$this->assertEquals('', $form->getName());
}

public function testThatCreateApiBuilderReturnAFormBuilderWithoutNameAndApiTypeIsDefault()
{
$formFactory = new ApiFormFactory(new FormRegistry([], new ResolvedFormTypeFactory()));
Expand Down

0 comments on commit 22ad2fd

Please sign in to comment.