本文整理匯總了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;
}