當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ActiveRecord::attachBehavior方法代碼示例

本文整理匯總了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');
 }
開發者ID:felixmaier1989,項目名稱:yii2-renderdual,代碼行數:10,代碼來源:RenderDualTest.php

示例2: setUp

 public function setUp()
 {
     $this->mock = $this->getMock(ActiveRecord::class, ['save', 'hasAttribute', 'getIsNewRecord', 'setAttribute']);
     $this->mock->attachBehavior('bl', ['class' => BlameableBehavior::class]);
 }
開發者ID:opus-online,項目名稱:yii2-base,代碼行數:5,代碼來源:BlameableBehaviorTest.php

示例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']);
 }
開發者ID:opus-online,項目名稱:yii2-base,代碼行數:5,代碼來源:TimestampBehaviorTest.php

示例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);
         }
     }
 }
開發者ID:thinker-g,項目名稱:yii2-hermes-mailing,代碼行數:18,代碼來源:DefaultController.php

示例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;
 }
開發者ID:vladdnepr,項目名稱:yii2-ycm,代碼行數:7,代碼來源:Module.php

示例6: setUp

 public function setUp()
 {
     $this->mock = $this->getMock(ActiveRecord::class, ['save', 'validate']);
     $this->mock->attachBehavior('safeSaver', SafeSaverBehaviour::class);
 }
開發者ID:opus-online,項目名稱:yii2-base,代碼行數:5,代碼來源:SafeSaverBehaviourTest.php


注:本文中的yii\db\ActiveRecord::attachBehavior方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。