本文整理汇总了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;
}