Skip to content

Commit

Permalink
Merge pull request #222 from jzawadzki/symfony4
Browse files Browse the repository at this point in the history
symfony4 support
  • Loading branch information
LogansUA authored Dec 26, 2017
2 parents db39160 + 174420b commit 06328cc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions Resources/config/service.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<!-- T W I G H E L P E R S -->
<service id="twig.extension.stfalcon_tinymce" class="%stfalcon_tinymce.twig.extension.class%">
<argument type="service" id="service_container" />
<argument type="service" id="assets.packages" />
<tag name="twig.extension" alias="stfalcon_tinymce" />
</service>
</services>
Expand Down
16 changes: 11 additions & 5 deletions Twig/Extension/StfalconTinymceExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Stfalcon\Bundle\TinymceBundle\Twig\Extension;

use Stfalcon\Bundle\TinymceBundle\Helper\LocaleHelper;
use Symfony\Component\Asset\Packages;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
Expand All @@ -25,14 +26,20 @@ class StfalconTinymceExtension extends \Twig_Extension
*/
protected $baseUrl;

/**
* @var Packages
*/
private $packages;

/**
* Initialize tinymce helper
*
* @param ContainerInterface $container
*/
public function __construct(ContainerInterface $container)
public function __construct(ContainerInterface $container, Packages $packages)
{
$this->container = $container;
$this->packages = $packages;
}

/**
Expand Down Expand Up @@ -94,7 +101,7 @@ public function tinymceInit($options = array())
unset($config['asset_package_name']);

/** @var $assets \Symfony\Component\Templating\Helper\CoreAssetsHelper */
$assets = $this->getService('assets.packages');
$assets = $this->packages;

// Get path to tinymce script for the jQuery version of the editor
if ($config['tinymce_jquery']) {
Expand Down Expand Up @@ -180,7 +187,7 @@ public function tinymceInit($options = array())
json_encode($config)
);

return $this->getService('templating')->render('StfalconTinymceBundle:Script:init.html.twig', array(
return $this->getService('twig')->render('@StfalconTinymce/Script/init.html.twig', array(
'tinymce_config' => $tinymceConfiguration,
'include_jquery' => $config['include_jquery'],
'tinymce_jquery' => $config['tinymce_jquery'],
Expand Down Expand Up @@ -208,8 +215,7 @@ public function getName()
*/
protected function getAssetsUrl($inputUrl)
{
/** @var $assets \Symfony\Component\Templating\Helper\CoreAssetsHelper */
$assets = $this->getService('assets.packages');
$assets = $this->packages;

$url = preg_replace('/^asset\[(.+)\]$/i', '$1', $inputUrl);

Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
},
"require": {
"php": ">=5.4.0",
"symfony/symfony": ">=3.0"
"symfony/framework-bundle": "^3.0|^4.0",
"symfony/twig-bundle": "^3.0|^4.0",
"symfony/asset":"^3.0|^4.0"
},
"autoload": {
"psr-0": {
Expand Down

0 comments on commit 06328cc

Please sign in to comment.