public function setAssets($type, $assets, $publicDirectory)
    {
        if(!in_array($type, self::$assetTypes)){
            throw new InvalidArgumentException('Unknow asset type "' . $type . '", it should be either ' . implode(', ', self::$assetTypes));
        }
        if(!is_array($assets)){
            throw new InvalidArgumentException('Assests should be an array, "' . gettype($assets) . '" given');
        }

        /**
         * Apply active encoder immediately
         * @var Encoding $encoder
         */
        $encoder = EncoderService::singleton()->get($this->assetEncoders[$type], $publicDirectory);
        foreach ($assets as $asset) {
            if ($asset instanceof MediaAsset) {
                $mediaSource = $asset->getMediaSource();
                if ($mediaSource instanceof MediaSource || $mediaSource instanceof HttpSource) {
                    $assetKey = $asset->getMediaIdentifier();
                } else {
                    $assetKey = $mediaSource->getBaseName($asset->getMediaIdentifier());
                }
            } else {
                $assetKey = $asset;
            }

            $this->assets[$type][$assetKey] = $encoder->encode( $asset );
        }
    }