mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 17:51:40 +09:00
Reorder return values of VariableBase::getValue() so that the value can be quickly accessed
This commit is contained in:
parent
0d14aca1c0
commit
fd0491cb0d
3 changed files with 18 additions and 15 deletions
|
|
@ -609,7 +609,7 @@ class Query extends VariableBase
|
|||
{
|
||||
// Get the name of the column or expression to order by.
|
||||
$column_name = '';
|
||||
list($is_expression, $column_name) = $orderby->getValue($this->_args);
|
||||
list($column_name, $is_expression) = $orderby->getValue($this->_args);
|
||||
if (!$column_name)
|
||||
{
|
||||
continue;
|
||||
|
|
@ -649,7 +649,7 @@ class Query extends VariableBase
|
|||
protected function _arrangeLimitOffset(Navigation $navigation): string
|
||||
{
|
||||
// Get the list count.
|
||||
list($is_expression, $list_count) = $navigation->list_count->getValue($this->_args);
|
||||
$list_count = $navigation->list_count->getValue($this->_args)[0];
|
||||
if ($list_count <= 0)
|
||||
{
|
||||
return '';
|
||||
|
|
@ -660,11 +660,11 @@ class Query extends VariableBase
|
|||
// Get the offset from the page or offset variable.
|
||||
if ($navigation->page)
|
||||
{
|
||||
list($is_expression, $page) = $navigation->page->getValue($this->_args);
|
||||
$page = $navigation->page->getValue($this->_args)[0];
|
||||
}
|
||||
if ($navigation->offset)
|
||||
{
|
||||
list($is_expression, $offset) = $navigation->offset->getValue($this->_args);
|
||||
$offset = $navigation->offset->getValue($this->_args)[0];
|
||||
}
|
||||
|
||||
// If page is available, set the offset and require pagination for this query.
|
||||
|
|
|
|||
|
|
@ -281,11 +281,17 @@ class VariableBase
|
|||
/**
|
||||
* Get the current value, falling back to the default value if necessary.
|
||||
*
|
||||
* Format of return value: [value, is_expression, is_default_value]
|
||||
*
|
||||
* @param array $args
|
||||
* @return array
|
||||
*/
|
||||
public function getValue(array $args): array
|
||||
{
|
||||
$value = null;
|
||||
$is_expression = false;
|
||||
$is_default_value = false;
|
||||
|
||||
if ($this->var && Query::isValidVariable($args[$this->var] ?? null, $this instanceof ColumnWrite))
|
||||
{
|
||||
if ($args[$this->var] === '')
|
||||
|
|
@ -293,35 +299,32 @@ class VariableBase
|
|||
if ($this instanceof ColumnWrite)
|
||||
{
|
||||
$value = $args[$this->var];
|
||||
$is_expression = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
list($is_expression, $value) = $this->getDefaultValue();
|
||||
$is_default_value = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$is_expression = false;
|
||||
$value = $args[$this->var];
|
||||
}
|
||||
}
|
||||
elseif ($this->default !== null)
|
||||
{
|
||||
list($is_expression, $value) = $this->getDefaultValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
$is_expression = null;
|
||||
$value = null;
|
||||
$is_default_value = true;
|
||||
}
|
||||
|
||||
return [$is_expression, $value];
|
||||
return [$value, $is_expression, $is_default_value];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default value of this variable.
|
||||
*
|
||||
* Format of return value: [is_expression, value]
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDefaultValue(): array
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue