Skip to content

Commit

Permalink
Release 2.0: Support Symfony 3.0 (#57)
Browse files Browse the repository at this point in the history
* Drop support for old versions

* Add phpunit-bridge to find deprecations

* Replace security.context by security.authentication_checker

* Migrate to assets component

* Document changes to Security and Asset Extension

* Add support for symfony 3

* Composer is the only supported install method

* Update CHANGELOG

* Remove Symfony\Component\HttpKernel\Log\LoggerInterface

* Update installation and intro chapters of documentation

* Remove Symfony 2.1 stuff, remove class parameters

* Fix copyright year

* Asset name generation in different before 1.1.3

* Tests pass with assetic 1.1.3

* Clean up assetic documentation

* Boolean referenceType is not supported anymore

* Add missing use statements and doc comments

* Update documentation

* Fix some phpdoc issues

* form.csrf_provider is deprecated since sf 2.4

* Enabling the controllers throws an error about MopaBootstrapBundle

* Fix code style

* Add missing dev packages

* Remove deprecated CsrfProviderInterface

* Smarty_Internal_Function_Call_Handler is not available after 3.1.27

* Avoid deprecated services
  • Loading branch information
davidfuhr authored and vitorbrandao committed Jul 20, 2016
1 parent 62af97d commit 92ad31c
Show file tree
Hide file tree
Showing 78 changed files with 671 additions and 685 deletions.
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ git:
depth: 1

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
Expand All @@ -16,10 +14,8 @@ php:
matrix:
fast_finish: true
include:
- php: 5.3
- php: 5.5
env: COMPOSER_FLAGS="--prefer-lowest"
- php: 5.6
env: SYMFONY_VERSION=2.3.*
- php: 5.6
env: SYMFONY_VERSION=2.7.*
- php: 5.6
Expand Down
20 changes: 18 additions & 2 deletions Assetic/SmartyFormulaLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@
* License along with NoiseLabs-SmartyBundle; if not, see
* <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011-2015 Vítor Brandão
* Copyright (C) 2011-2016 Vítor Brandão
*
* @category NoiseLabs
* @package SmartyBundle
* @copyright (C) 2011-2014 Vítor Brandão <[email protected]>
* @copyright (C) 2011-2016 Vítor Brandão <[email protected]>
* @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html LGPL-3
*/

namespace NoiseLabs\Bundle\SmartyBundle\Assetic;

use Assetic\Factory\AssetFactory;
use Assetic\Factory\Loader\FormulaLoaderInterface;
use Assetic\Factory\Resource\ResourceInterface;
use NoiseLabs\Bundle\SmartyBundle\Extension\AsseticExtension;
Expand All @@ -38,9 +39,24 @@
*/
class SmartyFormulaLoader implements FormulaLoaderInterface
{
/**
* @var SmartyEngine
*/
protected $engine;

/**
* @var AsseticExtension
*/
protected $extension;

/**
* @var AssetFactory
*/
protected $factory;

/**
* @var array
*/
protected $tags = array();

public function __construct(SmartyEngine $engine)
Expand Down
4 changes: 2 additions & 2 deletions Bootstrap/Extension/InitializrExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
* License along with NoiseLabs-SmartyBundle; if not, see
* <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011-2015 Vítor Brandão
* Copyright (C) 2011-2016 Vítor Brandão
*
* @category NoiseLabs
* @package SmartyBundle
* @copyright (C) 2011-2014 Vítor Brandão <[email protected]>
* @copyright (C) 2011-2016 Vítor Brandão <[email protected]>
* @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html LGPL-3
* @link http://www.noiselabs.org
*/
Expand Down
4 changes: 2 additions & 2 deletions Bootstrap/Extension/NavbarExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
* License along with NoiseLabs-SmartyBundle; if not, see
* <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011-2015 Vítor Brandão
* Copyright (C) 2011-2016 Vítor Brandão
*
* @category NoiseLabs
* @package SmartyBundle
* @copyright (C) 2011-2014 Vítor Brandão <[email protected]>
* @copyright (C) 2011-2016 Vítor Brandão <[email protected]>
* @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html LGPL-3
* @link http://www.noiselabs.org
*/
Expand Down
11 changes: 7 additions & 4 deletions Bootstrap/Navbar/Renderer/NavbarRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
* License along with NoiseLabs-SmartyBundle; if not, see
* <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011-2015 Vítor Brandão
* Copyright (C) 2011-2016 Vítor Brandão
*
* @category NoiseLabs
* @package SmartyBundle
* @copyright (C) 2011-2014 Vítor Brandão <[email protected]>
* @copyright (C) 2011-2016 Vítor Brandão <[email protected]>
* @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html LGPL-3
* @link http://www.noiselabs.org
*/
Expand Down Expand Up @@ -64,8 +64,11 @@ public function renderNavbar($name, array $options = array())
$template = $options['template'];
}

$html = $this->getSmartyEngine()->fetchTemplateFunction($template, $function,
array('navbar' => $navbar));
$html = $this->getSmartyEngine()->fetchTemplateFunction(
$template,
$function,
array('navbar' => $navbar)
);

return $html;
}
Expand Down
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Change Log

All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [2.0.0] Unreleased

### Added
- Compatibility with Symfony 3.0

### Changed
- AssetsExtension now uses the new [Asset Component](http://symfony.com/doc/current/components/asset/introduction.html)
- SecurityExtension now uses `security.authorization_checker` instead of `security.context`

### Removed
- Drop Support for Symfony < 2.8
- `Symfony\Component\HttpKernel\Log\LoggerInterface` as been replaced by `Psr\Log\LoggerInterface`
- Drop Support for PHP < 5.5

## [1.3.0] - 2016-03-24

### Added
- Compatibility with Symfony 2.8

### Removed
- [#50](https://github.com/noiselabs/SmartyBundle/pull/50) Removed support for unsupported versions of Symfony

### Fixed
- [#51](https://github.com/noiselabs/SmartyBundle/pull/51) fix problem with "plugin tag are already registered" debug messages

18 changes: 12 additions & 6 deletions CacheWarmer/SmartyCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
* License along with NoiseLabs-SmartyBundle; if not, see
* <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011-2015 Vítor Brandão
* Copyright (C) 2011-2016 Vítor Brandão
*
* @category NoiseLabs
* @package SmartyBundle
* @copyright (C) 2011-2014 Vítor Brandão <[email protected]>
* @copyright (C) 2011-2016 Vítor Brandão <[email protected]>
* @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html LGPL-3
* @link http://www.noiselabs.org
*/

namespace NoiseLabs\Bundle\SmartyBundle\CacheWarmer;

use NoiseLabs\Bundle\SmartyBundle\Exception\RuntimeException as SmartyBundleRuntimeException;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;

/**
* Generates the Smarty cache for all templates.
Expand All @@ -40,8 +40,15 @@
*/
class SmartyCacheWarmer implements CacheWarmerInterface
{
/**
* @var ContainerInterface
*/
protected $container;
protected $warmer;

/**
* @var TemplateFinderInterface
*/
protected $finder;

/**
* Constructor.
Expand All @@ -67,7 +74,6 @@ public function __construct(ContainerInterface $container, TemplateFinderInterfa
public function warmUp($cacheDir)
{
$engine = $this->container->get('templating.engine.smarty');
$smarty = $engine->getSmarty();
$logger = $this->container->has('logger') ? $this->container->get('logger') : null;

foreach ($this->finder->findAllTemplates() as $template) {
Expand Down
10 changes: 5 additions & 5 deletions CacheWarmer/SmartyTemplateFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
* License along with NoiseLabs-SmartyBundle; if not, see
* <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011-2015 Vítor Brandão
* Copyright (C) 2011-2016 Vítor Brandão
*
* @category NoiseLabs
* @package SmartyBundle
* @copyright (C) 2011-2014 Vítor Brandão <[email protected]>
* @copyright (C) 2011-2016 Vítor Brandão <[email protected]>
* @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html LGPL-3
* @link http://www.noiselabs.org
*/

namespace NoiseLabs\Bundle\SmartyBundle\CacheWarmer;

use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Templating\TemplateNameParserInterface;
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Templating\TemplateNameParserInterface;

/**
* Finds all the templates.
Expand Down
12 changes: 2 additions & 10 deletions Command/CompileCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
* License along with NoiseLabs-SmartyBundle; if not, see
* <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011-2015 Vítor Brandão
* Copyright (C) 2011-2016 Vítor Brandão
*
* @category NoiseLabs
* @package SmartyBundle
* @copyright (C) 2011-2014 Vítor Brandão <[email protected]>
* @copyright (C) 2011-2016 Vítor Brandão <[email protected]>
* @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html LGPL-3
* @link http://www.noiselabs.org
*/
Expand Down Expand Up @@ -51,12 +51,6 @@ protected function configure()
InputArgument::OPTIONAL,
'A bundle name'
)
->addOption(
'force',
null,
InputOption::VALUE_NONE,
'Force the compilation of all templates even if they weren\'t modified'
)
->setHelp(<<<EOF
The following command finds all known Smarty templates and compiles them:
Expand All @@ -75,10 +69,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$finder = $this->getContainer()->get('smarty.templating.finder');
$engine = $this->getContainer()->get('templating.engine.smarty');
$smarty = $engine->getSmarty();

$bundleName = $input->getArgument('bundle');
$force = (boolean) $input->getOption('force');
$verbose = $input->getOption('verbose');

if ($bundleName && (0 === strpos($bundleName, '@'))) {
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Compiler/MopaBootstrapPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
* License along with NoiseLabs-SmartyBundle; if not, see
* <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011-2015 Vítor Brandão
* Copyright (C) 2011-2016 Vítor Brandão
*
* @category NoiseLabs
* @package SmartyBundle
* @copyright (C) 2011-2014 Vítor Brandão <[email protected]>
* @copyright (C) 2011-2016 Vítor Brandão <[email protected]>
* @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html LGPL-3
* @link http://www.noiselabs.org
*/
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Compiler/RegisterExtensionsPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
* License along with NoiseLabs-SmartyBundle; if not, see
* <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011-2015 Vítor Brandão
* Copyright (C) 2011-2016 Vítor Brandão
*
* @category NoiseLabs
* @package SmartyBundle
* @copyright (C) 2011-2014 Vítor Brandão <[email protected]>
* @copyright (C) 2011-2016 Vítor Brandão <[email protected]>
* @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html LGPL-3
* @link http://www.noiselabs.org
*/
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
* License along with NoiseLabs-SmartyBundle; if not, see
* <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011-2015 Vítor Brandão
* Copyright (C) 2011-2016 Vítor Brandão
*
* @category NoiseLabs
* @package SmartyBundle
* @copyright (C) 2011-2014 Vítor Brandão <[email protected]>
* @copyright (C) 2011-2016 Vítor Brandão <[email protected]>
* @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html LGPL-3
* @link http://www.noiselabs.org
*/
Expand Down
6 changes: 3 additions & 3 deletions DependencyInjection/SmartyExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
* License along with NoiseLabs-SmartyBundle; if not, see
* <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011-2015 Vítor Brandão
* Copyright (C) 2011-2016 Vítor Brandão
*
* @category NoiseLabs
* @package SmartyBundle
* @copyright (C) 2011-2014 Vítor Brandão <[email protected]>
* @copyright (C) 2011-2016 Vítor Brandão <[email protected]>
* @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html LGPL-3
* @link http://www.noiselabs.org
*/
Expand Down Expand Up @@ -81,7 +81,7 @@ public function load(array $configs, ContainerBuilder $container)
$loader->load('assetic.xml');

// choose dynamic or static
if ($useController = $container->getParameterBag()->resolveValue($container->getParameterBag()->get('assetic.use_controller'))) {
if ($container->getParameterBag()->resolveValue($container->getParameterBag()->get('assetic.use_controller'))) {
$container->getDefinition('smarty.extension.assetic.dynamic')->addTag('smarty.extension', array('alias' => 'assetic'));
$container->removeDefinition('smarty.extension.assetic.static');
} else {
Expand Down
24 changes: 16 additions & 8 deletions Exception/AbstractException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
* License along with NoiseLabs-SmartyBundle; if not, see
* <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011-2015 Vítor Brandão
* Copyright (C) 2011-2016 Vítor Brandão
*
* @category NoiseLabs
* @package SmartyBundle
* @copyright (C) 2011-2014 Vítor Brandão <[email protected]>
* @copyright (C) 2011-2016 Vítor Brandão <[email protected]>
* @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html LGPL-3
*/

Expand Down Expand Up @@ -51,9 +51,13 @@ class AbstractException extends \Exception
* @param Smarty_Internal_Template $template Smarty template
* @param Exception $previous The previous exception
*/
public function __construct($message, $lineno = -1, $filename = null,
\Smarty_Internal_Template $template = null, \Exception $previous = null)
{
public function __construct(
$message,
$lineno = -1,
$filename = null,
\Smarty_Internal_Template $template = null,
\Exception $previous = null
) {
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
$this->previous = $previous;
parent::__construct('');
Expand All @@ -69,8 +73,11 @@ public function __construct($message, $lineno = -1, $filename = null,
$this->guessTemplateInfo();
}

$this->rawMessage = str_replace(array('&quot;', '&gt;', '&lt;'),
array('"', '>', '<'), html_entity_decode($message));
$this->rawMessage = str_replace(
array('&quot;', '&gt;', '&lt;'),
array('"', '>', '<'),
html_entity_decode($message)
);

$this->updateRepr();
}
Expand Down Expand Up @@ -233,7 +240,8 @@ protected function jsonEncode($param)
*
* @return array
*/
function objectToArray($var) {
function objectToArray($var)
{
$result = array();
$references = array();

Expand Down
Loading

0 comments on commit 92ad31c

Please sign in to comment.