本文整理汇总了PHP中DataObjectInterface::canEdit方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObjectInterface::canEdit方法的具体用法?PHP DataObjectInterface::canEdit怎么用?PHP DataObjectInterface::canEdit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataObjectInterface
的用法示例。
在下文中一共展示了DataObjectInterface::canEdit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addRecord
public function addRecord(DataObjectInterface $record, $parentFields = null)
{
$fields = null;
if (!$record->canEdit()) {
return;
}
$this->records->push($record);
if (method_exists($record, 'multiEditor')) {
$editor = $record->multiEditor();
// add its records to 'me'
$this->addMultiEditor($editor, $record, true);
return;
} elseif (method_exists($record, 'multiEditFields')) {
$fields = $record->multiEditFields();
} else {
$fields = $record->getCMSFields();
}
/* @var $fields FieldList */
$record->extend('updateMultiEditFields', $fields);
// we just want the data fields, not wrappers
$fields = $fields->dataFields();
if (!count($fields)) {
return;
}
$status = $record->CMSPublishedState;
if ($status) {
$status = ' (' . $status . ')';
}
$tab = ToggleCompositeField::create('CompositeHeader' . $record->ID, $record->Title . $status, null);
if ($parentFields) {
$parentFields->push($tab);
} else {
$tab->setStartClosed(false);
$this->tabs->push($tab);
}
// if we're not using toggles, we only add the header _if_ we're an inner item, ie $parentFields != null
if ($parentFields) {
$this->children->push(HeaderField::create('RecordHeader' . $record->ID, $record->Title . $status));
}
foreach ($fields as $field) {
$original = $field->getName();
// if it looks like a multieditor field, let's skip for now.
if (strpos($original, '__') > 0) {
continue;
}
if ($field instanceof MultiRecordEditingField) {
$this->addMultiEditor($field, $record, false, $tab);
continue;
}
$exists = isset($record->{$original}) || $record->hasMethod($original) || $record->hasMethod('hasField') && $record->hasField($original);
$val = null;
if ($exists) {
$val = $record->__get($original);
}
$field->setValue($val, $record);
// tweak HTMLEditorFields so they're not huge
if ($this->htmlEditorHeight && $field instanceof HtmlEditorField) {
$field->setRows($this->htmlEditorHeight);
}
// re-write the name to the multirecordediting name for later retrieval.
// this cannot be done earlier as otherwise, fields that load data from the
// record won't be able to find the information they're expecting
$name = $this->getFieldName($field, $record);
$field->setName($name);
if (method_exists($field, 'setRecord')) {
$field->setRecord($record);
}
if ($tab) {
$tab->push($field);
}
$this->children->push($field);
}
}
开发者ID:helpfulrobot,项目名称:nyeholt-silverstripe-multirecordeditor,代码行数:73,代码来源:MultiRecordEditingField.php