當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。