本文整理汇总了PHP中DataObject::hasField方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObject::hasField方法的具体用法?PHP DataObject::hasField怎么用?PHP DataObject::hasField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataObject
的用法示例。
在下文中一共展示了DataObject::hasField方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scaffoldFormField
public function scaffoldFormField($title = null, $params = null)
{
$titleField = $this->object->hasField('Title') ? 'Title' : 'Name';
$map = DataList::create(get_class($this->object))->map('ID', $titleField);
$field = new DropdownField($this->name, $title, $map);
$field->setEmptyString(' ');
return $field;
}
示例2: getExtraSavedData
/**
* Get the list of extra data from the $record as saved into it by
* {@see Form::saveInto()}
*
* Handles detection of falsey values explicitly saved into the
* DataObject by formfields
*
* @param DataObject $record
* @param SS_List $list
* @return array List of data to write to the relation
*/
protected function getExtraSavedData($record, $list)
{
// Skip extra data if not ManyManyList
if (!$list instanceof ManyManyList) {
return null;
}
$data = array();
foreach ($list->getExtraFields() as $field => $dbSpec) {
$savedField = "ManyMany[{$field}]";
if ($record->hasField($savedField)) {
$data[$field] = $record->getField($savedField);
}
}
return $data;
}
示例3: getWriterFor
/**
* Gets a writer for a DataObject
*
* If the field already has a value, a writer is created matching that
* identifier. Otherwise, a new writer is created based on either
*
* - The $type passed in
* - whether the $object class specifies a prefered storage type via
* getEffectiveContentStore
* - what the `defaultStore` is set to for the content service
*
*
* @param DataObject $object
* The object to get a writer for
* @param String $field
* The field being written to
* @param String $type
* Explicitly state what the content store type will be
* @return ContentWriter
*/
public function getWriterFor(DataObject $object = null, $field = 'FilePointer', $type = null)
{
if ($object && $field && $object->hasField($field)) {
$val = $object->{$field};
if (strlen($val)) {
$reader = $this->getReader($val);
if ($reader && $reader->isReadable()) {
return $reader->getWriter();
}
}
}
if (!$type) {
// specifically expecting to be handling File objects, but allows other
// objects to play too
if ($object && $object->hasMethod('getEffectiveContentStore')) {
$type = $object->getEffectiveContentStore();
} else {
$type = $this->defaultStore;
}
}
// looks like we're getting a writer with no underlying file (as yet)
return $this->getWriter($type);
}
示例4: getFieldsForObj
/**
* Returns all fields on the object which should be shown
* in the output. Can be customised through {@link self::setCustomFields()}.
*
* @todo Allow for custom getters on the processed object (currently filtered through inheritedDatabaseFields)
* @todo Field level permission checks
*
* @param DataObject $obj
* @return array
*/
protected function getFieldsForObj($obj) {
$dbFields = array();
// if custom fields are specified, only select these
if(is_array($this->customFields)) {
foreach($this->customFields as $fieldName) {
// @todo Possible security risk by making methods accessible - implement field-level security
if($obj->hasField($fieldName) || $obj->hasMethod("get{$fieldName}")) $dbFields[$fieldName] = $fieldName;
}
} else {
// by default, all database fields are selected
$dbFields = $obj->inheritedDatabaseFields();
}
if(is_array($this->customAddFields)) {
foreach($this->customAddFields as $fieldName) {
// @todo Possible security risk by making methods accessible - implement field-level security
if($obj->hasField($fieldName) || $obj->hasMethod("get{$fieldName}")) $dbFields[$fieldName] = $fieldName;
}
}
// add default required fields
$dbFields = array_merge($dbFields, array('ID'=>'Int'));
// @todo Requires PHP 5.1+
if(is_array($this->removeFields)) {
$dbFields = array_diff_key($dbFields, array_combine($this->removeFields,$this->removeFields));
}
return $dbFields;
}
示例5: scaffoldFormField
public function scaffoldFormField($title = null, $params = null) {
$titleField = ($this->object->hasField('Title')) ? "Title" : "Name";
$map = DataList::create(get_class($this->object))->map("ID", $titleField);
return new DropdownField($this->name, $title, $map, null, null, ' ');
}
示例6: scaffoldFormField
public function scaffoldFormField($title = null, $params = null) {
$titleField = ($this->object->hasField('Title')) ? "Title" : "Name";
$map = new SQLMap($this->object->extendedSQL(), "ID", $titleField);
return new DropdownField($this->name, $title, $map, null, null, ' ');
}
示例7: saveInto
/**
* @desc
*/
function saveInto(DataObject $record)
{
$fieldname = $this->name;
if ($fieldname && $record && ($record->has_many($fieldname) || $record->many_many($fieldname))) {
$record->{$fieldname}()->setByIDList($this->value);
} else {
if ($fieldname && $record && $record->hasField($fieldname)) {
if ($this->value) {
$this->value = str_replace(",", "{comma}", $this->value);
$record->{$fieldname} = implode(",", $this->value);
} else {
$record->{$fieldname} = '';
}
}
}
}