src/Assetter/Assetter.php
public function loadFromArray(array $data)
    {
        list($data) = $this->fireEvent('load-from-array', [ $data ]);

        $files = [];

        if(isset($data['files']['js']) && is_array($data['files']['js']))
            $files['js'] = $this->resolveFilesList($data['files']['js'], isset($data['revision']) ? $data['revision'] : null);
        if(isset($data['files']['css']) && is_array($data['files']['css']))
            $files['css'] = $this->resolveFilesList($data['files']['css'], isset($data['revision']) ? $data['revision'] : null);

        $item = [
            'order'    => isset($data['order']) ? $data['order'] : 0,
            'name'     => isset($data['name']) ? $data['name'] : uniqid(),
            'files'    => $files,
            'group'    => isset($data['group']) ? $data['group'] : $this->defaultGroup,
            'require'  => isset($data['require']) ? $data['require'] : []
        ];

        if(isset($item['files']['js']) && is_array($item['files']['js']))
            $item['files']['js'] = $this->applyNamespaces($item['files']['js']);
        if(isset($item['files']['css']) && is_array($item['files']['css']))
            $item['files']['css'] = $this->applyNamespaces($item['files']['css']);

        $this->loaded[] = $item;

        if(isset($item['require']) && is_array($item['require']))
        {
            foreach($item['require'] as $name)
            {
                $this->loadFromCollection($name);
            }
        }

        return $this;
    }
public function loadFromArray(array $data)
    {
        list($data) = $this->fireEvent('load-from-array', [ $data ]);

        $files = [];

        if(isset($data['files']['js']) && is_array($data['files']['js']))
            $files['js'] = $this->resolveFilesList($data['files']['js'], isset($data['revision']) ? $data['revision'] : null);
        if(isset($data['files']['css']) && is_array($data['files']['css']))
            $files['css'] = $this->resolveFilesList($data['files']['css'], isset($data['revision']) ? $data['revision'] : null);

        $item = [
            'order'    => isset($data['order']) ? $data['order'] : 0,
            'name'     => isset($data['name']) ? $data['name'] : uniqid(),
            'files'    => $files,
            'group'    => isset($data['group']) ? $data['group'] : $this->defaultGroup,
            'require'  => isset($data['require']) ? $data['require'] : []
        ];

        if(isset($item['files']['js']) && is_array($item['files']['js']))
            $item['files']['js'] = $this->applyNamespaces($item['files']['js']);
        if(isset($item['files']['css']) && is_array($item['files']['css']))
            $item['files']['css'] = $this->applyNamespaces($item['files']['css']);

        $this->loaded[] = $item;

        if(isset($item['require']) && is_array($item['require']))
        {
            foreach($item['require'] as $name)
            {
                $this->loadFromCollection($name);
            }
        }

        return $this;
    }
public function loadFromArray ( array $ data ) { list ( $ data ) = $ this -> fireEvent ( 'load-from-array' , [ $ data ] ) ; $ files = [ ] ; if ( isset ( $ data [ 'files' ] [ 'js' ] ) && is_array ( $ data [ 'files' ] [ 'js' ] ) ) $ files [ 'js' ] = $ this -> resolveFilesList ( $ data [ 'files' ] [ 'js' ] , isset ( $ data [ 'revision' ] ) ? $ data [ 'revision' ] : null ) ; if ( isset ( $ data [ 'files' ] [ 'css' ] ) && is_array ( $ data [ 'files' ] [ 'css' ] ) ) $ files [ 'css' ] = $ this -> resolveFilesList ( $ data [ 'files' ] [ 'css' ] , isset ( $ data [ 'revision' ] ) ? $ data [ 'revision' ] : null ) ; $ item = [ 'order' => isset ( $ data [ 'order' ] ) ? $ data [ 'order' ] : 0 , 'name' => isset ( $ data [ 'name' ] ) ? $ data [ 'name' ] : uniqid ( ) , 'files' => $ files , 'group' => isset ( $ data [ 'group' ] ) ? $ data [ 'group' ] : $ this -> defaultGroup , 'require' => isset ( $ data [ 'require' ] ) ? $ data [ 'require' ] : [ ] ] ; if ( isset ( $ item [ 'files' ] [ 'js' ] ) && is_array ( $ item [ 'files' ] [ 'js' ] ) ) $ item [ 'files' ] [ 'js' ] = $ this -> applyNamespaces ( $ item [ 'files' ] [ 'js' ] ) ; if ( isset ( $ item [ 'files' ] [ 'css' ] ) && is_array ( $ item [ 'files' ] [ 'css' ] ) ) $ item [ 'files' ] [ 'css' ] = $ this -> applyNamespaces ( $ item [ 'files' ] [ 'css' ] ) ; $ this -> loaded [ ] = $ item ; if ( isset ( $ item [ 'require' ] ) && is_array ( $ item [ 'require' ] ) ) { foreach ( $ item [ 'require' ] as $ name ) { $ this -> loadFromCollection ( $ name ) ; } } return $ this ; }
Load asset by given array. Apply registered namespaces for all
files' paths.
@param  array  $item Asset data array.
@return self
Load asset by given array . Apply registered namespaces for all files paths .