当前位置: 首页>>代码示例>>PHP>>正文


PHP Table::addBehavior方法代码示例

本文整理汇总了PHP中Cake\ORM\Table::addBehavior方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::addBehavior方法的具体用法?PHP Table::addBehavior怎么用?PHP Table::addBehavior使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\ORM\Table的用法示例。


在下文中一共展示了Table::addBehavior方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCamposEmArray

 /**
  * testCamposEmArray
  *
  * @retun  void
  * @access public
  */
 public function testCamposEmArray()
 {
     $this->Noticias->addBehavior("CakePtbr.AjusteData", ["autorizado_em", "publicado_em"]);
     $noticia = $this->__preparaNoticia("25/03/15 16:42:05");
     $this->assertEquals("2015-03-22", $noticia->get("autorizado_em"));
     $this->assertEquals("2015-03-25 16:42:05", $noticia->get("publicado_em"));
 }
开发者ID:matheusviegas,项目名称:cake_ptbr,代码行数:13,代码来源:AjusteDataBehaviorTest.php

示例2: setUp

 public function setUp()
 {
     parent::setUp();
     $this->entityMap = ['Authors' => Author::class, 'Users' => User::class, 'Editors' => Editor::class, 'Readers' => Reader::class, 'Subscribers' => Reader::class, '' => User::class];
     $this->table = TableRegistry::get('Users');
     $this->table->entityClass(User::class);
     $authors = TableRegistry::get('Authors', ['table' => 'users']);
     $editors = TableRegistry::get('Editors', ['table' => 'users']);
     $readers = TableRegistry::get('Readers', ['table' => 'users']);
     $authors->addBehavior('Robotusers/TableInheritance.Sti');
     $editors->addBehavior('Robotusers/TableInheritance.Sti');
     $readers->addBehavior('Robotusers/TableInheritance.Sti');
     $this->table->addBehavior('Robotusers/TableInheritance.StiParent', ['discriminatorMap' => ['Authors' => 'Authors', 'Editors' => 'Editors'], 'tableMap' => ['Readers' => ['Readers', 'Subscribers']]]);
     $authors->entityClass(Author::class);
     $editors->entityClass(Editor::class);
     $readers->entityClass(Reader::class);
 }
开发者ID:robotusers,项目名称:cakephp-table-inheritance,代码行数:17,代码来源:StiParentBehaviorTest.php

示例3: loadUserBehaviour

 /**
  * Loads the User behavior for the user model if it is not already loaded
  *
  * @return void
  */
 public function loadUserBehaviour()
 {
     if ($this->_config['autoloadBehavior'] && !$this->UserTable->hasBehavior('UserTools.User')) {
         if (is_array($this->_config['autoloadBehavior'])) {
             $this->UserTable->addBehavior('Burzum/UserTools.User', $this->_config['autoloadBehavior']);
         } else {
             $this->UserTable->addBehavior('Burzum/UserTools.User');
         }
     }
 }
开发者ID:nielin,项目名称:cakephp-user-tools,代码行数:15,代码来源:UserToolComponent.php

示例4: setUp

 /**
  * Initial Tree
  *
  * - One
  * -- One-SubA
  * - Two
  * -- Two-SubA
  * --- Two-SubA-1
  * ---- Two-SubA-1-1
  * - Three
  * - Four
  * -- Four-SubA
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->Tree = new TreeHelper(new View(null));
     $this->Table = TableRegistry::get('AfterTrees');
     $this->Table->addBehavior('Tree');
     //$this->Table->truncate();
     $connection = ConnectionManager::get('test');
     $sql = $this->Table->schema()->truncateSql($connection);
     foreach ($sql as $snippet) {
         $connection->execute($snippet);
     }
     //$this->Table->deleteAll(array());
     $data = [['name' => 'One'], ['name' => 'Two'], ['name' => 'Three'], ['name' => 'Four'], ['name' => 'One-SubA', 'parent_id' => 1], ['name' => 'Two-SubA', 'parent_id' => 2], ['name' => 'Four-SubA', 'parent_id' => 4], ['name' => 'Two-SubA-1', 'parent_id' => 6], ['name' => 'Two-SubA-1-1', 'parent_id' => 8]];
     foreach ($data as $row) {
         $row = new Entity($row);
         $this->Table->save($row);
     }
 }
开发者ID:alescx,项目名称:cakephp-tools,代码行数:34,代码来源:TreeHelperTest.php

示例5: testAddBehaviorDuplicate

 /**
  * Test adding a behavior that is a duplicate.
  *
  * @return void
  */
 public function testAddBehaviorDuplicate()
 {
     $table = new Table(['table' => 'articles']);
     $this->assertNull($table->addBehavior('Sluggable', ['test' => 'value']));
     $this->assertNull($table->addBehavior('Sluggable', ['test' => 'value']));
     try {
         $table->addBehavior('Sluggable', ['thing' => 'thing']);
         $this->fail('No exception raised');
     } catch (\RuntimeException $e) {
         $this->assertContains('The "Sluggable" alias has already been loaded', $e->getMessage());
     }
 }
开发者ID:jdaosavanh,项目名称:clickerwebapp,代码行数:17,代码来源:TableTest.php

示例6: _loadBehavior

 /**
  * Loads the purifier behavior for the given table if not already attached.
  *
  * @param \Cake\ORM\Table $table Table object.
  * @param array Set of fields to sanitize
  * @return void
  */
 protected function _loadBehavior(Table $table, $fields)
 {
     if (!in_array('HtmlPurifier', $table->behaviors()->loaded())) {
         $table->addBehavior('Burzum/HtmlPurifier.HtmlPurifier', ['fields' => $fields, 'purifierConfig' => $this->param('config')]);
     }
 }
开发者ID:burzum,项目名称:cakephp-html-purifier,代码行数:13,代码来源:PurifierShell.php

示例7: setUp

 /**
  * startTest
  *
  * @retun void
  * @access public
  */
 public function setUp()
 {
     $this->Produtos = TableRegistry::get('CakePtbr.Produtos');
     $this->Produtos->addBehavior("CakePtbr.AjusteFloat");
 }
开发者ID:matheusviegas,项目名称:cake_ptbr,代码行数:11,代码来源:AjusteFloatBehaviorTest.php

示例8: setUp

 /**
  * setUp().
  *
  * @return void
  */
 public function setUp()
 {
     $this->table = TableRegistry::get('Dummy');
     $this->table->addBehavior('Eav.Eav');
 }
开发者ID:quickapps-plugins,项目名称:eav,代码行数:10,代码来源:EavBehaviorTest.php

示例9: testAddBehavior

 /**
  * Test adding a behavior to a table.
  *
  * @return void
  */
 public function testAddBehavior()
 {
     $mock = $this->getMock('Cake\\ORM\\BehaviorRegistry', [], [], '', false);
     $mock->expects($this->once())->method('load')->with('Sluggable');
     $table = new Table(['table' => 'articles', 'behaviors' => $mock]);
     $table->addBehavior('Sluggable');
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:12,代码来源:TableTest.php


注:本文中的Cake\ORM\Table::addBehavior方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。