Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

Commit

Permalink
Adding a new SelfCheckingAsseticResource for compat with 2.8-3.0+
Browse files Browse the repository at this point in the history
In 2.8, the SelfCheckingResourceInterface becomes available and you must
implement it for 3.0. An if statement either uses the old AsseticResource
(which does not include this interface) or the new SelfCheckingAsseticResource
if the interface exists.
  • Loading branch information
weaverryan committed Nov 24, 2015
1 parent d885ec8 commit 49c7279
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
25 changes: 25 additions & 0 deletions Config/SelfCheckingAsseticResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/*
* This file is part of the Symfony framework.
*
* (c) Fabien Potencier <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Symfony\Bundle\AsseticBundle\Config;

use Symfony\Component\Config\Resource\SelfCheckingResourceInterface;

/**
* Implements SelfCheckingResourceInterface required in Symfony 3.0.
*
* @author Ryan Weaver <[email protected]>
*
* @internal
*/
class SelfCheckingAsseticResource extends AsseticResource implements SelfCheckingResourceInterface
{
}
8 changes: 7 additions & 1 deletion Routing/AsseticLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Assetic\Asset\AssetInterface;
use Assetic\Factory\LazyAssetManager;
use Symfony\Bundle\AsseticBundle\Config\AsseticResource;
use Symfony\Bundle\AsseticBundle\Config\SelfCheckingAsseticResource;
use Symfony\Component\Config\Loader\Loader;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
Expand Down Expand Up @@ -56,7 +57,12 @@ public function load($routingResource, $type = null)
$resources = array($resources);
}
foreach ($resources as $resource) {
$routes->addResource(new AsseticResource($resource));
if (interface_exists('Symfony\Component\Config\Resource\SelfCheckingResourceInterface')) {
$routes->addResource(new SelfCheckingAsseticResource($resource));
} else {
// for BC with symfony/config 2.7 and lower
$routes->addResource(new AsseticResource($resource));
}
}
}

Expand Down

0 comments on commit 49c7279

Please sign in to comment.