本文整理匯總了PHP中yii\base\Application::attachBehaviors方法的典型用法代碼示例。如果您正苦於以下問題:PHP Application::attachBehaviors方法的具體用法?PHP Application::attachBehaviors怎麽用?PHP Application::attachBehaviors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類yii\base\Application
的用法示例。
在下文中一共展示了Application::attachBehaviors方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: initialize
/**
*
* @param \yii\base\Application $app
* @param array $config
*/
protected function initialize($app, $config)
{
if ($app instanceof \yii\web\Application) {
$app->attachBehaviors([PriceHook::className() => PriceHook::className(), StockHook::className() => StockHook::className()]);
if (ArrayHelper::getValue($config, 'attach_user_behavior', true)) {
$this->attachUserProperty($app->getUser());
}
}
}
示例2: bootstrap
/**
* Initialize application before process request
* @param \yii\base\Application $app
*/
public function bootstrap($app)
{
$definitions = (require __DIR__ . '/definitions.php');
foreach ($definitions as $name => $definition) {
Yii::$container->set($name, $definition);
}
$hooks = (require __DIR__ . '/hooks.php');
$app->attachBehaviors(array_combine($hooks, $hooks));
}
示例3: bootstrap
/**
*
* @param \yii\base\Application $app
*/
public function bootstrap($app)
{
$app->attachBehaviors([GlHook::className() => GlHook::className(), InvoiceHook::className() => InvoiceHook::className()]);
}
示例4: bootstrap
/**
*
* @param \yii\base\Application $app
*/
public function bootstrap($app)
{
$app->attachBehaviors([CogsHook::className(), PriceHook::className(), StockHook::className()]);
}