I can't understand this error. I tried all things but can't solve this. Can someone tell me where is my fault please .
The error :
FatalThrowableError in MemcachedCacheProvider.php line 14: Type error: Argument 1 passed to AppBundle\Data\CacheProvider\MemcachedCacheProvider::__construct() must implement interface Symfony\Component\DependencyInjection\ContainerInterface, none given, called in ...app\cache\dev\appDevDebugProjectContainer.php on line 373
MemcachedCacheProvider.php ;
<?php
namespace AppBundle\Data\CacheProvider;
use AppBundle\Data\Interfaces\ICacheProvider;
use AppBundle\Data\Interfaces\ICacheItem;
use Symfony\Component\DependencyInjection\ContainerInterface;
class MemcachedCacheProvider implements ICacheProvider
{
/** @var ContainerInterface */
protected $_container;
public function __construct(ContainerInterface $container) {
$this->_container = $container;
}
public function GetItem($cacheKey)
{
$result = $this->_container->get('beryllium_cache.client')->get($cacheKey);
if($result === null
|| !$result)
return null;
return $result;
}
public function GetItems(array $cacheKeys)
{
$cachedItems = array();
$cache = $this->_container->get('beryllium_cache.client');
foreach($cacheKeys as $key) {
$item = $cache->get($key);
if($item === null || !$item)
return null;
$cachedItems[] = $item;
}
if(count($cachedItems) == 0)
return null;
return $cachedItems;
}
public function RemoveItem($cacheKey)
{
$this->_container->get('beryllium_cache.client')->delete($cacheKey);
}
public function RemovePrefix($namespaceKey)
{
//Used namespaces for memcache, so incrementing namespace value will now work as removing prefix
$this->_container->get('beryllium_cache.client')->increment($namespaceKey);
//TODO: No solution for removing items by prefix in memcached. Flushing cache!
//$this->_container->get('beryllium_cache.client')->flush();
}
public function SetItem(ICacheItem $cacheItem)
{
if($cacheItem->GetItem() === null)
return;
$this->_container->get('beryllium_cache.client')->set($cacheItem->GetKey(), $cacheItem, ($cacheItem->GetExpireTimeStamp() == 0 ? 0 : ($cacheItem->GetExpireTimeStamp()-time())));
}
public function SetItems(array $items, $expireTimeStamp)
{
$cache = $this->_container->get('beryllium_cache.client');
foreach($items as &$item) {
$cache->set($item->GetKey(), $item, ($expireTimeStamp == 0 ? 0 : ($expireTimeStamp-time())));
}
}
public function GetNamespace($namespaceKey)
{
$ns = $this->GetItem($namespaceKey);
if(empty($ns)) {
//generate a random value to use as namespace and store it
$ns = mt_rand();
$this->_container->get('beryllium_cache.client')->set($namespaceKey, $ns, 0);
}
return $ns;
}
And the services.yml ;
ayon_app.cacheprovider:
class: AppBundle\Data\CacheProvider\MemcachedCacheProvider
arguments: ["@service_container"]
$this->get(...), but if by any chance you do$x = new MemcachedCacheProvider(...)then that would be a problem. So I don't need all your code, just the context where it is used/created/injected. - Yoshi