public function test_decode_html_entities() { $inputRecords = [['integer' => 100, 'float' => 1.5, 'textWithHtml' => "<b>With bold text with html entities</b>", 'false' => false, 'true' => true, 'string' => 'Hi, this is a string']]; $result = DbAdapterHelper::decodeHtmlEntities($inputRecords); $this->assertEquals("100", $result[0]['integer'], "Could not decode integer"); $this->assertEquals("1.5", $result[0]['float'], "Could not decode float"); $this->assertEquals("<b>With bold text with html entities</b>", $result[0]['textWithHtml'], "Could not decode string with html tags"); $this->assertEquals("0", $result[0]['false'], "Could not decode boolean false"); $this->assertEquals("1", $result[0]['true'], "Could not decode boolean true"); $this->assertEquals("Hi, this is a string", $result[0]['string'], "Could not decode a string"); }
/** * Returns categories * * @param array $ids * @param array $columns * @return array * @throws \Exception */ public function read($ids, $columns) { if (!$ids && empty($ids)) { $message = SnippetsHelper::getNamespace()->get('adapters/orders/no_ids', 'Can not read orders without ids.'); throw new \Exception($message); } if (!$columns && empty($columns)) { $message = SnippetsHelper::getNamespace()->get('adapters/orders/no_column_names', 'Can not read orders without column names.'); throw new \Exception($message); } $builder = $this->getBuilder($columns, $ids); $orders = $builder->getQuery()->getResult(); $orders = DbAdapterHelper::decodeHtmlEntities($orders); $result['default'] = DbAdapterHelper::escapeNewLines($orders); return $result; }
/** * Reads order data from `s_order` table * * @param $ids * @param $columns * @return array * @throws \Exception */ public function read($ids, $columns) { if (!$ids) { $message = SnippetsHelper::getNamespace()->get('adapters/orders/no_ids', 'Can not read orders without ids.'); throw new \Exception($message); } if (!$columns) { $message = SnippetsHelper::getNamespace()->get('adapters/orders/no_column_names', 'Can not read orders without column names.'); throw new \Exception($message); } $result = []; // orders $orders = []; if (!empty($columns['order'])) { $orderBuilder = $this->getOrderBuilder($columns['order'], $ids); $orders = $orderBuilder->getQuery()->getResult(); $orders = DbAdapterHelper::decodeHtmlEntities($orders); $orders = DbAdapterHelper::escapeNewLines($orders); $result = ['order' => $orders]; } if (!empty($columns['taxRateSum'])) { $taxRateSums = $this->getTaxSums($ids, $orders); $result['taxRateSum'] = $taxRateSums; } return $result; }
/** * @param $ids * @param $columns * @return mixed * @throws \Exception */ public function read($ids, $columns) { if (!$ids && empty($ids)) { $message = $this->snippetHelper->getNamespace()->get('adapters/articles_no_ids', 'Can not read articles without ids.'); throw new \Exception($message); } if (!$columns && empty($columns)) { $message = $this->snippetHelper->getNamespace()->get('adapters/articles_no_column_names', 'Can not read articles without column names.'); throw new \Exception($message); } //articles $articleBuilder = $this->getArticleBuilder($columns['article'], $ids); $articles = $articleBuilder->getQuery()->getResult(); $result['article'] = $this->dbAdapterHelper->decodeHtmlEntities($articles); //prices $columns['price'] = array_merge($columns['price'], ['customerGroup.taxInput as taxInput', 'articleTax.tax as tax']); $priceBuilder = $this->getPriceBuilder($columns['price'], $ids); $result['price'] = $priceBuilder->getQuery()->getResult(); if ($result['purchasePrice']) { $result['purchasePrice'] = round($result['purchasePrice'], 2); } foreach ($result['price'] as &$record) { if ($record['taxInput']) { $record['price'] = round($record['price'] * (100 + $record['tax']) / 100, 2); $record['pseudoPrice'] = round($record['pseudoPrice'] * (100 + $record['tax']) / 100, 2); } else { $record['price'] = round($record['price'], 2); $record['pseudoPrice'] = round($record['pseudoPrice'], 2); } if (!$record['inStock']) { $record['inStock'] = '0'; } } //images $imageBuilder = $this->getImageBuilder($columns['image'], $ids); $tempImageResult = $imageBuilder->getQuery()->getResult(); foreach ($tempImageResult as &$tempImage) { $tempImage['imageUrl'] = $this->mediaService->getUrl($tempImage['imageUrl']); } $result['image'] = $tempImageResult; //filter values $propertyValuesBuilder = $this->getPropertyValueBuilder($columns['propertyValues'], $ids); $result['propertyValue'] = $propertyValuesBuilder->getQuery()->getResult(); //configurator $configBuilder = $this->getConfiguratorBuilder($columns['configurator'], $ids); $result['configurator'] = $configBuilder->getQuery()->getResult(); //similar $similarsBuilder = $this->getSimilarBuilder($columns['similar'], $ids); $result['similar'] = $similarsBuilder->getQuery()->getResult(); //accessories $accessoryBuilder = $this->getAccessoryBuilder($columns['accessory'], $ids); $result['accessory'] = $accessoryBuilder->getQuery()->getResult(); //categories $result['category'] = $this->prepareCategoryExport($ids, $columns['category']); $result['translation'] = $this->prepareTranslationExport($ids); return $result; }
/** * Returns categories * * @param $ids * @param $columns * @return mixed * * @throws \Exception */ public function read($ids, $columns) { if (!$ids && empty($ids)) { $message = SnippetsHelper::getNamespace()->get('adapters/categories/no_ids', 'Can not read categories without ids.'); throw new \Exception($message); } if (!$columns && empty($columns)) { $message = SnippetsHelper::getNamespace()->get('adapters/categories/no_column_names', 'Can not read categories without column names.'); throw new \Exception($message); } $builder = $this->getBuilder($columns['default'], $ids); $categories = $builder->getQuery()->getArrayResult(); $result['default'] = DbAdapterHelper::decodeHtmlEntities($categories); $result['customerGroups'] = $this->getBuilder($this->getCustomerGroupsColumns(), $ids)->getQuery()->getResult(); return $result; }
/** * @param array $ids * @param array $columns * @return array */ public function read($ids, $columns) { foreach ($columns as $key => $value) { if ($value == 'unhashedPassword') { unset($columns[$key]); } } $builder = $this->getBuilder($columns, $ids); $query = $builder->getQuery(); $query->setHydrationMode(AbstractQuery::HYDRATE_ARRAY); $paginator = $this->manager->createPaginator($query); $customers = $paginator->getIterator()->getArrayCopy(); $result['default'] = DbAdapterHelper::decodeHtmlEntities($customers); return $result; }