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 );
        }
    }
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 );
        }
    }
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 ) ; } }
Set item's assets of a given type to the pack.

@param string $type the assets type, one of those who are supported.
@param string[] $assets the list of assets' URL to load

@param \tao_models_classes_service_StorageDirectory $publicDirectory

@throw InvalidArgumentException
Set item s assets of a given type to the pack .