src/Http/Composers/AssetViewComposer.php
public function compose(View $view)
    {
        $strategy = $this->getValidatedStrategyFromConfig();
        $output = [];

        foreach((array)config("sharp.extensions.assets") as $position => $paths) {
            foreach((array)$paths as $assetPath) {
                if(!isset($output[$position])) {
                    $output[$position] = [];
                }

                // Only render valid assets
                if(ends_with($assetPath, $this->assetTypes)) {
                    // Grab the relevant template based on the filetype
                    $template = array_get($this->renderTemplates, $this->getAssetFileType($assetPath));

                    // Apply the strategy (run through asset() or mix()
                    $resolvedAssetPath = $this->getAssetPathWithStrategyApplied($strategy, $assetPath);

                    $output[$position][] = sprintf($template, $resolvedAssetPath);
                }
            }
        }

        // Build the strings to output in the blades
        $toBind = [];
        foreach((array)$output as $position => $toOutput) {
            $toBind[$position] = implode('', $toOutput);
        }

        $view->with('injectedAssets', $toBind);
    }
public function compose(View $view)
    {
        $strategy = $this->getValidatedStrategyFromConfig();
        $output = [];

        foreach((array)config("sharp.extensions.assets") as $position => $paths) {
            foreach((array)$paths as $assetPath) {
                if(!isset($output[$position])) {
                    $output[$position] = [];
                }

                // Only render valid assets
                if(ends_with($assetPath, $this->assetTypes)) {
                    // Grab the relevant template based on the filetype
                    $template = array_get($this->renderTemplates, $this->getAssetFileType($assetPath));

                    // Apply the strategy (run through asset() or mix()
                    $resolvedAssetPath = $this->getAssetPathWithStrategyApplied($strategy, $assetPath);

                    $output[$position][] = sprintf($template, $resolvedAssetPath);
                }
            }
        }

        // Build the strings to output in the blades
        $toBind = [];
        foreach((array)$output as $position => $toOutput) {
            $toBind[$position] = implode('', $toOutput);
        }

        $view->with('injectedAssets', $toBind);
    }
public function compose ( View $ view ) { $ strategy = $ this -> getValidatedStrategyFromConfig ( ) ; $ output = [ ] ; foreach ( ( array ) config ( "sharp.extensions.assets" ) as $ position => $ paths ) { foreach ( ( array ) $ paths as $ assetPath ) { if ( ! isset ( $ output [ $ position ] ) ) { $ output [ $ position ] = [ ] ; } // Only render valid assets if ( ends_with ( $ assetPath , $ this -> assetTypes ) ) { // Grab the relevant template based on the filetype $ template = array_get ( $ this -> renderTemplates , $ this -> getAssetFileType ( $ assetPath ) ) ; // Apply the strategy (run through asset() or mix() $ resolvedAssetPath = $ this -> getAssetPathWithStrategyApplied ( $ strategy , $ assetPath ) ; $ output [ $ position ] [ ] = sprintf ( $ template , $ resolvedAssetPath ) ; } } } // Build the strings to output in the blades $ toBind = [ ] ; foreach ( ( array ) $ output as $ position => $ toOutput ) { $ toBind [ $ position ] = implode ( '' , $ toOutput ) ; } $ view -> with ( 'injectedAssets' , $ toBind ) ; }
Bind data to the view

@param View $view
@throws SharpInvalidAssetRenderStrategy
Bind data to the view