本文整理匯總了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;
}