Overview
  • Namespace
  • Class

Namespaces

  • yii2cdn

Classes

  • Cdn
  • Component
  • ConfigFile
  • ConfigLoader
  • ConfigParser
  • File
  • Section

Class Cdn

Yii2 CDN Component

yii\base\Component
Extended by yii2cdn\Cdn
Namespace: yii2cdn
Package: yii2cdn
Author: Junaid Atari mj.atari@gmail.com
Version: 0.1
Located at src/Cdn.php

Methods summary

public
# init( )

Component intializer

Component intializer

Throws

yii\base\InvalidConfigException
when property is empty
protected yii2cdn\ConfigFile
# getFileConfigObject( string $file = null )

Get a ConfigFile Object

Get a ConfigFile Object

Parameters

$file

Returns

yii2cdn\ConfigFile
protected
# loadComponents( array $config )

Import components from configuration array

Import components from configuration array

Parameters

$config
Components configuration
protected
# loadComponentsFile( string $path )

Import components from configuration file

Import components from configuration file

Parameters

$path
Components configuration file path
protected
# buildComponentsCache( )

Build a components list

Build a components list

public
# refresh( )

Remove the cache and rebuild components list

Remove the cache and rebuild components list

public static boolean
# isOnline( )

Check that Mode Live or Offline

Check that Mode Live or Offline

Returns

boolean
public yii2cdn\Component|null
# get( string $id, $throwException = true )

Get cdn component by ID

Get cdn component by ID

Parameters

$id
Component ID
$throwException

Returns

yii2cdn\Component|null
Component Object

See

yii2cdn\Cdn::exists()
public boolean
# exists( string $id, boolean $throwException = true )

Check that cdn component exists

Check that cdn component exists

Parameters

$id
Component ID
$throwException
(optional) Throw exception when unknown component id given (default: false)

Returns

boolean
True when exist, False when undefined

Throws

yii\base\UnknownPropertyException
When unknown component id given
public yii2cdn\Section
# getSectionByRoot( string $root, boolean $throwException = true )

Get the file by root Root example : component-id/section

Get the file by root Root example : component-id/section

Parameters

$root
Root to file
$throwException
True will throw exception (default: true)

Returns

yii2cdn\Section
Section Object

Throws

yii\base\UnknownPropertyException
When unknown component id given
yii\base\InvalidParamException
When null given as section
yii\base\UnknownPropertyException
When section name not found

See

Component::get()
Section::getSection()
public yii2cdn\File|string|null
# getFileByRoot( string $root, boolean $asUrl = false, boolean $throwException = true )

Get the file by root Root example : component-id/section/file-id

Get the file by root Root example : component-id/section/file-id

Parameters

$root
Root to file
$asUrl
True will return file url instead of object (default: false)
$throwException
True will throw exception (default: true)

Returns

yii2cdn\File|string|null
Section file | File Url | Null when not found

Throws

yii\base\UnknownPropertyException
When unknown component id given
yii\base\InvalidParamException
When null given as section
yii\base\UnknownPropertyException
When section name not found
yii\base\UnknownPropertyException
When file id not found

See

Component::get()
Section::getSection()
yii2cdn\Section::getFileById()
public yii2cdn\Cdn
# whenOffline( callable $callback, string $property = 'cdn' )

Perform a callback function when Offline mode is active

Perform a callback function when Offline mode is active

Parameters

$callback

A callback function

function ( \yii2cdn\Cdn $cdn ) {
        // some logic here
    }
$property
(optional) Default component property name (default: cdn)

Returns

yii2cdn\Cdn

Throws

yii\base\InvalidConfigException
When the callback parameter is not a function

See

yii2cdn\Cdn::isOnline()
public yii2cdn\Cdn
# whenOnline( callable $callback, string $property = 'cdn' )

Perform a callback function when Online mode is active

Perform a callback function when Online mode is active

Parameters

$callback

A callback function

function ( \yii2cdn\Cdn $cdn ) {
        // some logic here
    }
$property
(optional) Default component property name (default: cdn)

Returns

yii2cdn\Cdn

Throws

yii\base\InvalidConfigException
When the callback parameter is not a function

See

yii2cdn\Cdn::isOnline()

Properties summary

public string $baseUrl

Base url to cdn directory

Base url to cdn directory

# null
public string $basePath

base path to cdn directory

base path to cdn directory

# null
public array $aliases

Custom url aliases, replaces with @alias(*) in files url Usage: ['xyz' => '/url/to', ...]

Custom url aliases, replaces with @alias(*) in files url Usage: ['xyz' => '/url/to', ...]

# []
public string $componentClass

CDN component class default: \yii2cdn\Component

CDN component class default: \yii2cdn\Component

# '\yii2cdn\Component'
public string $configParserClass

CDN components configuration parser class default: \yii2cdn\ComponentConfigParser

CDN components configuration parser class default: \yii2cdn\ComponentConfigParser

# '\yii2cdn\ConfigParser'
public string $sectionClass

CDN component section class default: \yii2cdn\ComponentSection

CDN component section class default: \yii2cdn\ComponentSection

# '\yii2cdn\Section'
public string $configFileClass

CDN Configuration File Class default: \yii2cdn\ConfigFile

CDN Configuration File Class default: \yii2cdn\ConfigFile

# '\yii2cdn\ConfigFile'
public string $fileClass

CDN component section file class default: \yii2cdn\SectionFile

CDN component section file class default: \yii2cdn\SectionFile

# '\yii2cdn\File'
public string $configLoaderClass

CDN component configuration loader class default: \yii2cdn\ConfigLoader

CDN component configuration loader class default: \yii2cdn\ConfigLoader

# '\yii2cdn\ConfigLoader'
public array $configs

CDN components configuration files list Usage: 1. 'path/to/cdn-config.php' : main file path 2. ['path/to/cdn-config.php'] : main file path 3. ['path/to/cdn-config.php', 'offline'=>false] : online cdn file path 4. ['path/to/cdn-config.php', 'offline'=>true] : offline cdn file path

CDN components configuration files list Usage: 1. 'path/to/cdn-config.php' : main file path 2. ['path/to/cdn-config.php'] : main file path 3. ['path/to/cdn-config.php', 'offline'=>false] : online cdn file path 4. ['path/to/cdn-config.php', 'offline'=>true] : offline cdn file path

# []
public array $components

CDN components configuration

CDN components configuration

# []
public array $sections

Sections name list default: (

css

,

js

)

Sections name list default: (

css

,

js

)

# ['js', 'css']
public string $cacheKey

Cache Key for caching built components configuration to load fast

Cache Key for caching built components configuration to load fast

# null
public boolean $enableCaching

Enable storing components configuration in cache

Enable storing components configuration in cache

# false
protected array $_regComponents

Components registered under cdn

Components registered under cdn

# []
API documentation generated by ApiGen