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

Commit

Permalink
bug #395 Fixing 3.0 compatibility problem with ResourceInterface::isF…
Browse files Browse the repository at this point in the history
…resh() (weaverryan)

This PR was merged into the 2.7-dev branch.

Discussion
----------

Fixing 3.0 compatibility problem with ResourceInterface::isFresh()

Hi guys!

The bundle is not ready for 3.0 yet, because of [AsseticResource](https://github.com/symfony/assetic-bundle/blob/master/Config/AsseticResource.php). Implementing `isFresh()` on `ResourceInterface` is deprecated: we need to also implement `SelfCheckingResourceInterface`.

But this patch clearly has issues: it makes AsseticBundle require symfony/config 2.8 (and worse, beta currently). Is there a way to make the bundle compatible with 2.7 (where `SelfCheckingResourceInterface` doesn't exist) AND 3.0 (where `SelfCheckingResourceInterface` is required) at the same time?

Thanks!

Commits
-------

49c7279 Adding a new SelfCheckingAsseticResource for compat with 2.8-3.0+
  • Loading branch information
stof committed Dec 1, 2015
2 parents d885ec8 + 49c7279 commit 9ad8456
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 9ad8456

Please sign in to comment.