-
Notifications
You must be signed in to change notification settings - Fork 2
Override default classes
Junaid Atari edited this page Aug 24, 2016
·
5 revisions
Info: This tutorial will demonstrate how to override default yii2cdn core classes.
- Cdn property:
$componentClass
- Default class:
\yii2cdn\Component
/** @var \yii2cdn\Component $component */
$component = \Yii::$app->cdn->get('component-id');
- Cdn property:
$sectionClass
- Default class:
\yii2cdn\Section
/** @var \yii2cdn\Section $section */
$section = $component->getSection('section-id');
- Cdn property:
$fileClass
- Default class:
\yii2cdn\File
/** @var \yii2cdn\File $file */
$file = $section->getFile('file-id');
- Cdn property:
$configParserClass
- Default class:
\yii2cdn\ConfigParser
- Cdn property:
$configFileClass
- Default class:
\yii2cdn\ConfigFile
- Cdn property:
$configLoaderClass
- Default class:
\yii2cdn\ConfigLoader
- Create a file
Component.php
under /common/yii2cdn/ directrory - Add the following code:
namespace common/yii2cdn;
class Component extends \yii2cdn\Component {
// Add your logic, override methods here...
}
- Open
@app/config/main.php
in your code editor. - Add a new propery
componentClass
inside thecdn
component like the following example:
// ...
'components' => [
// ...
'cdn' => [
'class' => '\yii2cdn\Cdn',
// Extended CDN component class
'componentClass' => '\common\yii2cdn\Component',
// ...
],
// ...
],
// ...
Copyright (c) 2016 Junaid Atari and it's contributes.