Returns an ordered list of the file uid's that have been bucketed into this content type. The list is ordered by
the files date.

@param string $order

@return array
764998
public function getFileList($order = 'desc')
    {
        if (! is_null($this->itemsOrderCache) && isset($this->itemsOrderCache[$order])) {
            return $this->itemsOrderCache[$order];
        }

        // Order Files by date newer to older
        $this->items->sort(function ($a, $b) use ($order) {
            if ($a == $b) {
                return 0;
            }
            if ($order === 'asc') {
                return ($a < $b) ? -1 : 1;
            }

            return ($a > $b) ? -1 : 1;
        });

        $this->itemsOrderCache[$order] = $this->items->all();

        return $this->itemsOrderCache[$order];
    }
882550
public function getData($order = self::SORT_DESC)
    {
        return array(
            'items' => array_map(
                function (Item $item) {
                    /*
                     * @var Item $item
                     */
                    return $item->toArray();
                },
                array_values($this->getItems($order))
            ),
        );
    }
343228
protected function parseOrder($order) {
        if(is_string($order)) {
            $array   =  explode(',',$order);
            $order   =  array();
            foreach ($array as $key=>$val){
                $arr  =  explode(' ',trim($val));
                if(isset($arr[1])) {
                    $arr[1]  =  $arr[1]=='asc'?1:-1;
                }else{
                    $arr[1]  =  1;
                }
                $order[$arr[0]]    = $arr[1];
            }
        }
        return $order;
    }
289804
public function thenByDesc($order)
    {
        $order = LambdaUtils::toSelectCallable($order);
        $this->orders[] = array("property" => $order, "direction" => self::ORDER_DESC);
        return $this;
    }
536286
public static function orderArray($array, $order)
    {
        $ordered = [];

        foreach ($order as $key) {
            if (array_key_exists($key, $array)) {
                $ordered[$key] = $array[$key];
            }
        }

        return $ordered;
    }
1267584
protected function getItemListForOrder(Order $order): array
    {
        $items = [];

        $priceCheck = 0;
        $count = -1;

        /** @var LineItem $item */
        foreach ($order->lineItems as $item) {
            $price = Currency::round($item->salePrice);
            // Can not accept zero amount items. See item (4) here:
            // https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECCustomizing/#setting-order-details-on-the-paypal-review-page

            if ($price !== 0) {
                $count++;
                /** @var Purchasable $purchasable */
                $purchasable = $item->getPurchasable();
                $defaultDescription = Craft::t('commerce', 'Item ID').' '.$item->id;
                $purchasableDescription = $purchasable ? $purchasable->getDescription() : $defaultDescription;
                $description = isset($item->snapshot['description']) ? $item->snapshot['description'] : $purchasableDescription;
                $description = empty($description) ? 'Item '.$count : $description;
                $items[] = [
                    'name' => $description,
                    'description' => $description,
                    'quantity' => $item->qty,
                    'price' => $price,
                ];

                $priceCheck += ($item->qty * $item->salePrice);
            }
        }

        $count = -1;

        /** @var OrderAdjustment $adjustment */
        foreach ($order->adjustments as $adjustment) {
            $price = Currency::round($adjustment->amount);

            // Do not include the 'included' adjustments, and do not send zero value items
            // See item (4) https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECCustomizing/#setting-order-details-on-the-paypal-review-page
            if (($adjustment->included == 0 || $adjustment->included == false) && $price !== 0) {
                $count++;
                $items[] = [
                    'name' => empty($adjustment->name) ? $adjustment->type." ".$count : $adjustment->name,
                    'description' => empty($adjustment->description) ? $adjustment->type.' '.$count : $adjustment->description,
                    'quantity' => 1,
                    'price' => $price,
                ];
                $priceCheck += $adjustment->amount;
            }
        }

        $priceCheck = Currency::round($priceCheck);
        $totalPrice = Currency::round($order->totalPrice);
        $same = (bool)($priceCheck === $totalPrice);

        if (!$same) {
            Craft::error('Item bag total price does not equal the orders totalPrice, some payment gateways will complain.', __METHOD__);
        }

        return $items;
    }
1008661
public function getBestRenderLocales($ordered = self::ORDER_LANG) {
        $locales = [];
        $this->getServerLocales();

        foreach($this->getClientLocales() as $locale) {
            /** @var Locale $locale  */

            $loc = $this->serverLocales->getBestMatchingLocaleForLocale($locale);
            if($loc && !in_array($loc, $locales)) {
                $locales[]  = $loc;
            }
        }
        if(count($locales) == 0) {
            if($this->defaultLocale)
                $locales[] = $this->defaultLocale;
            else {
                $locales[] = $this->getServerLocales()[0] ?? NULL;
            }
        }

        if($ordered & self::ORDER_STRUCT) {
            $locs = [];
            foreach($locales as $loc) {
                /** @var Locale $loc */
                $lang = $loc->getLanguage();

                $locs[$lang][] = $loc;
            }

            if($ordered & self::ORDER_LANG) {
                foreach($locs as &$ll)
                    usort($ll, LocaleCollection::LANG_SORT_CALLBACK);
            } elseif($ordered & self::ORDER_REG) {
                foreach($locs as &$ll)
                    usort($ll, LocaleCollection::REG_SORT_CALLBACK);
            }

            return $locs;
        }

        return $locales;
    }
896280
public static function getOrders($filter = array())
    {
        $filter = Filter::create($filter);
        return self::getCollection('/orders' . $filter->toQuery(), 'Order');
    }
1259360
public function getOrderFileList($orderId)
    {
        $orderFileList = oxNew(OrderFileList::class);
        $orderFileList->loadOrderFiles($orderId);

        if (count($orderFileList) > 0) {
            return $orderFileList;
        }

        return false;
    }
1327298
public function files($directory)
	{
		$glob = glob($directory.'/*');

		if ($glob === false) return array();

		// To get the appropriate files, we'll simply glob the directory and filter
		// out any "files" that are not truly files so we do not end up with any
		// directories in our list, but only true files within the directory.
		return array_filter($glob, function($file)
		{
			return filetype($file) == 'file';
		});
	}
1026617
public function show(Order $order)
    {
        Shop::instance($order->shop_id);
        $paymentMethods = Shop::getPaymentMethods()->flatten()->mapWithKeys(function($method) {
            return [$method::getId() => $method::getName()];
        })->all();
        $orderStatuses = $this->orderstatus->all()->pluck('name', 'id')->toArray();

        return view('order::admin.orders.view', compact('order', 'paymentMethods', 'orderStatuses'));
    }
1035909
public function get_all_products_in( $order ) {
		$order = wc_get_order( $order );
		if ( ! $order ) {
			return [];
		}
		$products = [];
		foreach ( $order->get_items() as $item ) {
			$products[] = $order->get_product_from_item( $item );
		}
		return $products;
	}
810981
public function listFiles($directory)
    {
        if (!file_exists($directory)) {
            return collect([]);
        }

        return $this->scanDir($directory)->reject(function ($item) {
            return !$this->isAllowedDirectory($item) && !$this->isYamlFile($item);
        })->mapWithKeys(function ($item) {
            if (is_dir($item)) {
                return [basename($item) => $this->listFiles($item)->toArray()];
            }

            return [$this->cleanKey($item) => $item];
        });
    }
766022
public function getFilesList($dir)
	{
		$list = [];
		$iterator = Aws\recursive_dir_iterator($dir);
		foreach ($iterator as $filename) {
			$list[] = $filename;
		}
		return $list;
	}
432655
public function all($order = 'ASC')
    {
        $capsule = $this->_database->getCapsule();

        $this->_model = $capsule->table($this->table)->orderBy('id', $order)->get();

        return $this->_model;
    }
636643
protected static function parseOrderParameters($order)
    {
        $parsedOrder = [];
        if (count($order) > 0) {
            foreach ($order as $key => $o) {
                // Check if $order array is already formatted properly
                if (!is_numeric($key) && is_numeric($o)) {
                    $parsedOrder[$key] = $o;
                    continue;
                }
                $o = self::str($o);
                if ($o->startsWith('-')) {
                    $parsedOrder[$o->subString(1, 0)->val()] = -1;
                } elseif ($o->startsWith('+')) {
                    $parsedOrder[$o->subString(1, 0)->val()] = 1;
                } else {
                    $parsedOrder[$o->val()] = 1;
                }
            }
        }

        return $parsedOrder;
    }
446142
public static function actionTree($sort = '')
    {
        $order = ExtHelpers::getOrder($sort, [
            'menu_id',
            'parent_id',
            'text',
            'title',
            'url',
            'view_package',
            'expanded',
            'closable',
            'is_folder',
            'is_open_url',
            'is_open_target',
            'is_every_open',
            'is_hide',
            'display_order',
            'note',
            'status',
        ], [], 'display_order ASC,menu_id ASC');
        $tree = DpAdminMenu::getTreeByParentId(null, '', [], $order);

        return [
            'children' => $tree,
        ];
    }