Skip to content

Commit

Permalink
Merge pull request #317 from lenybernard/upgrade/2.7-deprecations
Browse files Browse the repository at this point in the history
Upgrade/2.7 deprecations
  • Loading branch information
Leny BERNARD committed Jan 22, 2016
2 parents 935b391 + e2cf5ee commit dc8f0b8
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Bundle/CoreBundle/Twig/Extension/GlobalsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Provides some gloval variabls to twig.
*/
class GlobalsExtension extends \Twig_Extension
class GlobalsExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface
{
protected $templateMapper;
protected $session;
Expand Down
10 changes: 8 additions & 2 deletions Bundle/FormBundle/Twig/FormExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ class FormExtension extends \Twig_Extension
public function getFunctions()
{
return [
'form_help' => new \Twig_Function_Node('Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', ['is_safe' => ['html']]),
'form_tabs' => new \Twig_Function_Node('Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', ['is_safe' => ['html']]),
new \Twig_SimpleFunction('form_help', null, [
'node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode',
'is_safe' => ['html'],
]),
new \Twig_SimpleFunction('form_tabs', null, [
'node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode',
'is_safe' => ['html'],
]),
];
}

Expand Down
2 changes: 1 addition & 1 deletion Bundle/FormBundle/Twig/IconExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @author Craig Blanchette (isometriks) <[email protected]>
*/
class IconExtension extends \Twig_Extension
class IconExtension extends \Twig_Extension implements \Twig_Extension_InitRuntimeInterface
{
/**
* @var \Twig_Environment
Expand Down
2 changes: 1 addition & 1 deletion Bundle/MediaBundle/Twig/MenuTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(MenuBuilder $menuBuilder)
public function getFunctions()
{
return [
'admin_menu_get' => new \Twig_Function_Method($this, 'getAdminMenu'),
new \Twig_SimpleFunction('admin_menu_get', [$this, 'getAdminMenu']),
];
}

Expand Down
2 changes: 1 addition & 1 deletion Bundle/PageBundle/Twig/Extension/PageExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function getFunctions()
{
return [
new \Twig_SimpleFunction('vic_current_page_reference', [$this, 'victoireCurrentPageReference']),
'cms_page_css' => new \Twig_Function_Method($this, 'cmsPageCss', ['is_safe' => ['html']]),
new \Twig_SimpleFunction('cms_page_css', [$this, 'cmsPageCss'], ['is_safe' => ['html']]),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ public function redislize($data)
public function unredislize($data)
{
$data = urldecode($data);
// unserialize data if we can
$unserializedData = @unserialize($data);
if ($unserializedData !== false) {
return $unserializedData;

if (self::isSerialized($data)) {
$unserializedData = @unserialize($data);
if ($unserializedData !== false) {
return $unserializedData;
}
}

return $data;
Expand Down Expand Up @@ -91,4 +93,30 @@ public function generateKey($alias, $id)
{
return $alias.':'.$id;
}

public static function isSerialized($data) {
// if it isn't a string, it isn't serialized
if ( !is_string( $data ) )
return false;
$data = trim( $data );
if ( 'N;' == $data )
return true;
if ( !preg_match( '/^([adObis]):/', $data, $badions ) )
return false;
switch ( $badions[1] ) {
case 'a' :
case 'O' :
case 's' :
if ( preg_match( "/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data ) )
return true;
break;
case 'b' :
case 'i' :
case 'd' :
if ( preg_match( "/^{$badions[1]}:[0-9.E-]+;\$/", $data ) )
return true;
break;
}
return false;
}
}
4 changes: 2 additions & 2 deletions Bundle/WidgetBundle/Twig/LinkExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ public function victoireLink($parameters, $label, $attr = [], $currentClass = 'a

$url = $this->victoireLinkUrl($parameters, true, $url);
//Creates a new twig environment
$twigEnv = new \Twig_Environment(new \Twig_Loader_String());
$twig = new \Twig_Environment(new \Twig_Loader_Array(['linkTemplate' => '{{ link|raw }}']));

return $twigEnv->render('{{ link|raw }}', ['link' => '<a href="'.$url.'" '.implode($attributes, ' ').'>'.$label.'</a>']);
return $twig->render('linkTemplate', ['link' => '<a href="'.$url.'" '.implode($attributes, ' ').'>'.$label.'</a>']);
}

/**
Expand Down

0 comments on commit dc8f0b8

Please sign in to comment.