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


PHP Table::getFieldsDefinitions方法代碼示例

本文整理匯總了PHP中Cake\ORM\Table::getFieldsDefinitions方法的典型用法代碼示例。如果您正苦於以下問題:PHP Table::getFieldsDefinitions方法的具體用法?PHP Table::getFieldsDefinitions怎麽用?PHP Table::getFieldsDefinitions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Cake\ORM\Table的用法示例。


在下文中一共展示了Table::getFieldsDefinitions方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _storeFileStorage

 /**
  * Store to FileStorage table.
  *
  * @param  object $docEntity Document entity
  * @param  string $field of the association
  * @param  array $fileData File data
  * @param  array $options for extra setup
  * @return object|bool Fresh created entity or false on unsuccesful attempts.
  */
 protected function _storeFileStorage($docEntity, $field, $fileData, $options = [])
 {
     $fieldsDefinitions = [];
     $fieldOption = [];
     $assocName = CsvMigrationsUtils::createAssociationName('Burzum/FileStorage.FileStorage', $field);
     $fileStorEnt = $this->_table->{$assocName}->newEntity($fileData);
     if (method_exists($this->_table, 'getFieldsDefinitions') && is_callable([$this->_table, 'getFieldsDefinitions'])) {
         $fieldsDefinitions = $this->_table->getFieldsDefinitions();
     }
     if (!empty($fieldsDefinitions)) {
         foreach ($fieldsDefinitions as $tableField => $definition) {
             if ($tableField == $field) {
                 $fieldOption = $definition;
                 break;
             }
         }
     }
     if (!empty($options['ajax'])) {
         //AJAX upload doesn't know anything about the entity
         //it relates to, as it's not saved yet
         $patchData = ['model' => $this->_table->table(), 'model_field' => $field];
     } else {
         $patchData = [$this->_fileStorageForeignKey => $docEntity->get('id'), 'model' => $this->_table->table(), 'model_field' => $field];
     }
     $fileStorEnt = $this->_table->{$assocName}->patchEntity($fileStorEnt, $patchData);
     if ($this->_table->{$assocName}->save($fileStorEnt)) {
         if (!empty($fieldOption) && $fieldOption['type'] == 'images') {
             $this->createThumbnails($fileStorEnt);
         }
         return $fileStorEnt;
     }
     return false;
 }
開發者ID:QoboLtd,項目名稱:cakephp-csv-migrations,代碼行數:42,代碼來源:FileUploadsUtils.php


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