src/View/Helper/Traits/IncludeTrait.php
protected function _include($path, array $options = [], $type = 'css')
    {
        $doc = $this->Document;
        $options += ['once' => true, 'block' => null, 'fullBase' => true, 'weight' => 10];
        $external = false;

        $assetArray = $this->_arrayInclude($path, $options, $type);
        if ($assetArray) {
            return $assetArray;
        }

        $path = $this->_getCurrentPath($path, $assetArray);
        if (empty($path)) {
            return null;
        }

        $options += ['alias' => Str::slug($path)];
        list($url, $options, $external) = $this->_getCurrentUrlAndOptions($path, $options, $type, $external);

        if (($this->_isOnceIncluded($path, $type, $options)) || $this->_hasAsset($path, $type, $external)) {
            return null;
        }

        unset($options['once']);
        $this->_includedAssets[$type][$path] = true;

        $out = $this->_getTypeOutput($options, $url, $type);

        $options['alias'] = Str::low($options['alias']);
        if ($options['block'] === 'assets') {
            $this->_assets[$type][$options['alias']] = [
                'url'    => $url,
                'output' => $out,
                'path'   => $path,
                'weight' => $options['weight'],
            ];

            return null;
        }

        if (empty($options['block'])) {
            return $out;
        }

        $options = $this->_setFetchBlock($options, $type);
        $this->_View->append($options['block'], $out . $doc->eol);
    }
protected function _include($path, array $options = [], $type = 'css')
    {
        $doc = $this->Document;
        $options += ['once' => true, 'block' => null, 'fullBase' => true, 'weight' => 10];
        $external = false;

        $assetArray = $this->_arrayInclude($path, $options, $type);
        if ($assetArray) {
            return $assetArray;
        }

        $path = $this->_getCurrentPath($path, $assetArray);
        if (empty($path)) {
            return null;
        }

        $options += ['alias' => Str::slug($path)];
        list($url, $options, $external) = $this->_getCurrentUrlAndOptions($path, $options, $type, $external);

        if (($this->_isOnceIncluded($path, $type, $options)) || $this->_hasAsset($path, $type, $external)) {
            return null;
        }

        unset($options['once']);
        $this->_includedAssets[$type][$path] = true;

        $out = $this->_getTypeOutput($options, $url, $type);

        $options['alias'] = Str::low($options['alias']);
        if ($options['block'] === 'assets') {
            $this->_assets[$type][$options['alias']] = [
                'url'    => $url,
                'output' => $out,
                'path'   => $path,
                'weight' => $options['weight'],
            ];

            return null;
        }

        if (empty($options['block'])) {
            return $out;
        }

        $options = $this->_setFetchBlock($options, $type);
        $this->_View->append($options['block'], $out . $doc->eol);
    }
protected function _include ( $ path , array $ options = [ ] , $ type = 'css' ) { $ doc = $ this -> Document ; $ options += [ 'once' => true , 'block' => null , 'fullBase' => true , 'weight' => 10 ] ; $ external = false ; $ assetArray = $ this -> _arrayInclude ( $ path , $ options , $ type ) ; if ( $ assetArray ) { return $ assetArray ; } $ path = $ this -> _getCurrentPath ( $ path , $ assetArray ) ; if ( empty ( $ path ) ) { return null ; } $ options += [ 'alias' => Str :: slug ( $ path ) ] ; list ( $ url , $ options , $ external ) = $ this -> _getCurrentUrlAndOptions ( $ path , $ options , $ type , $ external ) ; if ( ( $ this -> _isOnceIncluded ( $ path , $ type , $ options ) ) || $ this -> _hasAsset ( $ path , $ type , $ external ) ) { return null ; } unset ( $ options [ 'once' ] ) ; $ this -> _includedAssets [ $ type ] [ $ path ] = true ; $ out = $ this -> _getTypeOutput ( $ options , $ url , $ type ) ; $ options [ 'alias' ] = Str :: low ( $ options [ 'alias' ] ) ; if ( $ options [ 'block' ] === 'assets' ) { $ this -> _assets [ $ type ] [ $ options [ 'alias' ] ] = [ 'url' => $ url , 'output' => $ out , 'path' => $ path , 'weight' => $ options [ 'weight' ] , ] ; return null ; } if ( empty ( $ options [ 'block' ] ) ) { return $ out ; } $ options = $ this -> _setFetchBlock ( $ options , $ type ) ; $ this -> _View -> append ( $ options [ 'block' ] , $ out . $ doc -> eol ) ; }
Include asset.

@param string|array $path
@param array $options
@param string $type
@return bool|null|string
Include asset .