Skip to content

Commit 8347a13

Browse files
authored
Merge pull request #1 from MyOnlineStore/symfony4
2 parents f99ad33 + 62ae7f5 commit 8347a13

File tree

20 files changed

+169
-135
lines changed

20 files changed

+169
-135
lines changed

.gitignore

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
.idea
21
composer.lock
3-
Tests/cache
4-
Tests/log
2+
clover.xml
53

4+
/.idea/
5+
/var/
6+
/vendor/
7+
/Tests/cache
8+
/Tests/log

.travis.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
11
language: php
22

33
php:
4-
- 5.6
5-
- 7.0
6-
- 7.1
4+
- 7.1.3
5+
- 7.2.0
76

87
sudo: false
98

109
cache:
11-
directories:
12-
- vendor
13-
- $HOME/.composer/cache
10+
directories:
11+
- vendor
12+
- $HOME/.composer/cache
1413

1514
matrix:
1615
fast_finish: true
1716

1817
env:
19-
- SYMFONY_VERSION="3.0.*" DECODA_VERSION="6.0.*"
20-
- SYMFONY_VERSION="3.0.*" DECODA_VERSION="6.*"
21-
- SYMFONY_VERSION="3.1.*" DECODA_VERSION="6.*"
22-
- SYMFONY_VERSION="3.2.*" DECODA_VERSION="6.*"
2318
- SYMFONY_VERSION="3.3.*" DECODA_VERSION="6.*"
2419
- SYMFONY_VERSION="3.4.*" DECODA_VERSION="6.*"
2520
- SYMFONY_VERSION="4.0.*" DECODA_VERSION="6.*"

Command/DumpEmoticonsCommand.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ protected function configure()
2121
{
2222
$this
2323
->setName('bbcode:dump')
24-
->setDescription('dump emoticons to public folder')
25-
->addOption('emoticons-folder', null, InputOption::VALUE_OPTIONAL, null, null)
24+
->setDescription('Dumps the emoticons to their configured folder')
25+
->addOption('emoticons-folder', null, InputOption::VALUE_OPTIONAL)
2626
;
2727
}
2828

2929
/**
3030
* Copies one folder to another.
3131
*
32-
* @param $src
33-
* @param $dst
32+
* @param string $src
33+
* @param string $dst
3434
*/
35-
private function recurseCopy($src, $dst)
35+
private function recurseCopy(string $src, string $dst)
3636
{
3737
$dir = opendir($src);
3838
@mkdir($dst);
@@ -49,15 +49,15 @@ private function recurseCopy($src, $dst)
4949
}
5050

5151
/**
52-
* @param \Symfony\Component\Console\Input\InputInterface $input
53-
* @param \Symfony\Component\Console\Output\OutputInterface $output
52+
* @param InputInterface $input
53+
* @param OutputInterface $output
5454
*
55-
* @return int|null|void
55+
* @return int
5656
*/
5757
protected function execute(InputInterface $input, OutputInterface $output)
5858
{
5959
$webFolder = sprintf('%s%s',
60-
$this->getContainer()->getParameter('assetic.write_to'),
60+
$this->getContainer()->getParameter('fm_bbcode.public_path'),
6161
$this->getContainer()->getParameter('fm_bbcode.emoticon.path')
6262
);
6363
@mkdir($webFolder);
@@ -68,11 +68,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
6868
}
6969

7070
if (!file_exists($emoticonsFolder) && !is_dir($emoticonsFolder)) {
71-
return $output->writeln('<error>Emoticons folder does not exist</error>');
71+
$output->writeln('<error>Emoticons folder does not exist</error>');
72+
return 2; // ENOENT - No such file or directory
7273
}
7374

7475
$this->recurseCopy($emoticonsFolder, $webFolder);
7576

7677
$output->writeln('<comment>Emoticons dumped succesfully</comment>');
78+
79+
return 0;
7780
}
7881
}

DependencyInjection/Compiler/RegisterFiltersPass.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Symfony\Component\DependencyInjection\Reference;
77
use Symfony\Component\DependencyInjection\ContainerBuilder;
88
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9+
use Decoda\Filter;
910

1011
class RegisterFiltersPass implements CompilerPassInterface
1112
{
@@ -37,7 +38,7 @@ public function process(ContainerBuilder $container)
3738
$class = $container->getDefinition($id)->getClass();
3839

3940
$refClass = new \ReflectionClass($class);
40-
$interface = 'Decoda\Filter';
41+
$interface = Filter::class;
4142
if (!$refClass->implementsInterface($interface)) {
4243
throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface));
4344
}

DependencyInjection/Configuration.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public function getConfigTreeBuilder()
9797
->end()
9898
->end()
9999
->end()
100+
->scalarNode('public_path')->defaultValue('%kernel.project_dir%/public')->end()
100101
->end()
101102
->end();
102103

@@ -132,7 +133,9 @@ private function addEmoticonSection(ArrayNodeDefinition $rootNode)
132133
})
133134
->end()
134135
->end()
135-
->scalarNode('folder')->defaultValue('%kernel.root_dir%/../vendor/mjohnson/decoda/emoticons')->end()
136+
->scalarNode('folder')
137+
->defaultValue('%kernel.project_dir%/vendor/mjohnson/decoda/emoticons')
138+
->end()
136139
->scalarNode('extension')->defaultValue('png')->end()
137140
->end()
138141
->end()

DependencyInjection/FMBbcodeExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
class FMBbcodeExtension extends Extension
1818
{
1919
/**
20-
* @see Symfony\Component\DependencyInjection\Extension.ExtensionInterface::load()
20+
* @see \Symfony\Component\DependencyInjection\Extension\ExtensionInterface::load()
2121
*
22-
* @param array $configs
23-
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
22+
* @param array $configs
23+
* @param ContainerBuilder $container
2424
*/
2525
public function load(array $configs, ContainerBuilder $container)
2626
{

README.md

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,33 @@ Using Composer, just add the following configuration to your `composer.json`:
4040

4141
Or you can use composer to install this bundle:
4242

43-
For symfony <3.0, use latest ~6 version
43+
For Symfony <3.0, use latest ~6 version
4444

4545
```sh
4646
composer require helios-ag/fm-bbcode-bundle:~6
4747
```
4848

49-
for Symfony 3
49+
For Symfony 3.0, use latest ~7 version
5050

5151
```sh
5252
composer require helios-ag/fm-bbcode-bundle
5353
```
54+
5455
or
5556

5657
```sh
5758
composer require helios-ag/fm-bbcode-bundle:~7
5859
```
5960

61+
For Symfony 4.0 you can use the ~8 version
62+
63+
```sh
64+
composer require helios-ag/fm-bbcode-bundle:~8
65+
```
66+
6067
### Step 2: Enable the bundle
6168

62-
Finally, enable the bundle in the kernel:
69+
Finally, for Symfony2 and Symfony3, enable the bundle in the AppKernel:
6370

6471
``` php
6572
<?php
@@ -73,15 +80,32 @@ public function registerBundles()
7380
);
7481
}
7582
```
83+
84+
For Symfony4, you'll need to enable the bundle in your `bundles.php`-file:
85+
``` php
86+
// config/bundles.php
87+
88+
return [
89+
// ...
90+
FM\BbcodeBundle\FMBbcodeBundle::class => ['all' => true],
91+
];
92+
```
93+
7694
### Step 3: Dump emoticons (optional)
7795

7896
To enable emoticons via emoticon hook, use the following command to copy emoticons images to
7997
public folder (web/emoticons)
8098

99+
For Symfony2:
81100
``` bash
82101
./app/console bbcode:dump
83102
```
84103

104+
For Symfony3 and Symfony4:
105+
``` bash
106+
./bin/console bbcode:dump
107+
```
108+
85109
## Basic configuration
86110

87111
### Make the Twig extensions available by updating your configuration:
@@ -259,12 +283,27 @@ emoticons:
259283
- ":my_emoticon:"
260284
```
261285

286+
### How to customize the emoticons assets
287+
288+
To customize emoticons assets folders, use `path` and `folder` node configuration:
289+
290+
```yaml
291+
# app/config.yml
292+
293+
fm_bbcode:
294+
public_path: # Default: %kernel.project_dir%/public
295+
emoticon:
296+
path: # Default: /emoticons
297+
folder: # Default: %kernel.project_dir%/vendor/mjohnson/decoda/emoticons%
298+
```
299+
300+
Using the default configuration it would dump the emoticons in ` %kernel.project_dir%/public/emoticons`
301+
262302
### How to automatically dump emoticons on each deploy
263303

264-
Add the following commands to you projects composer.json:
304+
Add the following commands to you projects `composer.json`:
265305

266306
```json
267-
# composer.json
268307
"scripts": {
269308
"post-install-cmd": [
270309
"FM\\BbcodeBundle\\Composer\\ScriptHandler::installEmoticons"
@@ -274,14 +313,3 @@ Add the following commands to you projects composer.json:
274313
]
275314
}
276315
```
277-
278-
To customize emoticons assets folders, use `path` and `folder` node configuration:
279-
280-
```yaml
281-
# app/config.yml
282-
283-
fm_bbcode:
284-
emoticon:
285-
path: # Default: /emoticons
286-
folder: # Default: %kernel.root_dir%/../vendor/mjohnson/decoda/emoticons%
287-
```

Resources/config/bbcode.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22

33
<container xmlns="http://symfony.com/schema/dic/services"
4-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
66

7-
<parameters>
7+
<parameters>
88
<parameter key="fm_bbcode.twig.extension.class">FM\BbcodeBundle\Templating\BbcodeExtension</parameter>
99
<parameter key="fm_bbcode.templating.helper.class">FM\BbcodeBundle\Templating\Helper\BbcodeHelper</parameter>
1010
</parameters>
1111

12-
<services>
12+
<services>
1313
<service id="fm_bbcode.twig.extension" class="%fm_bbcode.twig.extension.class%" public="false">
1414
<tag name="twig.extension" />
1515
<argument type="service" id="fm_bbcode.decoda_manager"/>
1616
</service>
1717

18-
<service id="fm_bbcode.templating.helper" class="%fm_bbcode.templating.helper.class%">
18+
<service id="fm_bbcode.templating.helper" class="%fm_bbcode.templating.helper.class%" public="true">
1919
<tag name="templating.helper" alias="bbcode" />
2020
<argument type="service" id="fm_bbcode.decoda_manager"/>
2121
</service>
2222

23-
<service id="fm_bbcode.decoda_manager" class="FM\BbcodeBundle\Decoda\DecodaManager">
23+
<service id="fm_bbcode.decoda_manager" class="FM\BbcodeBundle\Decoda\DecodaManager" public="true">
2424
<argument type="service" id="service_container"/>
2525
<argument type="service" id="file_locator" />
2626
<argument type="collection">
@@ -30,6 +30,6 @@
3030
<argument key="default_locale">%kernel.default_locale%</argument>
3131
</argument>
3232
</service>
33-
</services>
33+
</services>
3434

3535
</container>

Resources/config/filters.xml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22

33
<container xmlns="http://symfony.com/schema/dic/services"
4-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
66

77
<parameters>
88
<parameter key="fm_bbcode.decoda.filter.block.class">Decoda\Filter\BlockFilter</parameter>
@@ -19,37 +19,37 @@
1919
</parameters>
2020

2121
<services>
22-
<service id="fm_bbcode.decoda.filter.block" class="%fm_bbcode.decoda.filter.block.class%">
22+
<service id="fm_bbcode.decoda.filter.block" class="%fm_bbcode.decoda.filter.block.class%" public="true">
2323
<tag name="fm_bbcode.decoda.filter" id="block" />
2424
</service>
25-
<service id="fm_bbcode.decoda.filter.code" class="%fm_bbcode.decoda.filter.code.class%">
25+
<service id="fm_bbcode.decoda.filter.code" class="%fm_bbcode.decoda.filter.code.class%" public="true">
2626
<tag name="fm_bbcode.decoda.filter" id="code" />
2727
</service>
28-
<service id="fm_bbcode.decoda.filter.email" class="%fm_bbcode.decoda.filter.email.class%">
28+
<service id="fm_bbcode.decoda.filter.email" class="%fm_bbcode.decoda.filter.email.class%" public="true">
2929
<tag name="fm_bbcode.decoda.filter" id="email" />
3030
</service>
31-
<service id="fm_bbcode.decoda.filter.image" class="%fm_bbcode.decoda.filter.image.class%">
31+
<service id="fm_bbcode.decoda.filter.image" class="%fm_bbcode.decoda.filter.image.class%" public="true">
3232
<tag name="fm_bbcode.decoda.filter" id="image" />
3333
</service>
34-
<service id="fm_bbcode.decoda.filter.list" class="%fm_bbcode.decoda.filter.list.class%">
34+
<service id="fm_bbcode.decoda.filter.list" class="%fm_bbcode.decoda.filter.list.class%" public="true">
3535
<tag name="fm_bbcode.decoda.filter" id="list" />
3636
</service>
37-
<service id="fm_bbcode.decoda.filter.quote" class="%fm_bbcode.decoda.filter.quote.class%">
37+
<service id="fm_bbcode.decoda.filter.quote" class="%fm_bbcode.decoda.filter.quote.class%" public="true">
3838
<tag name="fm_bbcode.decoda.filter" id="quote" />
3939
</service>
40-
<service id="fm_bbcode.decoda.filter.text" class="%fm_bbcode.decoda.filter.text.class%">
40+
<service id="fm_bbcode.decoda.filter.text" class="%fm_bbcode.decoda.filter.text.class%" public="true">
4141
<tag name="fm_bbcode.decoda.filter" id="text" />
4242
</service>
43-
<service id="fm_bbcode.decoda.filter.url" class="%fm_bbcode.decoda.filter.url.class%">
43+
<service id="fm_bbcode.decoda.filter.url" class="%fm_bbcode.decoda.filter.url.class%" public="true">
4444
<tag name="fm_bbcode.decoda.filter" id="url" />
4545
</service>
46-
<service id="fm_bbcode.decoda.filter.default" class="%fm_bbcode.decoda.filter.default.class%">
46+
<service id="fm_bbcode.decoda.filter.default" class="%fm_bbcode.decoda.filter.default.class%" public="true">
4747
<tag name="fm_bbcode.decoda.filter" id="default" />
4848
</service>
49-
<service id="fm_bbcode.decoda.filter.video" class="%fm_bbcode.decoda.filter.video.class%">
49+
<service id="fm_bbcode.decoda.filter.video" class="%fm_bbcode.decoda.filter.video.class%" public="true">
5050
<tag name="fm_bbcode.decoda.filter" id="video" />
5151
</service>
52-
<service id="fm_bbcode.decoda.filter.table" class="%fm_bbcode.decoda.filter.table.class%">
52+
<service id="fm_bbcode.decoda.filter.table" class="%fm_bbcode.decoda.filter.table.class%" public="true">
5353
<tag name="fm_bbcode.decoda.filter" id="table" />
5454
</service>
5555
</services>

0 commit comments

Comments
 (0)