Adds an order
@param array $data
@param array $options
@return array
550829
public function add(array $data, array $options = array())
    {
        $result = array();
        $this->hook->attach('order.submit.before', $data, $options, $result, $this);

        if (!empty($result)) {
            return (array) $result;
        }

        $data['order_id'] = $this->order->add($data);

        if (empty($data['order_id'])) {
            return $this->getResultError();
        }

        $order = $this->order->get($data['order_id']);
        $this->setBundledProducts($order, $data);

        if (empty($options['admin'])) {
            $this->setPriceRules($order);
            $this->updateCart($order, $data['cart']);
            $this->notifyCreated($order);
            $result = $this->getResultAdded($order);
        } else {
            $this->cloneCart($order, $data['cart']);
            $result = $this->getResultAddedAdmin($order);
        }

        $this->hook->attach('order.submit.after', $data, $options, $result, $this);
        return (array) $result;
    }
674531
public function insert($data, $priority = 0)
    {
        $this->data[] = [
            'data'     => $data,
            'priority' => $priority,
        ];

        $priority = array($priority, $this->max--);
        $this->getSplQueue()->insert($data, $priority);
        return $this;
    }
633909
protected function parseOrder($order, $options = [])
    {
        if (is_array($order)) {
            $array = [];
            foreach ($order as $key => $val) {
                if (is_numeric($key)) {
                    if (false === strpos($val, '(')) {
                        $array[] = $this->parseKey($val, $options);
                    } else {
                        $array[] = $val;
                    }
                } else {
                    $sort    = in_array(strtolower(trim($val)), ['asc', 'desc']) ? ' ' . $val : '';
                    $array[] = $this->parseKey($key, $options) . ' ' . $sort;
                }
            }
            $order = implode(',', $array);
        }

        return !empty($order) ? ' ORDER BY ' . $order : '';
    }
1004390
public function amend($data = null, $options = [])
    {
        if ($data !== null) {
            $count = $this->count();
            foreach ($data as $i => $value) {
                if (!isset($this[$i])) {
                    $this->setAt($i, $value, $options);
                } else {
                    $this[$i]->amend($value, $options);
                }
            }
            for ($i = count($data); $i < $count; $i++) {
                unset($this[$i]);
            }
        }
        $this->_original = $this->_data;
        $this->_modified = false;
        return $this;
    }
694863
protected function addOrder(array $params, $money, array $options)
    {
        $params['items'][] = [
            'id'          => Arr::get($options, 'reference'),
            'title'       => Arr::get($options, 'description'),
            'description' => Arr::get($options, 'description'),
            'unit_price'  => (float) $this->gateway->amount($money),
            'quantity'    => 1,
            'currency_id' => Arr::get($options, 'currency'),
        ];

        return array_merge($params, [
            'currency_id'        => Arr::get($options, 'currency'),
            'external_reference' => Arr::get($options, 'reference'),
            'expires'            => Arr::get($options, 'expires', false),
        ]);
    }
436319
public function insert($data, $options = [])
    {
        return $this->database->createCommand()->insert($this->name, $data, $options);
    }
21335
public static function buildOptions($data, $options_map, $orderby, $options) {
		$data = \Object\Data\Common::options($data, $options_map, $options);
		// sorting
		if (!empty($options['i18n'])) {
			if ($options['i18n'] !== 'skip_sorting') {
				array_key_sort($data, ['name' => SORT_ASC], ['name' => SORT_NATURAL]);
			}
		} else if (empty($orderby)) {
			array_key_sort($data, ['name' => SORT_ASC], ['name' => SORT_NATURAL]);
		}
		return $data;
	}
39218
public function Order( $data )
	{
		Deprecation::getInstance()->setExceptionVersion( '0.9' )
			->message(  'Use orderBy instad' );
		if( !is_array( $data ) )
			throw new InvalidArgumentException( 'Orders must be given as List of Column and Direction.' );
		$column		= $data[0];
		$direction	= strtoupper( $data[1] );
		$this->builder->addOrder( $column, $direction );
		return array();
	}
972141
private function order(array $data)
    {
        $filteredData = $this->filterOrderable($data);

        if (!empty($filteredData)) {
            uasort(
                $filteredData,
                function (OrderedNormalizerInterface $a, OrderedNormalizerInterface $b) {
                    return $a->getOrder() > $b->getOrder();
                }
            );

            return array_merge($filteredData, array_diff_key($data, $filteredData));
        }

        return $data;
    }
710384
public function addType($name, $type, $data = null, $options = array())
    {
        $this->types[$name] = $type;
        $this->data[$name] = $data;
        $this->options[$name] = $options;

        return $this;
    }
489054
public static final function jsonDecode($data, array $options = null): array
    {
        $encoder = new JsonEncoder($options);

        return [$encoder->decode($data), $encoder->hasError()
            ? new EncoderException('JSON Error: '. $encoder->getError()) : null];
    }
896631
public function post($url, $data = [], array $options = [])
    {
        $options = $this->_mergeOptions($options);
        $url = $this->buildUrl($url, [], $options);

        return $this->_doRequest(Request::METHOD_POST, $url, $data, $options);
    }
249125
public static final function jsonEncode($data, array $options = null): array
    {
        $encoder = new JsonEncoder($options);

        return [$encoder->encode($data), $encoder->hasError()
            ? new EncoderException('JSON Error: '. $encoder->getError()) : null];
    }
249733
public function deserialize(array $data, Options $options = null)
    {
        if (empty($options)) {
            $options = $this->optionsRepo->findOneBy(['id' => $data['id']]);
        }
        if (empty($options)) {
            $options = new Options();
        }
        if (isset($data['user'])) {
            $user = isset($data['user']['id']) ? $this->userRepo->findOneBy(['uuid' => $data['user']['id']]) : null;
            $options->setUser($user);
        }
        if (isset($data['data'])) {
            $options->setOptions($data['data']);
        }

        return $options;
    }
422604
protected function addOrder(array $params, $money, array $options)
    {
        return array_merge($params, [
            'amount'      => $this->gateway->amount($money),
            'currency'    => Arr::get($options, 'currency', $this->gateway->getCurrency()),
            'description' => Helper::ascii(Arr::get($options, 'description', 'PayMe Purchase')),
            'order_id'    => Arr::get($options, 'reference'),
        ]);
    }
1222445
public static function uploadFiles(\Object $data, array $options = array()) {
        $return = array('success' => array(), 'errors' => array());
        foreach ($data->toArray(TRUE) as $ppt => $info) {
            if (is_array($options['ignore']) && in_array($ppt, $options['ignore']))
                continue;
            self::makeValuesArray($info);

            foreach ($info['name'] as $key => $name) {
                if ($info['error'][$key] !== UPLOAD_ERR_OK) {
                    $return['errors'][$ppt][$name] = self::UPLOAD_ERROR_NO_FILE;
                    continue;
                }

                if (isset($options['maxSize'][$key]) && $info['size'] > $options['maxSize'][$key]) {
                    $return['errors'][$ppt][$name] = self::UPLOAD_ERROR_SIZE;
                    continue;
                }

                $tmpName = $info['tmp_name'][$key];
                $pInfo = pathinfo($name);
                if (isset($options['extensions']) && !in_array(strtolower($pInfo['extension']), $options['extensions'])) {
                    $return['errors'][$ppt][$name] = self::UPLOAD_ERROR_EXTENSION;
                    continue;
                }
                $dir = isset($options['path']) ? $options['path'] : DATA . 'uploads';
                if (substr($dir, strlen($dir) - 1) !== DIRECTORY_SEPARATOR)
                    $dir .= DIRECTORY_SEPARATOR;
                if (!is_dir($dir)) {
                    if (!mkdir($dir, 0777, true)) {
                        $return['errors'][$ppt][$name] = self::UPLOAD_ERROR_PATH;
                        continue;
                    }
                }
                $savePath = $dir . $options['prefix'] . preg_replace('/[^A-Z0-9._-]/i', '_', basename($pInfo['filename'])) . '.' . $pInfo['extension'];
                if (move_uploaded_file($tmpName, $savePath)) {
                    $return['success'][$ppt][$name] = $savePath;
                    self::$uploadSuccess = $savePath;
                } else {
                    $return['errors'][$ppt][$name] = self::UPLOAD_ERROR_FAILED;
                }
            }
        }
        return $return;
    }
742715
protected function addPriorityChoices(array $unsortedChoices, ChoicesAwareViewData $data)
    {
        foreach ($this->getSortPriority() as $name) {
            if (array_key_exists($name, $unsortedChoices)) {
                $data->addChoice($unsortedChoices[$name]);
                unset($unsortedChoices[$name]);
            }
        }

        return $unsortedChoices;
    }