Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
OrderRenderer.php
Go to the documentation of this file.
1 <?php
7 
10 
15 {
19  protected $quote;
20 
24  public function __construct(
26  ) {
27  $this->quote = $quote;
28  }
29 
37  public function render(Select $select, $sql = '')
38  {
39  if ($select->getPart(Select::ORDER)) {
40  $order = [];
41  foreach ($select->getPart(Select::ORDER) as $term) {
42  if (is_array($term)) {
43  if (is_numeric($term[0]) && (string)(int)$term[0] == $term[0]) {
44  $order[] = (int)trim($term[0]) . ' ' . $term[1];
45  } else {
46  $order[] = $this->quote->quoteIdentifier($term[0]) . ' ' . $term[1];
47  }
48  } elseif (is_numeric($term) && (string)(int)$term == $term) {
49  $order[] = (int)trim($term);
50  } else {
51  $order[] = $this->quote->quoteIdentifier($term);
52  }
53  }
54  $sql .= ' ' . Select::SQL_ORDER_BY . ' ' . implode(', ', $order) . PHP_EOL;
55  }
56  return $sql;
57  }
58 }
const ORDER
Definition: Select.php:54
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$order
Definition: order.php:55
const SQL_ORDER_BY
Definition: Select.php:74