本文整理汇总了PHP中DataList::dataClass方法的典型用法代码示例。如果您正苦于以下问题:PHP DataList::dataClass方法的具体用法?PHP DataList::dataClass怎么用?PHP DataList::dataClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataList
的用法示例。
在下文中一共展示了DataList::dataClass方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFiltersToDataList
/**
* @param DataList $list
* @param array $filters
* @param DataObject|string $sing - just a singleton object we can get information off of
* @return DataList
*/
public function addFiltersToDataList($list, array $filters, $sing = null)
{
if (!$sing) {
$sing = singleton($list->dataClass());
}
if (is_string($sing)) {
$sing = singleton($sing);
}
if (!empty($filters)) {
foreach ($filters as $filterField => $filterVal) {
if ($sing->hasExtension('HasStaticAttributes') && preg_match(self::config()->attribute_facet_regex, $filterField, $matches)) {
// $sav = $sing->StaticAttributeValues();
// Debug::log("sav = {$sav->getJoinTable()}, {$sav->getLocalKey()}, {$sav->getForeignKey()}");
// $list = $list
// ->innerJoin($sav->getJoinTable(), "\"{$sing->baseTable()}\".\"ID\" = \"{$sav->getJoinTable()}\".\"{$sav->getLocalKey()}\"")
// ->filter("\"{$sav->getJoinTable()}\".\"{$sav->getForeignKey()}\"", $filterVal)
// ;
// TODO: This logic should be something like the above, but I don't know
// how to get the join table from a singleton (which returns an UnsavedRelationList
// instead of a ManyManyList). I've got a deadline to meet, though, so this
// will catch the majority of cases as long as the extension is applied to the
// Product class instead of a subclass.
$list = $list->innerJoin('Product_StaticAttributeTypes', "\"SiteTree\".\"ID\" = \"Product_StaticAttributeTypes\".\"ProductID\"")->innerJoin('ProductAttributeValue', "\"Product_StaticAttributeTypes\".\"ProductAttributeTypeID\" = \"ProductAttributeValue\".\"TypeID\"")->innerJoin('Product_StaticAttributeValues', "\"SiteTree\".\"ID\" = \"Product_StaticAttributeValues\".\"ProductID\" AND \"ProductAttributeValue\".\"ID\" = \"Product_StaticAttributeValues\".\"ProductAttributeValueID\"")->filter("Product_StaticAttributeValues.ProductAttributeValueID", $filterVal);
} else {
$list = $list->filter($this->processFilterField($sing, $filterField, $filterVal));
}
}
}
return $list;
}
示例2: getManipulatedData
public function getManipulatedData(GridField $gridField, SS_List $list)
{
if (!$list instanceof RelationList) {
user_error('GridFieldManyRelationHandler requires the GridField to have a RelationList. Got a ' . get_class($list) . ' instead.', E_USER_WARNING);
}
$state = $this->getState($gridField);
// We don't use setupState() as we need the list
if ($state->FirstTime) {
$state->RelationVal = array_values($list->getIdList()) ?: array();
}
if (!$state->ShowingRelation && $this->useToggle) {
return $list;
}
$query = clone $list->dataQuery();
try {
$query->removeFilterOn($this->cheatList->getForeignIDFilter($list));
} catch (InvalidArgumentException $e) {
/* NOP */
}
$orgList = $list;
$list = new DataList($list->dataClass());
$list = $list->setDataQuery($query);
if ($orgList instanceof ManyManyList) {
$joinTable = $this->cheatManyList->getJoinTable($orgList);
$baseClass = ClassInfo::baseDataClass($list->dataClass());
$localKey = $this->cheatManyList->getLocalKey($orgList);
$query->leftJoin($joinTable, "\"{$joinTable}\".\"{$localKey}\" = \"{$baseClass}\".\"ID\"");
$list = $list->setDataQuery($query);
}
return $list;
}
开发者ID:helpfulrobot,项目名称:arillo-gridfieldrelationhandler,代码行数:31,代码来源:GridFieldManyRelationHandler.php
示例3: __construct
public function __construct($controller, $name, DataList $list)
{
$this->list = $list;
$class = $list->dataClass();
$singleton = singleton($class);
$fields = $singleton->getFrontEndFields();
$fields->unshift(new ListEditField("EditList", $this->list));
$fields->push(new HiddenField("ID", "ID"));
$actions = new FieldList(new FormAction("savenew", "Save " . $singleton->i18n_singular_name()));
parent::__construct($controller, $name, $fields, $actions);
$this->setupEditingMode();
$singleton->extend('updateListEditForm', $this);
//all fields are required
if (!$this->validator) {
$this->setValidator(new RequiredFields(array_keys($fields->saveableFields())));
}
}
示例4: getSortTable
/**
* Gets the table which contains the sort field.
*
* @param DataList $list
* @return string
*/
public function getSortTable(DataList $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}'");
}
开发者ID:phil-quinn,项目名称:silverstripe-versioneddataobjects,代码行数:24,代码来源:VersionedGridFieldOrderableRows.php
示例5: __construct
public function __construct(DataList $list)
{
$this->list = $list;
//TODO: user error if list is null
parent::__construct($this->list->dataClass());
}
示例6: getQuery
/**
* Returns a SQL object representing the search context for the given
* list of query parameters.
*
* @param array $searchParams Map of search criteria, mostly taked from $_REQUEST.
* If a filter is applied to a relationship in dot notation,
* the parameter name should have the dots replaced with double underscores,
* for example "Comments__Name" instead of the filter name "Comments.Name".
* @param string|array $sort Database column to sort on.
* Falls back to {@link DataObject::$default_sort} if not provided.
* @param string|array $limit
* @param DataList $existingQuery
* @return DataList
*/
public function getQuery($searchParams, $sort = false, $limit = false, $existingQuery = null)
{
if ($existingQuery) {
if (!$existingQuery instanceof DataList) {
throw new InvalidArgumentException("existingQuery must be DataList");
}
if ($existingQuery->dataClass() != $this->modelClass) {
throw new InvalidArgumentException("existingQuery's dataClass is " . $existingQuery->dataClass() . ", {$this->modelClass} expected.");
}
$query = $existingQuery;
} else {
$query = DataList::create($this->modelClass);
}
if (is_array($limit)) {
$query = $query->limit(isset($limit['limit']) ? $limit['limit'] : null, isset($limit['start']) ? $limit['start'] : null);
} else {
$query = $query->limit($limit);
}
$query = $query->sort($sort);
// hack to work with $searchParems when it's an Object
$searchParamArray = array();
if (is_object($searchParams)) {
$searchParamArray = $searchParams->getVars();
} else {
$searchParamArray = $searchParams;
}
foreach ($searchParamArray as $key => $value) {
$key = str_replace('__', '.', $key);
if ($filter = $this->getFilter($key)) {
$filter->setModel($this->modelClass);
$filter->setValue($value);
if (!$filter->isEmpty()) {
$query = $query->alterDataQuery(array($filter, 'apply'));
}
}
}
if ($this->connective != "AND") {
throw new Exception("SearchContext connective '{$this->connective}' not supported after ORM-rewrite.");
}
return $query;
}