@param Shopgate_Model_XmlResultObject $itemNode

@return Shopgate_Model_XmlResultObject
162666
public function asXml(Shopgate_Model_XmlResultObject $itemNode)
    {
        /**
         * @var Shopgate_Model_XmlResultObject $stockNode
         */
        $stockNode = $itemNode->addChild('stock');
        $stockNode->addChild('is_saleable', (int)$this->getIsSaleable());
        $stockNode->addChild('backorders', (int)$this->getBackorders());
        $stockNode->addChild('use_stock', (int)$this->getUseStock());
        $stockNode->addChild('stock_quantity', $this->getStockQuantity());
        $stockNode->addChild('minimum_order_quantity', $this->getMinimumOrderQuantity(), null, false);
        $stockNode->addChild('maximum_order_quantity', $this->getMaximumOrderQuantity(), null, false);
        $stockNode->addChildWithCDATA('availability_text', $this->getAvailabilityText(), false);

        return $itemNode;
    }
1335011
public function fromArray($itemResultSet)
    {
        if ($itemResultSet instanceof \Closure) {
            $itemResultSet = $itemResultSet($this->table);
        }

        $initialBuild = false;
        if (!$this->entitiesGraph) {
            $initialBuild = true;
        }

        if (is_numeric($itemResultSet)) {
            return $itemResultSet;
        }

        if (!$itemResultSet) {
            return null;
        }

        if ($itemResultSet instanceof Collection) {
            if (0 == $itemResultSet->count()) {
                if ($this->fromArrayResultCallback) {
                    $method = $this->fromArrayResultCallback;
                    return $method([]);
                } else {
                    return [];
                }
            }

            $resultSet = [];
            foreach ($itemResultSet as $offset => $itemSpec) {
                $resultSet[$offset] = $this->fromArray($itemSpec);
            }

            if (isset($this->fromArrayResultCallback)) {
                $method = $this->fromArrayResultCallback;
                return $method($resultSet);
            }

            return $resultSet;
        }

        $initialObject = $itemResultSet;
        if (is_object($itemResultSet)) {
            if (!method_exists($itemResultSet, 'toArray')) {
                throw new \InvalidArgumentException(
                    'The item result set, if an object, must contain the method toArray which converts the result set to a flat array'
                );
            }
            $itemResultSet = $itemResultSet->toArray();
        }

        if ($this->toClassName instanceof \Closure) {
            $subMapper = call_user_func($this->toClassName, $itemResultSet);
        } else {
            $subMapper = $this->toClassName;
        }

        $refl   = new \ReflectionClass($subMapper);
        $entity = $refl->newInstanceWithoutConstructor();

        // Map simple column to properties types
        foreach ($this->columnsToProperties as $columnName => $propertyName) {
            if (array_key_exists($propertyName, $this->propertiesToMappers)) {
                continue;
            }
            $prop = $refl->getProperty($propertyName);
            $prop->setAccessible(true);

            try {
                $value = $this->getValueFromArrayByKey($columnName, $itemResultSet);

                if (array_key_exists($propertyName, $this->propertiesFromArrayCallbacks)) {
                    $value = call_user_func_array(
                        $this->propertiesFromArrayCallbacks[$propertyName],
                        [$value]
                    );
                }

            } catch (\Exception $e) {
                $value = new NotPopulatedPropertyValue($propertyName, get_class($this));
            }

            $prop->setValue($entity, $value);
        }

        // Map simple properties types (that do not have any columns)
        foreach ($this->properties as $propertyName) {
            if (in_array($propertyName, $this->columnsToProperties)) {
                continue;
            }
            $prop = $refl->getProperty($propertyName);
            $prop->setAccessible(true);

            if (array_key_exists($propertyName, $this->propertiesFromArrayCallbacks)) {
                $value = call_user_func_array(
                    $this->propertiesFromArrayCallbacks[$propertyName],
                    [$itemResultSet]
                );
                $prop->setValue($entity, $value);
            }
        }

        // Map Class Types
        foreach ($this->propertiesToClasses as $propertyName => $subMapper) {
            $prop = $refl->getProperty($propertyName);
            $prop->setAccessible(true);

            $value = $subMapper->fromArray(
                $itemResultSet
            );

            $prop->setValue($entity, $value);
        }

        $this->entitiesGraph[get_class($this)] = $entity;

        // Map via Mappers
        foreach ($this->propertiesToMappers as $propertyName => $mapperClassName) {
            $columnName = array_search($propertyName, $this->columnsToProperties);

            /** @var DoplioDataMapper $subMapper */
            $subMapper = $this->resolver->resolve($mapperClassName);
            $subMapper->setEntitiesGraph($this->entitiesGraph);
            $prop = $refl->getProperty($propertyName);
            $prop->setAccessible(true);

            $value = null;

            if (array_key_exists($mapperClassName, $this->entitiesGraph)) {
                $value = $this->entitiesGraph[$mapperClassName];
            } else {
                if (array_key_exists($columnName, $itemResultSet)) {
                    $value                                 = $subMapper->fromArray(
                        $initialObject->$columnName
                    );
                    $this->entitiesGraph[$mapperClassName] = $value;

                    $this->identityMap += $subMapper->identityMap;
                } else {
                    $value = new NotPopulatedPropertyValue($propertyName, get_class($this));
                }
            }

            $prop->setValue($entity, $value);
        }

        if (!is_array($initialObject)) {
            $this->identityMap[] = [
                $initialObject,
                $entity
            ];
        }

        if ($initialBuild) {
            $this->entitiesGraph = [];
        }
        return $entity;
    }
173990
public static function fromString($itemValue)
    {
        $bits = preg_split('/(".+?"|[^;]+)(?:;|$)/', $itemValue, 0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
        $value = array_shift($bits);
        $attributes = [];

        foreach ($bits as $bit) {
            list($bitName, $bitValue) = explode('=', trim($bit));

            $bitValue = self::trimEdge($bitValue, '"');
            $bitValue = self::trimEdge($bitValue, '\'');

            $attributes[$bitName] = $bitValue;
        }

        $url = self::trimEdge($value, '<');

        return new self($url, $attributes);
    }
114685
public function asXml(Shopgate_Model_XmlResultObject $itemNode)
    {
        /**
         * @var Shopgate_Model_XmlResultObject $categoryNode
         */
        $categoryNode = $itemNode->addChild('category');
        $categoryNode->addAttribute('uid', $this->getUid());
        $categoryNode->addAttribute('sort_order', (int)$this->getSortOrder());
        $categoryNode->addAttribute(
            'parent_uid',
            $this->getParentUid()
                ? $this->getParentUid()
                : null
        );
        $categoryNode->addAttribute('is_active', (int)$this->getIsActive());
        $categoryNode->addAttribute('is_anchor', (int)$this->getIsAnchor());
        $categoryNode->addChildWithCDATA('name', $this->getName());
        $categoryNode->addChildWithCDATA('deeplink', $this->getDeeplink());

        if ($this->getImage()) {
            $this->getImage()->asXml($categoryNode);
        }

        return $itemNode;
    }
103438
protected function findItem($tableName,$itemId)
  {
    $tableAlias = $this->getTableAlias($tableName);

    $qb = $this->dbConn->createQueryBuilder();
    $qb->select($this->getTableSelects($tableName,$tableAlias));
    $qb->from($tableName,$tableAlias);

    $primaryKeyName = $this->getTablePrimaryKey($tableName);

    $qb->andWhere($primaryKeyName . ' = :' . $primaryKeyName);

    $qb->setParameter($primaryKeyName,$itemId);

    $rows = $qb->execute()->fetchAll();

    return count($rows) === 1 ? $this->extractItem($tableAlias . '__',$rows[0]) : null;
  }
1362540
private function createMappingField(\DOMNode $fieldNode)
    {
        $fieldParam = ['type' => $fieldNode->getAttribute('type')];

        if ($fieldNode->hasAttribute('nestedPath')) {
            $fieldParam['nestedPath'] = $fieldNode->getAttribute('nestedPath');
        }

        foreach ($fieldNode->childNodes as $childNode) {
            if ($childNode instanceof \DOMElement) {
                $tagName = $this->underscore($childNode->tagName);
                $fieldParam['fieldConfig'][$tagName] = $childNode->nodeValue;
            }
        }

        return $fieldParam;
    }
273983
public static function fromString($itemValue)
    {
        $parts = HeaderUtils::split($itemValue, ';=');

        $part = array_shift($parts);
        $attributes = HeaderUtils::combine($parts);

        return new self($part[0], $attributes);
    }
126991
public function asXml(Shopgate_Model_XmlResultObject $itemNode)
    {
        /**
         * @var Shopgate_Model_XmlResultObject $shippingNode
         */
        $shippingNode = $itemNode->addChild('shipping');
        $shippingNode->addChild('costs_per_order', $this->getCostsPerOrder(), null, false);
        $shippingNode->addChild('additional_costs_per_unit', $this->getAdditionalCostsPerUnit(), null, false);
        $shippingNode->addChild('is_free', (int)$this->getIsFree());

        return $itemNode;
    }
30872
protected function _getValidContentNodeData($contentNode) {
        $contentNode = $contentNode instanceof Garp_Util_Configuration ? $contentNode : new Garp_Util_Configuration($contentNode);
        $contentNode
            ->obligate('model')
            ->obligate('data')
            ->obligate('columns')
            ->setDefault('type', '')
            ->setDefault('classes', '')
        ;
        return $contentNode;
    }
966024
public function itemCreate(Item $item)
    {
        $response = $this->getGuzzleClient()
            ->post(
                '/items',
                array_merge($this->setQuery(), $this->setBody($item))
            );

        return $this->serializer->deserialize(
            $response->getBody()->getContents(),
            Item::class,
            'json'
        );
    }
429803
protected function _createNodeArray( MShop_Locale_Item_Site_Interface $item )
	{
		$result = $item->toArray();

		if( method_exists( $item, 'getChildren' ) )
		{
			foreach( $item->getChildren() as $child ) {
				$result['children'][] = $this->_createNodeArray( $child );
			}
		}

		return (object) $result;
	}
184979
public function writeItem(array $item)
    {
        $newNode = $this->xml->createElement($this->rowNodeName);

        //attributes
        if (isset($item['@attributes']) && is_array($item['@attributes'])) {
            foreach ($item['@attributes'] as $key => $value) {
                $attr = $this->xml->createAttribute($key);
                $attr->value = $value;
                $newNode->appendChild($attr);
            }
            unset($item['@attributes']);
        }

        //values
        foreach ($item as $key => $value) {
            $node = $this->xml->createElement($key);
            $node->nodeValue = $value;
            $newNode->appendChild($node);
        }

        $this->rootNode->appendChild($newNode);

        return $this;
    }
316850
protected function getNode($xquery)
    {
      $nodeList = $this->document->getXPath()->query($xquery, $this->node);

      if($nodeList->length == 0)
        throw new Exception(__METHOD__ . '; ' . $xquery . ' node is missing');

      return $nodeList->item(0);
    }
184966
public function asXml(Shopgate_Model_XmlResultObject $itemNode)
    {
        /**
         * @var Shopgate_Model_XmlResultObject $imageNode
         */
        $imageNode = $itemNode->addChild('image');
        $imageNode->addAttribute('uid', $this->getUid());
        $imageNode->addAttribute('sort_order', $this->getSortOrder());
        $imageNode->addAttribute('is_cover', $this->getIsCover());
        $imageNode->addChildWithCDATA('url', $this->getUrl());
        $imageNode->addChildWithCDATA('title', $this->getTitle(), false);
        $imageNode->addChildWithCDATA('alt', $this->getAlt(), false);

        return $itemNode;
    }
692228
public function widgetToValue($varValue, $itemId)
    {
        if (null === $varValue) {
            return null;
        }
        static $cache = [];
        $attributeId = $this->get('id');
        if (array_key_exists($attributeId, $cache) && array_key_exists($varValue, $cache[$attributeId])) {
            return $cache[$attributeId][$varValue];
        }

        $model = $this->getSelectMetaModel();
        $alias = $this->getIdColumn();

        if ($model->hasAttribute($alias)) {
            $attribute = $model->getAttribute($alias);
            // It is an attribute, we may search for it.
            $ids = $attribute->searchFor($varValue);
        } else {
            // Must be a system column then.
            $result = $this->connection->createQueryBuilder()
                ->select('v.id')
                ->from($this->getSelectSource(), 'v')
                ->where('v.' . $this->getIdColumn() . '=:value')
                ->setParameter('value', $varValue)
                ->execute();

            $ids = $result->fetchAll(\PDO::FETCH_COLUMN);
        }

        // Maybe deleted value?
        if ([] === $ids) {
            return $cache[$attributeId][$varValue] = null;
        }

        // Multiple results.
        if (null === $ids || \count($ids) > 1) {
            throw new \RuntimeException(
                \sprintf(
                    'Multiple values found for %s, are there obsolete values for %s.%s (att_id: %s)?',
                    \var_export($varValue, true),
                    $model->getTableName(),
                    $this->getColName(),
                    $this->get('id')
                )
            );
        }
        $valueId = \array_shift($ids);

        $value = $this->getValuesById(
            [$valueId],
            [$this->getAliasColumn(), $this->getValueColumn(), $this->getIdColumn(), $this->getSortingColumn()]
        );

        return $cache[$attributeId][$varValue] = $value[$valueId];
    }
689933
static function createArrayFromDOMNode( $domNode )
    {
        if ( !$domNode )
        {
            return null;
        }

        $retArray = array();
        foreach ( $domNode->childNodes as $childNode )
        {
            if ( $childNode->nodeType != XML_ELEMENT_NODE )
            {
                continue;
            }

            if ( !isset( $retArray[$childNode->localName] ) )
            {
                $retArray[$childNode->localName] = array();
            }

            // If the node has children we create an array for this element
            // and append to it, if not we assign it directly
            if ( $childNode->hasChildNodes() )
            {
                $retArray[$childNode->localName][] = eZContentObjectPackageHandler::createArrayFromDOMNode( $childNode );
            }
            else
            {
                $retArray[$childNode->localName] = eZContentObjectPackageHandler::createArrayFromDOMNode( $childNode );
            }
        }
        foreach( $domNode->attributes as $attributeNode )
        {
            $retArray[$attributeNode->name] = $attributeNode->value;
        }

        return $retArray;
    }
825799
public function findItemsByItemTypeAndItemUid(string $itemType, int $itemUid) : array
    {
        $queryBuilder = $this->getQueryBuilder();
        $compositeExpression = $queryBuilder->expr()->andX(
            $queryBuilder->expr()->eq('item_type', $queryBuilder->getConnection()->quote($itemType, \PDO::PARAM_STR)),
            $queryBuilder->expr()->eq('item_uid', $itemUid)
        );
        return $this->getItemsByCompositeExpression($compositeExpression, $queryBuilder);
    }