Skip to content

Commit 7b80a88

Browse files
committed
Assetic framework support
1 parent 3f6dc69 commit 7b80a88

19 files changed

Lines changed: 2263 additions & 540 deletions

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"laminas/laminas-loader": "^2.5.1",
3030
"laminas/laminas-eventmanager": "^2.6.3 || ^3.0.1",
3131
"laminas/laminas-mvc": "^2.7.9 || ^3.0.2",
32-
"kriswallsmith/assetic": "^1.4.0",
32+
"assetic/framework": "^2.0",
3333
"laminas/laminas-dependency-plugin": "^2.0"
3434
},
3535
"require-dev": {

composer.lock

Lines changed: 2076 additions & 490 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/AssetManager/Asset/AggregateAsset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace AssetManager\Asset;
44

55
use Assetic\Asset\BaseAsset;
6-
use Assetic\Filter\FilterInterface;
6+
use Assetic\Contracts\Filter\FilterInterface;
77
use AssetManager\Exception;
88

99
/**

src/AssetManager/Cache/FilePathCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace AssetManager\Cache;
44

5-
use Assetic\Cache\CacheInterface;
5+
use Assetic\Contracts\Cache\CacheInterface;
66
use AssetManager\Exception\RuntimeException;
77
use Laminas\Stdlib\ErrorHandler;
88

src/AssetManager/Cache/LaminasCacheAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace AssetManager\Cache;
44

5-
use Assetic\Cache\CacheInterface;
5+
use Assetic\Contracts\Cache\CacheInterface;
66
use Laminas\Cache\Storage\StorageInterface;
77

88
/**
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace AssetManager\Cache;
6+
7+
use Assetic\Contracts\Cache\CacheInterface;
8+
use Psr\SimpleCache\CacheInterface as SimpleCache;
9+
10+
/**
11+
* PSR SimpleCache Adapter for Assetic
12+
*/
13+
class PsrSimpleCacheAdapter implements CacheInterface
14+
{
15+
16+
/** @var SimpleCache */
17+
protected $cache;
18+
19+
/** @var int|null */
20+
protected $ttl;
21+
22+
/**
23+
* Constructor
24+
*
25+
* @param SimpleCache $cache Laminas Configured Cache Storage
26+
* @param int|null $ttl
27+
*/
28+
public function __construct(SimpleCache $cache, ?int $ttl = null)
29+
{
30+
$this->cache = $cache;
31+
$this->ttl = $ttl;
32+
}
33+
34+
/**
35+
* {@inheritDoc}
36+
*/
37+
public function has($key)
38+
{
39+
return $this->cache->has($key);
40+
}
41+
42+
/**
43+
* {@inheritDoc}
44+
*/
45+
public function get($key)
46+
{
47+
return $this->cache->get($key);
48+
}
49+
50+
/**
51+
* {@inheritDoc}
52+
*/
53+
public function set($key, $value)
54+
{
55+
return $this->cache->set($key, $value, $this->ttl);
56+
}
57+
58+
/**
59+
* {@inheritDoc}
60+
*/
61+
public function remove($key)
62+
{
63+
return $this->cache->delete($key);
64+
}
65+
}

src/AssetManager/Resolver/CollectionResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace AssetManager\Resolver;
44

55
use Assetic\Asset\AssetCollection;
6-
use Assetic\Asset\AssetInterface;
6+
use Assetic\Contracts\Asset\AssetInterface;
77
use AssetManager\Exception;
88
use AssetManager\Service\AssetFilterManager;
99
use AssetManager\Service\AssetFilterManagerAwareInterface;

src/AssetManager/Resolver/ConcatResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace AssetManager\Resolver;
44

5-
use Assetic\Asset\AssetInterface;
5+
use Assetic\Contracts\Asset\AssetInterface;
66
use AssetManager\Asset\AggregateAsset;
77
use AssetManager\Exception;
88
use AssetManager\Service\AssetFilterManager;
@@ -135,7 +135,7 @@ public function resolve($name)
135135
throw new Exception\RuntimeException(
136136
sprintf(
137137
'Asset "%s" from collection "%s" can\'t be resolved '
138-
.'to an Asset implementing Assetic\Asset\AssetInterface.',
138+
.'to an Asset implementing Assetic\Contracts\Asset\AssetInterface.',
139139
$assetName,
140140
$name
141141
)

src/AssetManager/Resolver/ResolverInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface ResolverInterface
99
*
1010
* @param string $path The path to resolve.
1111
*
12-
* @return \Assetic\Asset\AssetInterface|null Asset instance when found, null when not.
12+
* @return \Assetic\Contracts\Asset\AssetInterface|null Asset instance when found, null when not.
1313
*/
1414
public function resolve($path);
1515
}

src/AssetManager/Service/AssetCacheManager.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace AssetManager\Service;
44

55
use Assetic\Asset\AssetCache;
6-
use Assetic\Asset\AssetInterface;
7-
use Assetic\Cache\CacheInterface;
6+
use Assetic\Contracts\Asset\AssetInterface;
7+
use Assetic\Contracts\Cache\CacheInterface;
88
use Laminas\ServiceManager\ServiceLocatorInterface;
99

1010
/**
@@ -138,9 +138,6 @@ private function classMapper($class)
138138
$classToCheck .= (substr($class, -5) === 'Cache') ? '' : 'Cache';
139139

140140
switch ($classToCheck) {
141-
case 'ApcCache':
142-
$class = 'Assetic\Cache\ApcCache';
143-
break;
144141
case 'FilesystemCache':
145142
$class = 'Assetic\Cache\FilesystemCache';
146143
break;

0 commit comments

Comments
 (0)