Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make compatible with Symfony 4 #1

Merged
merged 1 commit into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.idea
composer.lock
Tests/cache
Tests/log
clover.xml

/.idea/
/var/
/vendor/
/Tests/cache
/Tests/log
15 changes: 5 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
language: php

php:
- 5.6
- 7.0
- 7.1
- 7.1.3
- 7.2.0

sudo: false

cache:
directories:
- vendor
- $HOME/.composer/cache
directories:
- vendor
- $HOME/.composer/cache

matrix:
fast_finish: true

env:
- SYMFONY_VERSION="3.0.*" DECODA_VERSION="6.0.*"
- SYMFONY_VERSION="3.0.*" DECODA_VERSION="6.*"
- SYMFONY_VERSION="3.1.*" DECODA_VERSION="6.*"
- SYMFONY_VERSION="3.2.*" DECODA_VERSION="6.*"
- SYMFONY_VERSION="3.3.*" DECODA_VERSION="6.*"
- SYMFONY_VERSION="3.4.*" DECODA_VERSION="6.*"
- SYMFONY_VERSION="4.0.*" DECODA_VERSION="6.*"
Expand Down
23 changes: 13 additions & 10 deletions Command/DumpEmoticonsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ protected function configure()
{
$this
->setName('bbcode:dump')
->setDescription('dump emoticons to public folder')
->addOption('emoticons-folder', null, InputOption::VALUE_OPTIONAL, null, null)
->setDescription('Dumps the emoticons to their configured folder')
->addOption('emoticons-folder', null, InputOption::VALUE_OPTIONAL)
;
}

/**
* Copies one folder to another.
*
* @param $src
* @param $dst
* @param string $src
* @param string $dst
*/
private function recurseCopy($src, $dst)
private function recurseCopy(string $src, string $dst)
{
$dir = opendir($src);
@mkdir($dst);
Expand All @@ -49,15 +49,15 @@ private function recurseCopy($src, $dst)
}

/**
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int|null|void
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$webFolder = sprintf('%s%s',
$this->getContainer()->getParameter('assetic.write_to'),
$this->getContainer()->getParameter('fm_bbcode.public_path'),
$this->getContainer()->getParameter('fm_bbcode.emoticon.path')
);
@mkdir($webFolder);
Expand All @@ -68,11 +68,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

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

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

$output->writeln('<comment>Emoticons dumped succesfully</comment>');

return 0;
}
}
3 changes: 2 additions & 1 deletion DependencyInjection/Compiler/RegisterFiltersPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Decoda\Filter;

class RegisterFiltersPass implements CompilerPassInterface
{
Expand Down Expand Up @@ -37,7 +38,7 @@ public function process(ContainerBuilder $container)
$class = $container->getDefinition($id)->getClass();

$refClass = new \ReflectionClass($class);
$interface = 'Decoda\Filter';
$interface = Filter::class;
if (!$refClass->implementsInterface($interface)) {
throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface));
}
Expand Down
5 changes: 4 additions & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public function getConfigTreeBuilder()
->end()
->end()
->end()
->scalarNode('public_path')->defaultValue('%kernel.project_dir%/public')->end()
->end()
->end();

Expand Down Expand Up @@ -132,7 +133,9 @@ private function addEmoticonSection(ArrayNodeDefinition $rootNode)
})
->end()
->end()
->scalarNode('folder')->defaultValue('%kernel.root_dir%/../vendor/mjohnson/decoda/emoticons')->end()
->scalarNode('folder')
->defaultValue('%kernel.project_dir%/vendor/mjohnson/decoda/emoticons')
->end()
->scalarNode('extension')->defaultValue('png')->end()
->end()
->end()
Expand Down
6 changes: 3 additions & 3 deletions DependencyInjection/FMBbcodeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
class FMBbcodeExtension extends Extension
{
/**
* @see Symfony\Component\DependencyInjection\Extension.ExtensionInterface::load()
* @see \Symfony\Component\DependencyInjection\Extension\ExtensionInterface::load()
*
* @param array $configs
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
* @param array $configs
* @param ContainerBuilder $container
*/
public function load(array $configs, ContainerBuilder $container)
{
Expand Down
60 changes: 44 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,33 @@ Using Composer, just add the following configuration to your `composer.json`:

Or you can use composer to install this bundle:

For symfony <3.0, use latest ~6 version
For Symfony <3.0, use latest ~6 version

```sh
composer require helios-ag/fm-bbcode-bundle:~6
```

for Symfony 3
For Symfony 3.0, use latest ~7 version

```sh
composer require helios-ag/fm-bbcode-bundle
```

or

```sh
composer require helios-ag/fm-bbcode-bundle:~7
```

For Symfony 4.0 you can use the ~8 version

```sh
composer require helios-ag/fm-bbcode-bundle:~8
```

### Step 2: Enable the bundle

Finally, enable the bundle in the kernel:
Finally, for Symfony2 and Symfony3, enable the bundle in the AppKernel:

``` php
<?php
Expand All @@ -73,15 +80,32 @@ public function registerBundles()
);
}
```

For Symfony4, you'll need to enable the bundle in your `bundles.php`-file:
``` php
// config/bundles.php

return [
// ...
FM\BbcodeBundle\FMBbcodeBundle::class => ['all' => true],
];
```

### Step 3: Dump emoticons (optional)

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

For Symfony2:
``` bash
./app/console bbcode:dump
```

For Symfony3 and Symfony4:
``` bash
./bin/console bbcode:dump
```

## Basic configuration

### Make the Twig extensions available by updating your configuration:
Expand Down Expand Up @@ -259,12 +283,27 @@ emoticons:
- ":my_emoticon:"
```

### How to customize the emoticons assets

To customize emoticons assets folders, use `path` and `folder` node configuration:

```yaml
# app/config.yml

fm_bbcode:
public_path: # Default: %kernel.project_dir%/public
emoticon:
path: # Default: /emoticons
folder: # Default: %kernel.project_dir%/vendor/mjohnson/decoda/emoticons%
```

Using the default configuration it would dump the emoticons in ` %kernel.project_dir%/public/emoticons`

### How to automatically dump emoticons on each deploy

Add the following commands to you projects composer.json:
Add the following commands to you projects `composer.json`:

```json
# composer.json
"scripts": {
"post-install-cmd": [
"FM\\BbcodeBundle\\Composer\\ScriptHandler::installEmoticons"
Expand All @@ -274,14 +313,3 @@ Add the following commands to you projects composer.json:
]
}
```

To customize emoticons assets folders, use `path` and `folder` node configuration:

```yaml
# app/config.yml

fm_bbcode:
emoticon:
path: # Default: /emoticons
folder: # Default: %kernel.root_dir%/../vendor/mjohnson/decoda/emoticons%
```
14 changes: 7 additions & 7 deletions Resources/config/bbcode.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<?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">
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">

<parameters>
<parameters>
<parameter key="fm_bbcode.twig.extension.class">FM\BbcodeBundle\Templating\BbcodeExtension</parameter>
<parameter key="fm_bbcode.templating.helper.class">FM\BbcodeBundle\Templating\Helper\BbcodeHelper</parameter>
</parameters>

<services>
<services>
<service id="fm_bbcode.twig.extension" class="%fm_bbcode.twig.extension.class%" public="false">
<tag name="twig.extension" />
<argument type="service" id="fm_bbcode.decoda_manager"/>
</service>

<service id="fm_bbcode.templating.helper" class="%fm_bbcode.templating.helper.class%">
<service id="fm_bbcode.templating.helper" class="%fm_bbcode.templating.helper.class%" public="true">
<tag name="templating.helper" alias="bbcode" />
<argument type="service" id="fm_bbcode.decoda_manager"/>
</service>

<service id="fm_bbcode.decoda_manager" class="FM\BbcodeBundle\Decoda\DecodaManager">
<service id="fm_bbcode.decoda_manager" class="FM\BbcodeBundle\Decoda\DecodaManager" public="true">
<argument type="service" id="service_container"/>
<argument type="service" id="file_locator" />
<argument type="collection">
Expand All @@ -30,6 +30,6 @@
<argument key="default_locale">%kernel.default_locale%</argument>
</argument>
</service>
</services>
</services>

</container>
26 changes: 13 additions & 13 deletions Resources/config/filters.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?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">
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">

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

<services>
<service id="fm_bbcode.decoda.filter.block" class="%fm_bbcode.decoda.filter.block.class%">
<service id="fm_bbcode.decoda.filter.block" class="%fm_bbcode.decoda.filter.block.class%" public="true">
<tag name="fm_bbcode.decoda.filter" id="block" />
</service>
<service id="fm_bbcode.decoda.filter.code" class="%fm_bbcode.decoda.filter.code.class%">
<service id="fm_bbcode.decoda.filter.code" class="%fm_bbcode.decoda.filter.code.class%" public="true">
<tag name="fm_bbcode.decoda.filter" id="code" />
</service>
<service id="fm_bbcode.decoda.filter.email" class="%fm_bbcode.decoda.filter.email.class%">
<service id="fm_bbcode.decoda.filter.email" class="%fm_bbcode.decoda.filter.email.class%" public="true">
<tag name="fm_bbcode.decoda.filter" id="email" />
</service>
<service id="fm_bbcode.decoda.filter.image" class="%fm_bbcode.decoda.filter.image.class%">
<service id="fm_bbcode.decoda.filter.image" class="%fm_bbcode.decoda.filter.image.class%" public="true">
<tag name="fm_bbcode.decoda.filter" id="image" />
</service>
<service id="fm_bbcode.decoda.filter.list" class="%fm_bbcode.decoda.filter.list.class%">
<service id="fm_bbcode.decoda.filter.list" class="%fm_bbcode.decoda.filter.list.class%" public="true">
<tag name="fm_bbcode.decoda.filter" id="list" />
</service>
<service id="fm_bbcode.decoda.filter.quote" class="%fm_bbcode.decoda.filter.quote.class%">
<service id="fm_bbcode.decoda.filter.quote" class="%fm_bbcode.decoda.filter.quote.class%" public="true">
<tag name="fm_bbcode.decoda.filter" id="quote" />
</service>
<service id="fm_bbcode.decoda.filter.text" class="%fm_bbcode.decoda.filter.text.class%">
<service id="fm_bbcode.decoda.filter.text" class="%fm_bbcode.decoda.filter.text.class%" public="true">
<tag name="fm_bbcode.decoda.filter" id="text" />
</service>
<service id="fm_bbcode.decoda.filter.url" class="%fm_bbcode.decoda.filter.url.class%">
<service id="fm_bbcode.decoda.filter.url" class="%fm_bbcode.decoda.filter.url.class%" public="true">
<tag name="fm_bbcode.decoda.filter" id="url" />
</service>
<service id="fm_bbcode.decoda.filter.default" class="%fm_bbcode.decoda.filter.default.class%">
<service id="fm_bbcode.decoda.filter.default" class="%fm_bbcode.decoda.filter.default.class%" public="true">
<tag name="fm_bbcode.decoda.filter" id="default" />
</service>
<service id="fm_bbcode.decoda.filter.video" class="%fm_bbcode.decoda.filter.video.class%">
<service id="fm_bbcode.decoda.filter.video" class="%fm_bbcode.decoda.filter.video.class%" public="true">
<tag name="fm_bbcode.decoda.filter" id="video" />
</service>
<service id="fm_bbcode.decoda.filter.table" class="%fm_bbcode.decoda.filter.table.class%">
<service id="fm_bbcode.decoda.filter.table" class="%fm_bbcode.decoda.filter.table.class%" public="true">
<tag name="fm_bbcode.decoda.filter" id="table" />
</service>
</services>
Expand Down
Loading