src/Variant/VariantProcessor.php
public function process(StorableFileInterface $source, $variant, array $strategies)
    {
        $file = $this->makeTemporaryCopy($source);

        foreach ($strategies as $strategy => $options) {

            $instance = $this->strategyFactory->make($strategy)->setOptions($options);

            // The file returned by the strategy step may have altered the path,
            // name, extension and/or mime type of the file being processed.
            // This information is present in the returned ProcessableFile instance.

            try {
                $newFile = $instance->apply($file);

            } catch (VariantStrategyShouldNotBeAppliedException $e) {

                if ($this->shouldThrowExceptionForUnappliedStrategy()) {
                    throw new VariantStrategyNotAppliedException(
                        "Strategy '{$strategy}' not applied to '{$source->path()}'"
                    );
                }

                continue;
            }

            if (false === $newFile) {
                throw new VariantStrategyNotAppliedException(
                    "Failed to apply '{$strategy}' to '{$source->path()}'"
                );
            }

            $file = $newFile;
        }

        return $file;
    }
public function process(StorableFileInterface $source, $variant, array $strategies)
    {
        $file = $this->makeTemporaryCopy($source);

        foreach ($strategies as $strategy => $options) {

            $instance = $this->strategyFactory->make($strategy)->setOptions($options);

            // The file returned by the strategy step may have altered the path,
            // name, extension and/or mime type of the file being processed.
            // This information is present in the returned ProcessableFile instance.

            try {
                $newFile = $instance->apply($file);

            } catch (VariantStrategyShouldNotBeAppliedException $e) {

                if ($this->shouldThrowExceptionForUnappliedStrategy()) {
                    throw new VariantStrategyNotAppliedException(
                        "Strategy '{$strategy}' not applied to '{$source->path()}'"
                    );
                }

                continue;
            }

            if (false === $newFile) {
                throw new VariantStrategyNotAppliedException(
                    "Failed to apply '{$strategy}' to '{$source->path()}'"
                );
            }

            $file = $newFile;
        }

        return $file;
    }
public function process ( StorableFileInterface $ source , $ variant , array $ strategies ) { $ file = $ this -> makeTemporaryCopy ( $ source ) ; foreach ( $ strategies as $ strategy => $ options ) { $ instance = $ this -> strategyFactory -> make ( $ strategy ) -> setOptions ( $ options ) ; // The file returned by the strategy step may have altered the path, // name, extension and/or mime type of the file being processed. // This information is present in the returned ProcessableFile instance. try { $ newFile = $ instance -> apply ( $ file ) ; } catch ( VariantStrategyShouldNotBeAppliedException $ e ) { if ( $ this -> shouldThrowExceptionForUnappliedStrategy ( ) ) { throw new VariantStrategyNotAppliedException ( "Strategy '{$strategy}' not applied to '{$source->path()}'" ) ; } continue ; } if ( false === $ newFile ) { throw new VariantStrategyNotAppliedException ( "Failed to apply '{$strategy}' to '{$source->path()}'" ) ; } $ file = $ newFile ; } return $ file ; }
Returns a processed variant for a given source file.

@param StorableFileInterface $source
@param string                $variant    the name/prefix name of the variant
@param array[]               $strategies associative, ordered set of strategies to apply
@return StorableFileInterface
@throws VariantStrategyNotAppliedException
@throws CouldNotProcessDataException
Returns a processed variant for a given source file .