Skip to content

Commit

Permalink
Refactor(web-twig): Rename bundle and move repository
Browse files Browse the repository at this point in the history
  • Loading branch information
janicekt authored and literat committed Jul 30, 2022
1 parent 7a61956 commit 5cbe22e
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 46 deletions.
18 changes: 11 additions & 7 deletions packages/web-twig/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
Twig components bundle
Spirit Web Twig Bundle
=================

this bundle extends the twig implementation of embed with an HTML syntax-like. The only rule compared to html is that tags start in capital letters.
This is Symfony bundle with twig implementation [Spirit Design System](https://github.com/lmc-eu/spirit-design-system) components and extends the twig implementation with an HTML syntax-like.

## Requirements
- PHP 7.4
- Symfony 4.2+ or Symfony 5.0+
- Twig 2+

## Changelog
See [CHANGELOG](./CHANGELOG.md)
Expand All @@ -14,7 +18,7 @@ See [CHANGELOG](./CHANGELOG.md)
Download using *composer*

"require": {
"lmc/twig-components-bundle" : "~1.0.0"
"lmc/lmc/spirit-web-twig-bundle" : "~1.0.0"
},
"repositories": [
{
Expand All @@ -25,14 +29,14 @@ Download using *composer*

### Step 2

Add `TwigComponentsBundle` into bundles (under `all` bundles).
Add `SpiritWebTwigBundle` into bundles (under `all` bundles). If you use Symfony flex, it will be configured automatically.

**bundles.php**

```php
return [
...,
Lmc\TwigComponentsBundle\TwigComponentsBundle::class => ['all' => true],
Lmc\SpiritWebTwigBundle\SpiritWebTwigBundle::class => ['all' => true],
];
```

Expand All @@ -42,13 +46,13 @@ Configure parameters for this bundle.

**config.yml**
```yaml
twig_components:
spirit_web_twig:
path: "%kernel.project_dir%/templates/components"
path_alias: 'ui-components'
```
## Usage
after this configuration it will be possible to use components in your symfony project syntax-like Html
After this configuration it will be possible to use components in your symfony project syntax-like Html. The only rule compared to html is that tags start in capital letters.
```html
<ComponentName attr="value">Some other content</ComponentName>
Expand Down
8 changes: 4 additions & 4 deletions packages/web-twig/composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lmc/twig-components-bundle",
"name": "lmc/spirit-web-twig-bundle",
"type": "symfony-bundle",
"description": "Symfony bundle, which extends the twig implementation with an JSX syntax-like approach from React",
"description": "This is Symfony bundle with twig implementation Spirit Design System components and extends the twig implementation with an HTML syntax-like.",
"license": "proprietary",
"repositories": [
],
Expand All @@ -12,12 +12,12 @@
],
"autoload": {
"psr-4": {
"Lmc\\TwigComponentsBundle\\": "src/"
"Lmc\\SpiritWebTwigBundle\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Lmc\\TwigComponentsBundle\\": "tests/"
"Lmc\\SpiritWebTwigBundle\\": "tests/"
}
},
"require": {
Expand Down
10 changes: 0 additions & 10 deletions packages/web-twig/sonar-project.properties

This file was deleted.

2 changes: 1 addition & 1 deletion packages/web-twig/src/Compiler/ComponentLexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Lmc\TwigComponentsBundle\Compiler;
namespace Lmc\SpiritWebTwigBundle\Compiler;

use Twig\Environment;
use Twig\Lexer;
Expand Down
2 changes: 1 addition & 1 deletion packages/web-twig/src/Compiler/ComponentTagCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Lmc\TwigComponentsBundle\Compiler;
namespace Lmc\SpiritWebTwigBundle\Compiler;

/**
* Transforms <Tags /> to twig embed tags
Expand Down
4 changes: 2 additions & 2 deletions packages/web-twig/src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Lmc\TwigComponentsBundle\DependencyInjection;
namespace Lmc\SpiritWebTwigBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
Expand All @@ -11,7 +11,7 @@ class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('twig_components');
$treeBuilder = new TreeBuilder('spirit_web_twig');
$rootNode = $treeBuilder->getRootNode();

$rootNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Lmc\TwigComponentsBundle\DependencyInjection;
namespace Lmc\SpiritWebTwigBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -16,9 +16,9 @@
*/
class TwigComponentsExtension extends Extension
{
public const PARAMETER_PATH = 'twig_components.path';
public const PARAMETER_PATH = 'spirit_web_twig.path';

public const PARAMETER_PATH_ALIAS = 'twig_components.path_alias';
public const PARAMETER_PATH_ALIAS = 'spirit_web_twig.path_alias';

public function load(array $configs, ContainerBuilder $container): void
{
Expand Down
4 changes: 2 additions & 2 deletions packages/web-twig/src/Factory/TwigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Lmc\TwigComponentsBundle\Factory;
namespace Lmc\SpiritWebTwigBundle\Factory;

use Lmc\TwigComponentsBundle\Compiler\ComponentLexer;
use Lmc\SpiritWebTwigBundle\Compiler\ComponentLexer;
use Twig\Environment;
use Twig\Loader\FilesystemLoader;

Expand Down
8 changes: 4 additions & 4 deletions packages/web-twig/src/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ services:
autowire: true
autoconfigure: true

Lmc\TwigComponentsBundle\Factory\TwigFactory:
Lmc\SpiritWebTwigBundle\Factory\TwigFactory:
arguments:
- '@twig'
- '@twig.loader'
- '%twig_components.path%'
- '%twig_components.path_alias%'
- '%spirit_web_twig.path%'
- '%spirit_web_twig.path_alias%'

Twig\Environment:
factory: ['@Lmc\TwigComponentsBundle\Factory\TwigFactory', 'create']
factory: ['@Lmc\SpiritWebTwigBundle\Factory\TwigFactory', 'create']
11 changes: 11 additions & 0 deletions packages/web-twig/src/SpiritWebTwigBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

namespace Lmc\SpiritWebTwigBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class SpiritWebTwigBundle extends Bundle
{
}
4 changes: 2 additions & 2 deletions packages/web-twig/src/TwigComponentsBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

namespace Lmc\TwigComponentsBundle;
namespace Lmc\SpiritWebTwigBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class TwigComponentsBundle extends Bundle
class SpiritWebTwigBundle extends Bundle
{
}
6 changes: 3 additions & 3 deletions packages/web-twig/tests/ComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

namespace Lmc\TwigComponentsBundle;
namespace Lmc\SpiritWebTwigBundle;

use Lmc\TwigComponentsBundle\Compiler\ComponentLexer;
use Lmc\TwigComponentsBundle\Factory\TwigFactory;
use Lmc\SpiritWebTwigBundle\Compiler\ComponentLexer;
use Lmc\SpiritWebTwigBundle\Factory\TwigFactory;
use Mockery;
use PHPUnit\Framework\TestCase;
use Twig\Environment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Lmc\TwigComponentsBundle\DependencyInjection;
namespace Lmc\SpiritWebTwigBundle\DependencyInjection;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper;
Expand All @@ -13,7 +13,7 @@ public function testConfigurationDefinition(): void
{
$dumper = new YamlReferenceDumper();
$reference = <<<CONFIG
twig_components:
spirit_web_twig:
path: '%kernel.project_dir%/templates/components'
path_alias: ui-components\n
CONFIG;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Lmc\TwigComponentsBundle\DependencyInjection;
namespace Lmc\SpiritWebTwigBundle\DependencyInjection;

use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -32,7 +32,7 @@ private function loadExtension(array $configs): void

public function testShouldRegisterParameters(): void
{
$this->assertTrue($this->containerBuilder->hasParameter('twig_components.path'));
$this->assertTrue($this->containerBuilder->hasParameter('twig_components.path_alias'));
$this->assertTrue($this->containerBuilder->hasParameter('spirit_web_twig.path'));
$this->assertTrue($this->containerBuilder->hasParameter('spirit_web_twig.path_alias'));
}
}
4 changes: 2 additions & 2 deletions packages/web-twig/tests/Factory/TwigFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Lmc\TwigComponentsBundle\Factory;
namespace Lmc\SpiritWebTwigBundle\Factory;

use Lmc\TwigComponentsBundle\Compiler\ComponentLexer;
use Lmc\SpiritWebTwigBundle\Compiler\ComponentLexer;
use Mockery;
use PHPUnit\Framework\TestCase;
use Twig\Environment;
Expand Down

0 comments on commit 5cbe22e

Please sign in to comment.