Skip to content

Component

Junaid Atari edited this page Aug 23, 2016 · 13 revisions

Required Parameters

component-id

string

An ID of the component, should be unique. A valid name contains [a-z][a-z-0-9]+.

// Example
'font-awesome' => [
    // ...
]

sections

array

Either js or css or whatever text given will be considered as component section.

// Example
'component-id' => [
    // ...
    'css' => [
		// ...
    ],
    // another section
    /*'js' => [
		// ...
    ],*/
]

Optional Properties

@src

string

URL to the source directory. If a component directory is icons/font-awesome under the cdn directory, you can set the @src property as icons/font-awesome.

Default is Cdn's basePath + component-id (e.g., /cdn/component-id)

// Example
'font-awesome' => [
    // ...
    '@src' => 'icons/font-awesome',
    // ...
]

@baseUrl

string

Base url to the component. This will override baseUrl property of Cdn component.

Default is Cdn's baseUrl + component-id (e.g., /cdn/component-id)

// Example
'component-id' => [
    // ...
    '@baseUrl' => 'http://domain.com',
    // ...
]

@attributes

array Pairs of key=>value.

Define the component attributes.

Default is []

// Example
'font-awesome' => [
    // ...
    '@attributes' => [
    	'foo' => 'bar',
    ],
    // ...
]
How to access attribute?
/** @var \yii2cdn\Component $comp */
$comp = \Yii::$app->cdn->get('font-awesome');

// Get attribute value
echo $comp->getAttr('attribute');
// output: value

// Update/Set attribute
echo $comp->setAttr('attribute', 'value');
// output: value

// Get all the attributes
print_r ( $comp->getAttributes() );

@offline

boolean

Use component as offline. Setting true will skip the component when YII2CDN_OFFLINE is set to false.

Default is false

// Example
'component-id' => [
    // ...
    '@offline' => true,
    // ...
]

@offlineSections

array

IDs of the sections consider as offline and will be skipped when YII2CDN_OFFLINE is set to false.

Default is []

// Example
'component-id' => [
    // ...
    '@offlineSections' => ['css', 'js'],
    // ...
]

Note: the red links below are pages yet to be created. Feel free to add them!

Overview documents

  • README: distributed with yii2cdn, contains a quick overview of yii2cdn's functionality, an example, and the license.
  • REFERENCE: Containing incomplete api class reference.

Quick Start

Configuration

Tutorials

Clone this wiki locally