本文整理汇总了PHP中yii\db\ActiveRecord::attachBehavior方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::attachBehavior方法的具体用法?PHP ActiveRecord::attachBehavior怎么用?PHP ActiveRecord::attachBehavior使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\db\ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::attachBehavior方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRenderDualNotController
/**
* @test
*/
public function testRenderDualNotController()
{
$controller = new \yii\db\ActiveRecord();
$controller->attachBehavior('RenderDual', new \yii2renderdual\RenderDual());
$this->setExpectedException('Exception');
$render = $controller->renderDual('view', ['foo' => 'bar'], 'foo bar');
}
示例2: setUp
public function setUp()
{
$this->mock = $this->getMock(ActiveRecord::class, ['save', 'hasAttribute', 'getIsNewRecord', 'setAttribute']);
$this->mock->attachBehavior('bl', ['class' => BlameableBehavior::class]);
}
示例3: setUp
public function setUp()
{
$this->mock = $this->getMock(ActiveRecord::class, ['save', 'hasAttribute', 'getIsNewRecord', 'setAttribute']);
$this->mock->attachBehavior('ts', ['class' => TimestampBehavior::class, 'createdAtAttribute' => 'cr', 'updatedAtAttribute' => 'up']);
}
示例4: sendSigned
/**
* Send currently signed emails.
*/
protected function sendSigned()
{
while ($fetchedMails = $this->findMailBySignature($this->pageSize)) {
foreach ($fetchedMails as $this->_fetchedMail) {
if ($this->sentByBehavior) {
$this->_fetchedMail->attachBehavior($this->sentByBehavior->className(), $this->sentByBehavior);
}
$msg = $this->assembleMailMessage($this->_fetchedMail);
$isSent = $this->testMode ? rand(0, 1) : $this->getMailer()->send($msg);
$this->processEmailStatus($this->_fetchedMail, $isSent);
$this->_fetchedMail->save(false);
$this->{$this->useLiteAntiSpams ? "applySpamRulesLite" : "applySpamRules"}(++$this->_sentCount);
}
}
}
示例5: attachBehaviorsToModel
public function attachBehaviorsToModel(ActiveRecord $model)
{
$model->attachBehavior('datetimepicker', \vladdnepr\ycm\behaviors\DatePickerBehavior::className());
$model->attachBehavior('relationsseter', \vladdnepr\ycm\behaviors\RelationsBehavior::className());
$model->attachBehavior('multilang', \vladdnepr\ycm\behaviors\MultilangBehavior::className());
return $model;
}
示例6: setUp
public function setUp()
{
$this->mock = $this->getMock(ActiveRecord::class, ['save', 'validate']);
$this->mock->attachBehavior('safeSaver', SafeSaverBehaviour::class);
}