Skip to content

Commit

Permalink
Rename to sulu/web-twig
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Apr 25, 2019
1 parent 78e8221 commit 7bd0caf
Show file tree
Hide file tree
Showing 23 changed files with 459 additions and 330 deletions.
7 changes: 4 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ version: 2
jobs:
build:
docker:
- image: circleci/php:5.6-node-browsers
- image: circleci/php:7.1-node-browsers

steps:
- checkout
- run: echo 'memory_limit = -1' | sudo tee -a /usr/local/etc/php/php.ini
- run: sudo composer self-update
- restore_cache:
keys:
Expand All @@ -18,5 +19,5 @@ jobs:
paths:
- vendor
- ~/.composer/cache
- run: php -d memory_limit=2G ./vendor/bin/phpunit
- run: php -n -d memory_limit=2G ./vendor/bin/php-cs-fixer fix --verbose --diff --diff-format=udiff --dry-run
- run: composer lint
- run: composer test
21 changes: 0 additions & 21 deletions .php_cs

This file was deleted.

41 changes: 41 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

$header = <<<'EOF'
This file is part of Sulu.
(c) Sulu GmbH
This source file is subject to the MIT license that is bundled
with this source code in the file LICENSE.
EOF;

return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'ordered_imports' => true,
'concat_space' => ['spacing' => 'one'],
'array_syntax' => ['syntax' => 'short'],
'phpdoc_align' => false,
'class_definition' => [
'multiLineExtendsEachSingleLine' => true,
],
'linebreak_after_opening_tag' => true,
'declare_strict_types' => true,
'mb_str_functions' => true,
'no_php4_constructor' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'php_unit_strict' => true,
'phpdoc_order' => true,
'strict_comparison' => true,
'strict_param' => true,
'header_comment' => ['header' => $header],
])
->setFinder(
PhpCsFixer\Finder::create()
->exclude('vendor')
->in(__DIR__)
);
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 MASSIVE ART WebServices GmbH
Copyright (c) 2019 Sulu GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
## Installation

```bash
composer require massive/web-twig-extensions ^1.0
composer require sulu/web-twig
```

## Extensions

### 1. Component

The [web component twig extension](docs/component.md) in connection with [web-js](https://github.com/massiveart/web-js)
The [web component twig extension](docs/component.md) in connection with [web-js](https://github.com/sulu/web-js)
gives you simple and efficient way to handle your javascript components over twig.

[More](docs/component.md)
Expand Down
35 changes: 28 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,52 @@
{
"name": "massive/web-twig-extensions",
"name": "sulu/web-twig",
"type": "library",
"description": "The web twig extension for web-js component management",
"license": "MIT",
"authors": [
{
"name": "Massive Web Twig contributors",
"homepage": "https://github.com/massiveart/web-twig/graphs/contributors"
"name": "Sulu Web Twig contributors",
"homepage": "https://github.com/sulu/web-twig/graphs/contributors"
}
],
"require": {
"php": "~5.5 || ~7.0",
"twig/twig": "^1.11 || ^2.0"
"php": "^7.1",
"twig/twig": "^1.34 || ^2.4"
},
"require-dev": {
"phpunit/phpunit": "^5.0 || ^6.0 || ^7.0",
"symfony/property-access": "^2.8 || ^3.0 || ^4.0",
"symfony/intl": "^2.8 || ^3.0 || ^4.0",
"friendsofphp/php-cs-fixer": "^2.11"
"friendsofphp/php-cs-fixer": "^2.11",
"phpstan/phpstan": "^0.11.5",
"phpstan/phpstan-phpunit": "^0.11.0",
"jangregor/phpstan-prophecy": "^0.4.0"
},
"suggest": {
"symfony/property-access": "The ImageTwigExtension requires the symfony/property-access service.",
"symfony/intl": "The IntlTwigExtension requires the symfony/intl service."
},
"autoload": {
"psr-4": {
"Massive\\Component\\Web\\": "src/"
"Sulu\\Component\\Web\\Twig\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Sulu\\Component\\Web\\Twig\\Tests\\": "tests/"
}
},
"scripts": {
"test": [
"@phpunit"
],
"lint": [
"@phpstan",
"@php-cs"
],
"phpunit": "@php vendor/bin/phpunit",
"phpstan": "@php vendor/bin/phpstan analyze -c ./phpstan.neon",
"php-cs": "@php vendor/bin/php-cs-fixer fix --verbose --diff --dry-run",
"php-cs-fix": "@php vendor/bin/php-cs-fixer fix"
}
}
37 changes: 12 additions & 25 deletions docs/component.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Web Component Twig Extension

The web component twig extension in connection with [web-js](https://github.com/massiveart/web-js)
The web component twig extension in connection with [web-js](https://github.com/sulu/web-js)
gives you a simple and efficient way to handle your javascript components over twig.

## Setup
Expand All @@ -9,37 +9,17 @@ gives you a simple and efficient way to handle your javascript components over t

The twig extension need to be registered as [symfony service](http://symfony.com/doc/current/service_container.html).

**xml**

```xml
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="app.web_components" class="Massive\Component\Web\ComponentTwigExtension">
<tag name="twig.extension" />
</service>
</services>
</container>
```

**yml**

```yml
services:
app.web_components:
class: Massive\Component\Web\ComponentTwigExtension
tags:
- { name: twig.extension }
Sulu\Component\Web\Twig\ComponentTwigExtension: ~
```
If autoconfigure is not active you need to tag it with [twig.extension](https://symfony.com/doc/current/service_container.html#the-autoconfigure-option).
## Usage
You can get the registered components and service call and call the
[web-js](https://github.com/massiveart/web-js) function which is recommended to be used with it.
[web-js](https://github.com/sulu/web-js) function which is recommended to be used with it.
```twig
{# Registering a component #}
Expand All @@ -58,6 +38,13 @@ You can get the registered components and service call and call the
{# Call a service function with arguments #}
{% do call_service('api', 'send', ['Hello']) %}

{# Output Html which is needed once by a specific component #}
{% if 'component' in get_component_list() %}
<script id="component-template" type="text/html">
<div>Template</div>
</script>
{% endif %}

{# Start components and run service functions #}
<script>
web.startComponents({{ get_components() }});
Expand Down
26 changes: 3 additions & 23 deletions docs/count.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,13 @@ The count twig extension gives you a simple and efficient way to have a global c

The twig extension need to be registered as [symfony service](http://symfony.com/doc/current/service_container.html).

**xml**

```xml
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="app.twig.web_count" class="Massive\Component\Web\CountTwigExtension">
<tag name="twig.extension" />
</service>
</services>
</container>
```

**yml**

```yml
services:
app.twig.web_count:
class: Massive\Component\Web\CountTwigExtension
tags:
- { name: twig.extension }
Sulu\Component\Web\Twig\CountTwigExtension: ~
```
If autoconfigure is not active you need to tag it with [twig.extension](https://symfony.com/doc/current/service_container.html#the-autoconfigure-option).
## Usage
### Counter
Expand Down
29 changes: 3 additions & 26 deletions docs/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,13 @@ The web image twig extension gives you a simple and efficient way to handle your

The twig extension need to be registered as [symfony service](http://symfony.com/doc/current/service_container.html).

**xml**

```xml
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="app.twig.web_image" class="Massive\Component\Web\ImageTwigExtension">
<argument>/images/placeholders</argument>
<tag name="twig.extension" />
</service>
</services>
</container>
```

**yml**

```yml
services:
app.web_image:
class: Massive\Component\Web\ImageTwigExtension
arguments:
- '/images/placeholders'
tags:
- { name: twig.extension }
Sulu\Component\Web\Twig\ImageTwigExtension: ~
```
If autoconfigure is not active you need to tag it with [twig.extension](https://symfony.com/doc/current/service_container.html#the-autoconfigure-option).
## Usage
#### Get an image
Expand Down
26 changes: 3 additions & 23 deletions docs/intl.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,13 @@ The intl twig extension gives you a simple and efficient way to get country, lan

The twig extension need to be registered as [symfony service](http://symfony.com/doc/current/service_container.html).

**xml**

```xml
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="app.twig.web_intl" class="Massive\Component\Web\IntlTwigExtension">
<tag name="twig.extension" />
</service>
</services>
</container>
```

**yml**

```yml
services:
app.twig.web_intl:
class: Massive\Component\Web\IntlTwigExtension
tags:
- { name: twig.extension }
Sulu\Component\Web\Twig\IntlTwigExtension: ~
```
If autoconfigure is not active you need to tag it with [twig.extension](https://symfony.com/doc/current/service_container.html#the-autoconfigure-option).
## Usage
### Get country
Expand Down
26 changes: 3 additions & 23 deletions docs/url.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,13 @@ The url twig extension gives you a simple and efficient way to get specific part

The twig extension need to be registered as [symfony service](http://symfony.com/doc/current/service_container.html).

**xml**

```xml
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="app.twig.web_url" class="Massive\Component\Web\UrlTwigExtension">
<tag name="twig.extension" />
</service>
</services>
</container>
```

**yml**

```yml
services:
app.twig.web_url:
class: Massive\Component\Web\UrlTwigExtension
tags:
- { name: twig.extension }
Sulu\Component\Web\Twig\UrlTwigExtension: ~
```
If autoconfigure is not active you need to tag it with [twig.extension](https://symfony.com/doc/current/service_container.html#the-autoconfigure-option).
## Usage
### Format url
Expand Down
12 changes: 12 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
includes:
- vendor/jangregor/phpstan-prophecy/src/extension.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon

parameters:
level: max
paths:
- src
- tests
excludes_analyse:
- %currentWorkingDirectory%/vendor/*
Loading

0 comments on commit 7bd0caf

Please sign in to comment.