本文整理汇总了PHP中ArrayList::dataClass方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayList::dataClass方法的具体用法?PHP ArrayList::dataClass怎么用?PHP ArrayList::dataClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayList
的用法示例。
在下文中一共展示了ArrayList::dataClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOptions
/**
* @return ArrayList
*/
protected function getOptions()
{
$options = ArrayList::create();
$source = $this->getSource();
if (!$source) {
$source = new ArrayList();
}
$dataClass = $source->dataClass();
$values = $this->Value();
if (!$values) {
return $options;
}
if (is_array($values)) {
$values = DataList::create($dataClass)->filter('ID', $values);
}
$ids = $values->column('ID');
$titleField = $this->getTitleField();
foreach ($source as $object) {
$options->push(ArrayData::create(array('Title' => $object->{$titleField}, 'Value' => $object->ID, 'Selected' => in_array($object->ID, $ids))));
}
return $options;
}
示例2: getOptions
/**
* @return ArrayList
*/
protected function getOptions()
{
$options = ArrayList::create();
$source = $this->getSource();
if (!$source) {
$source = new ArrayList();
}
$dataClass = $source->dataClass();
$values = $this->Value();
// Mark selected tags while still returning a full list of possible options
$ids = array();
// empty fallback array for comparing
$values = $this->Value();
if ($values) {
// @TODO conversion from array to DataList to array...(?)
if (is_array($values)) {
$values = DataList::create($dataClass)->filter('ID', $values);
}
$ids = $values->column('ID');
}
$titleField = $this->getTitleField();
foreach ($source as $object) {
$options->push(ArrayData::create(array('Title' => $object->{$titleField}, 'Value' => $object->ID, 'Selected' => in_array($object->ID, $ids))));
}
return $options;
}