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


PHP Table::hasBehavior方法代码示例

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


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

示例1: checkTable

 /**
  * Do some checks on the table which has been passed to make sure that it has what we need
  *
  * @param string $table The table
  * @return void
  */
 protected function checkTable($table)
 {
     try {
         $this->Table = $this->loadModel($table);
     } catch (Exception $e) {
         $this->out(__('<error>' . $e->getMessage() . '</error>'));
         exit;
     }
     if (get_class($this->Table) === 'AppModel') {
         $this->out(__('<error>The table could not be found, instance of AppModel loaded.</error>'));
         exit;
     }
     if (!$this->Table->hasBehavior('Proffer')) {
         $out = __("<error>The table '" . $this->Table->alias() . "' does not have the Proffer behavior attached.</error>");
         $this->out($out);
         exit;
     }
     $config = $this->Table->behaviors()->Proffer->config();
     foreach ($config as $field => $settings) {
         if (!$this->Table->hasField($field)) {
             $out = __("<error>The table '" . $this->Table->alias() . "' does not have the configured upload field in it's schema.</error>");
             $this->out($out);
             exit;
         }
         if (!$this->Table->hasField($settings['dir'])) {
             $out = __("<error>The table '" . $this->Table->alias() . "' does not have the configured dir field in it's schema.</error>");
             $this->out($out);
             exit;
         }
     }
 }
开发者ID:rohanpande,项目名称:CakePHP3-Proffer,代码行数:37,代码来源:ProfferShell.php

示例2: 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


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