public
|
#
__construct( array $config )
ComponentSection constructor.
ComponentSection constructor.
Parameters
- $config
- Configuration object
|
public
string
|
#
getName( )
Get section name
Returns
string
|
public
yii2cdn\Component |string
|
#
getComponent( boolean $asId = false, string $property = 'cdn' )
Get section's component or id
Get section's component or id
Parameters
- $asId
- (optional) True will return component id (default: false)
- $property
- (optional) Property name of
cdn defined in @app/config/main.php (default: 'cdn')
Returns
|
public
string|array
|
#
getUrl( null|string|array $str = null )
Get the section's base Url
Get the section's base Url
Parameters
- $str
- (optional) Append string at end of url (/ is optional) | List of strings to append url with (default: null)
Returns
string|array
|
public
yii2cdn\File[] |array
|
#
callback( callable $callback, array $options = [ ], boolean $throwException = true )
Perform a callback on each file and get the filtered files
Perform a callback on each file and get the filtered files
Parameters
- $callback
Perform a callback on each file
function (string &$fileUrl, string &$fileId, boolean $excluded, boolean $included ) {
}
- $options
(optional) Addition options pass to function
Options are:
> boolean listOnly : Returning the files url list only (default: false)
> boolean noIds : Returning the list without file ids (default: false)
> boolean unique : True will return only unique files (default: true)
> array excluded : List of Files id to be skipped (default: [])
> array includeOnly : List of Files id to be included, other will be skipped (default: [])
- $throwException
- (optional) True will throw exception (default: true)
Returns
yii2cdn\File[] |array List of files | List of sections and their files [SECTION=>FILES_LIST][]
Throws
yii\base\InvalidParamException Option 'callback' not a function
yii\base\InvalidConfigException When option 'excluded' not an array
yii\base\InvalidConfigException When option 'includeOnly' not an array
|
public
yii2cdn\File[] |array
|
#
getFiles( boolean $asArray = false, boolean $unique = false )
Get section files list
Parameters
- $asArray
- True will return files list only (default: false)
- $unique
- (optional) True will remove duplicate elements (default: false)
Returns
yii2cdn\File[] |array List of section object/[key=>value] pair of section files
|
public
yii2cdn\File |string|null
|
#
getFileById( string $id, boolean $usUrl = false, boolean $throwException = true )
Get the file by ID
Parameters
- $id
- File ID
- $usUrl
- True will return file url instead of object (default: false)
- $throwException
- True will throw exception when file id not found (default: true)
Returns
yii2cdn\File |string|null Section file | File Url | Null when not found
Throws
yii\base\UnknownPropertyException When file id not found
|
public
|
#
registerFilesAs( string $type, array|null $list, array $options = [], callable $callback = null )
Register list of files/files object into current view by type
Register list of files/files object into current view by type
Parameters
- $type
- Register files as (e.g., js|css)
- $list
- List of File[] array | simple list | Include all files
- $options
- (optional) Additional options pass to file while registering files
- $callback
(optional) Perform callback on each registering file
function (string &$fileUrl, string &$fileId, boolean $excluded, boolean $included ) {
}
|