@param OrderElementInterface $orderElement
@param string                $type
@param string                $format

@return \Sonata\Component\Product\ProductInterface
506080
public function getProductFromRaw(OrderElementInterface $orderElement, $type, $format = 'json')
    {
        return $this->serializer->deserialize(json_encode($orderElement->getRawProduct()), $type, $format);
    }
1199729
public function orderBy($column, $type = 'asc')
    {
        if (! is_null($this->order)) {
            return $this;
        }

        if (!in_array($type, ['asc', 'desc'])) {
            $type = 'asc';
        }

        $this->order = 'order by `'.$column.'` '.$type;

        return $this;
    }
1223055
protected function createInvoiceElementFromOrderElement(OrderElementInterface $orderElement)
    {
        $invoice = $this->invoiceElementManager->create();
        $invoice->setOrderElement($orderElement);
        $invoice->setDescription($orderElement->getDescription());
        $invoice->setDesignation($orderElement->getDesignation());
        $invoice->setPrice($orderElement->getPrice(true));
        $invoice->setUnitPriceExcl($orderElement->getUnitPrice(false));
        $invoice->setUnitPriceInc($orderElement->getUnitPrice(true));
        $invoice->setVatRate($orderElement->getVatRate());
        $invoice->setQuantity($orderElement->getQuantity());
        $invoice->setTotal($orderElement->getTotal(true));

        return $invoice;
    }
2310
public function byFunction(
        string $function,
        string $order
    ): SortBy {
        $this->sortsBy[] = [
            'type' => self::TYPE_FUNCTION,
            'function' => $function,
            'order' => $order,
        ];

        return $this;
    }
1347770
private function createCreateForm(ProductOrderItem $entity)
    {
        $form = $this->createForm(new ProductOrderItemType(), $entity, array(
            'action' => $this->generateUrl('admin_orderitem_create'),
            'method' => 'POST',
        ));

        $form->add('submit', 'submit', array('label' => 'Create'));

        return $form;
    }
614246
public function addOrderLine(OrderLineInterface $orderLine): OrderInterface
    {
        if (!$this->hasOrderLine($orderLine)) {
            $this->orderLines->add($orderLine);
            $orderLine->setOrder($this);
        }

        return $this;
    }
1032661
public static function createFormatter($formatterElement)
    {
        $formatter = null;
        $type = $formatterElement->getType();

        switch ($type) {
            case "xml":
                include_once 'phing/tasks/ext/phploc/PHPLocXMLFormatter.php';
                $formatter = new PHPLocXMLFormatter();
                break;
            case "csv":
                include_once 'phing/tasks/ext/phploc/PHPLocCSVFormatter.php';
                $formatter = new PHPLocCSVFormatter();
                break;
            case "txt":
            case "cli":
                include_once 'phing/tasks/ext/phploc/PHPLocTextFormatter.php';
                $formatter = new PHPLocTextFormatter();
                break;
            default:
                throw new BuildException("Formatter '" . $type . "' not implemented");
        }

        $formatter->setOutfile($formatterElement->getOutfile());
        $formatter->setToDir($formatterElement->getToDir());
        $formatter->setUseFile($formatterElement->getUseFile());

        return $formatter;
    }
789479
protected function createElement(&$sorting, $type=ContentWrapper\Model::TYPE_SEPARATOR)
	{
		$model = new \ContentModel();

		if($type == ContentWrapper\Model::TYPE_START) {
			$sorting = $sorting - 2;
		}
		else {
			$sorting = $sorting + 2;
			$model->bootstrap_parentId = $this->objModel->id;
		}

		$model->tstamp  = time();
		$model->pid     = $this->objModel->pid;
		$model->ptable  = $this->objModel->ptable;
		$model->type    = $this->objModel->getTypeName($type);
		$model->sorting = $sorting;

		$model->save();

		return $model;
	}
214692
public function orderBy($col = 'id', $type='asc')
    {
        try {
            if (!is_null($this->query)) {
                $this->query .= ' ORDER BY '.$col. ' '.$type;
                return $this;
            }

        } catch (\Exception $exception) {
            var_dump($exception->getMessage());
        }
    }
454601
public function reorder($elementToBeAfterID = 0)
    {
        $element = $this->element;
        $parentId = $element->ParentID;
        $currentPosition = (int) $element->Sort;
        $sortAfterPosition = 0;

        if ($elementToBeAfterID) {
            /** @var BaseElement $afterBlock */
            $afterElement = BaseElement::get()->byID($elementToBeAfterID);

            if (!$afterElement) {
                throw new InvalidArgumentException(sprintf(
                    '%s#%s not found',
                    BaseElement::class,
                    $elementToBeAfterID
                ));
            }

            // Must be weak comparison as sometimes integers are returned from the DB as strings
            if ($afterElement->ParentID != $parentId) {
                throw new InvalidArgumentException(
                    'Trying to sort element to be placed after an element from a different elemental area'
                );
            }

            $sortAfterPosition = (int) $afterElement->Sort;
        }

        // We are updating records with SQL queries to avoid the ORM triggering the creation of new versions
        // for each element that is affected by this reordering.
        $baseTableName = Convert::raw2sql(DataObject::getSchema()->tableName(BaseElement::class));

        // Update both the draft and live versions of the records
        $tableNames = [$baseTableName];
        if (BaseElement::has_extension(Versioned::class)) {
            $tableNames[] = $element->stageTable($baseTableName, Versioned::LIVE);
        }

        foreach ($tableNames as $tableName) {
            $tableName = sprintf('"%s"', $tableName);

            if ($sortAfterPosition < $currentPosition) {
                $operator = '+';
                $filter = "$tableName.\"Sort\" > $sortAfterPosition AND $tableName.\"Sort\" < $currentPosition";
                $newBlockPosition = $sortAfterPosition + 1;
            } else {
                $operator = '-';
                $filter = "$tableName.\"Sort\" <= $sortAfterPosition AND $tableName.\"Sort\" > $currentPosition";
                $newBlockPosition = $sortAfterPosition;
            }

            $query = SQLUpdate::create()
                ->setTable("$tableName")
                ->assignSQL('"Sort"', "$tableName.\"Sort\" $operator 1")
                ->addWhere([$filter, "$tableName.\"ParentID\"" => $parentId]);

            $query->execute();
        }

        // Now use the ORM to write a new version of the record that we are directly reordering
        $element->Sort = $newBlockPosition;
        $element->write();

        return $element;
    }
760862
public function invoice($orderId, $invoiceKey)
    {
        /** @var OrderHandler $handler */
        $handler = $this->requestHandler();
        return $handler->invoice($orderId, $invoiceKey);
    }
660401
public function fieldSelectC($table, $fields, $where, $orderBy = null)
    {

        $this->cacheNext = true;

        return $this->fieldSelect($table, $fields, $where, $orderBy);
    }
1091384
public function buildField($type, $label, $field, $injects)
    {
        $format = $this->orderFormat['default'];
        if (isset($this->orderFormat[$type])) {
            $format = $this->orderFormat[$type];
        }

        $output = '';

        foreach ($format as $item) {
            if ($item == 'label') {
                $output .= $label;
            } elseif ($item == 'field') {
                $output .= $field;
            } elseif (isset($injects[$item])) {
                $output .= $injects[$item];
            }
        }

        return $output;
    }
34979
private function mediaCreateEditForm(Media $entity, $product, $type)
    {
        $types = $this->container->getParameter('flowcode_media.media_types');
        $class = $types[$entity->getMediaType()]["class_type"];

        $form = $this->createForm(new $class(), $entity, array(
            'action' => $this->generateUrl('admin_product_media_update', array("product" => $product->getId(), 'entity' => $entity->getId(), "type" => $entity->getMediaType())),
            'method' => 'PUT',
        ));

        $form->add('submit', 'submit', array('label' => 'Update'));

        return $form;
    }
255433
public function removeElement(OrderElement $elements)
    {
        $this->elements->removeElement($elements);
        $elements->setOrder(null);
    }
640685
protected function assemblyQuery(FormElement $element)
    {
        $table = $this->model->getTable();
        $input = $element->getInput();
        $type = $input->getType();
        $name = $element->id();
        $value = $input->getValue();

        if (null === $value) {
            return $this->query;
        }

        $columns = scheme()->columns($table);

        if ($input->hasQuery() && ($subQuery = $input->execQuery($this->query, $input->getValue()))) {
            $this->query = $subQuery;

            return $this->query;
        }

        if ($this->touchedTranslatableFilter($input, $columns)) {
            return $this->filterByTranslatableColumn($name, $type, $value);
        }

        if (!array_key_exists($name, $columns) && $input->hasRelation()) {
            if (($relation = call_user_func([$this, $input->getRelation()])) instanceof HasOne
                || $relation instanceof BelongsTo
            ) {
                return $this->filterRelationShipColumn($input, $relation, $name, $type, $value);
            }
        }

        $this->query = $this->applyQueryElementByType($this->query, $table, $name, $type, $value);

        return $this->query;
    }
509144
final public function orderBy(string $orderBy, string $order = 'ASC')
    {        
       $this->query->addOrderBy($orderBy, $order);

        return $this;
    }