public function create($service, array $params = array())
    {
        /** @var AssetContainer */
        $store = reset($params);
        if (!$store instanceof AssetContainer) {
            throw new BadMethodCallException("Can only create Image_Backend for " . AssetContainer::class);
        }

        // Check cache
        $key = sha1($store->getHash().'-'.$store->getVariant());
        if (array_key_exists($key, $this->cache)) {
            return $this->cache[$key];
        }

        // Verify file exists before creating backend
        $backend = null;
        if ($store->exists() && $store->getIsImage()) {
            $backend = $this->creator->create($service, $params);
        }

        // Cache
        $this->cache[$key] = $backend;
        return $backend;
    }
public function create($service, array $params = array())
    {
        /** @var AssetContainer */
        $store = reset($params);
        if (!$store instanceof AssetContainer) {
            throw new BadMethodCallException("Can only create Image_Backend for " . AssetContainer::class);
        }

        // Check cache
        $key = sha1($store->getHash().'-'.$store->getVariant());
        if (array_key_exists($key, $this->cache)) {
            return $this->cache[$key];
        }

        // Verify file exists before creating backend
        $backend = null;
        if ($store->exists() && $store->getIsImage()) {
            $backend = $this->creator->create($service, $params);
        }

        // Cache
        $this->cache[$key] = $backend;
        return $backend;
    }
public function create ( $ service , array $ params = array ( ) ) { /** @var AssetContainer */ $ store = reset ( $ params ) ; if ( ! $ store instanceof AssetContainer ) { throw new BadMethodCallException ( "Can only create Image_Backend for " . AssetContainer :: class ) ; } // Check cache $ key = sha1 ( $ store -> getHash ( ) . '-' . $ store -> getVariant ( ) ) ; if ( array_key_exists ( $ key , $ this -> cache ) ) { return $ this -> cache [ $ key ] ; } // Verify file exists before creating backend $ backend = null ; if ( $ store -> exists ( ) && $ store -> getIsImage ( ) ) { $ backend = $ this -> creator -> create ( $ service , $ params ) ; } // Cache $ this -> cache [ $ key ] = $ backend ; return $ backend ; }
Creates a new service instance.

@param string $service The class name of the service.
@param array $params The constructor parameters.
@return object The created service instances.
Creates a new service instance .