本文整理汇总了PHP中SS_List::dataClass方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_List::dataClass方法的具体用法?PHP SS_List::dataClass怎么用?PHP SS_List::dataClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SS_List
的用法示例。
在下文中一共展示了SS_List::dataClass方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Usage [e.g. in getCMSFields]
* $field = new PickerField('Authors', 'Selected Authors', $this->Authors(), 'Select Author(s)');
*
* @param string $name - Name of field (typically the relationship method)
* @param string $title - GridField Title
* @param SS_List $dataList - Result of the relationship component method (E.g. $this->Authors())
* @param string $linkExistingTitle - AddExisting Button Title
* @param string $sortField - Field to sort on. Be sure it exists in the $many_many_extraFields static
*/
public function __construct($name, $title = null, SS_List $dataList = null, $linkExistingTitle = null, $sortField = null)
{
$config = GridfieldConfig::create()->addComponents(new GridFieldButtonRow('before'), new GridFieldToolbarHeader(), new GridFieldDataColumns(), new GridFieldTitleHeader(), new GridFieldPaginator(), new PickerFieldAddExistingSearchButton(), new PickerFieldDeleteAction());
if ($sortField) {
$config->addComponent(new GridFieldOrderableRows($sortField));
}
if (!$linkExistingTitle) {
$linkExistingTitle = $this->isHaveOne() ? 'Select a ' . $dataList->dataClass() : 'Select ' . $dataList->dataClass() . '(s)';
// plural [has_many, many_many]
}
$config->getComponentByType('PickerFieldAddExistingSearchButton')->setTitle($linkExistingTitle);
return parent::__construct($name, $title, $dataList, $config);
}
示例2: getModelClass
/**
* Returns a data class that is a DataObject type that this GridField should look like.
*
* @return string
*
* @throws LogicException
*/
public function getModelClass()
{
if ($this->modelClassName) {
return $this->modelClassName;
}
if ($this->list && method_exists($this->list, 'dataClass')) {
$class = $this->list->dataClass();
if ($class) {
return $class;
}
}
throw new LogicException('GridField doesn\'t have a modelClassName, so it doesn\'t know the columns of this grid.');
}
示例3: getModelClasses
/**
* @return array
*/
public function getModelClasses()
{
if ($this->modelClassNames) {
return $this->modelClassNames;
}
if ($this->list && method_exists($this->list, 'dataClass')) {
$class = $this->list->dataClass();
if ($class) {
if (!is_array($class)) {
$class = array($class);
}
return static::convert_to_associative($class);
}
}
return array();
}
示例4: getSortTable
/**
* Gets the table which contains the sort field.
*
* @param DataList $list
* @return string
*/
public function getSortTable(SS_List $list)
{
$field = $this->getSortField();
if ($list instanceof ManyManyList) {
$extra = $list->getExtraFields();
$table = $list->getJoinTable();
if ($extra && array_key_exists($field, $extra)) {
return $table;
}
}
$classes = ClassInfo::dataClassesFor($list->dataClass());
foreach ($classes as $class) {
if (singleton($class)->hasOwnTableDatabaseField($field)) {
return $class;
}
}
throw new Exception("Couldn't find the sort field '{$field}'");
}