Skip to content
This repository was archived by the owner on Jun 25, 2025. It is now read-only.

Commit 5093446

Browse files
committed
Renamed all own classes due to incompatibilities across modules
- All classes start with Apisearch
1 parent 42f558b commit 5093446

11 files changed

+58
-58
lines changed

ajax.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@
3939

4040
function syncProducts()
4141
{
42-
require_once __DIR__ . '/model/exporter.php';
43-
require_once __DIR__ . '/model/builder.php';
44-
require_once __DIR__ . '/model/connection.php';
42+
require_once __DIR__ . '/model/apisearch_exporter.php';
43+
require_once __DIR__ . '/model/apisearch_builder.php';
44+
require_once __DIR__ . '/model/apisearch_connection.php';
4545
require_once __DIR__ . '/apisearch.php';
4646

47-
$exporter = new Exporter(
48-
new Builder(),
49-
new Connection()
47+
$exporter = new ApisearchExporter(
48+
new ApisearchBuilder(),
49+
new ApisearchConnection()
5050
);
5151

5252
$exporter->exportAll();

apisearch.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
exit;
2929
}
3030

31-
require_once __DIR__ . '/model/defaults.php';
32-
require_once __DIR__ . '/model/hooks.php';
33-
require_once __DIR__ . '/model/builder.php';
34-
require_once __DIR__ . '/model/connection.php';
31+
require_once __DIR__ . '/model/apisearch_defaults.php';
32+
require_once __DIR__ . '/model/apisearch_hooks.php';
33+
require_once __DIR__ . '/model/apisearch_builder.php';
34+
require_once __DIR__ . '/model/apisearch_connection.php';
3535

3636
class Apisearch extends Module
3737
{
@@ -41,35 +41,35 @@ class Apisearch extends Module
4141

4242
public function __construct()
4343
{
44-
$this->name = Defaults::PLUGIN_NAME;
44+
$this->name = ApisearchDefaults::PLUGIN_NAME;
4545
$this->tab = 'search_filter';
46-
$this->version = Defaults::PLUGIN_VERSION;
46+
$this->version = ApisearchDefaults::PLUGIN_VERSION;
4747
$this->author = 'Apisearch Team';
4848
$this->need_instance = 0;
4949
$this->bootstrap = true;
5050
parent::__construct();
5151
$this->displayName = $this->l('Apisearch');
5252
$this->description = $this->l('Search over your products, and give to your users unique, amazing and unforgettable experiences.');
5353
$this->ps_versions_compliancy = array('min' => '1.5', 'max' => _PS_VERSION_);
54-
$this->connection = new Connection();
55-
$this->hooks = new Hooks(
56-
new Builder(),
54+
$this->connection = new ApisearchConnection();
55+
$this->hooks = new ApisearchHooks(
56+
new ApisearchBuilder(),
5757
$this->connection
5858
);
5959
}
6060

6161
public function install()
6262
{
6363
Configuration::updateValue('AS_CLUSTER_URL', '');
64-
Configuration::updateValue('AS_ADMIN_URL', Defaults::DEFAULT_AS_ADMIN_URL);
65-
Configuration::updateValue('AS_API_VERSION', Defaults::DEFAULT_AS_API_VERSION);
64+
Configuration::updateValue('AS_ADMIN_URL', ApisearchDefaults::DEFAULT_AS_ADMIN_URL);
65+
Configuration::updateValue('AS_API_VERSION', ApisearchDefaults::DEFAULT_AS_API_VERSION);
6666
Configuration::updateValue('AS_APP', '');
6767
Configuration::updateValue('AS_INDEX', '');
6868
Configuration::updateValue('AS_TOKEN', '');
6969
Configuration::updateValue('AS_SHOP', '');
70-
Configuration::updateValue('AS_INDEX_PRODUCTS_WITHOUT_IMAGE', Defaults::DEFAULT_INDEX_PRODUCTS_WITHOUT_IMAGE);
71-
Configuration::updateValue('AS_REAL_TIME_INDEXATION', Defaults::DEFAULT_REAL_TIME_INDEXATION);
72-
Configuration::updateValue('AS_INDEX_PRODUCT_PURCHASE_COUNT', Defaults::DEFAULT_REAL_TIME_INDEXATION);
70+
Configuration::updateValue('AS_INDEX_PRODUCTS_WITHOUT_IMAGE', ApisearchDefaults::DEFAULT_INDEX_PRODUCTS_WITHOUT_IMAGE);
71+
Configuration::updateValue('AS_REAL_TIME_INDEXATION', ApisearchDefaults::DEFAULT_REAL_TIME_INDEXATION);
72+
Configuration::updateValue('AS_INDEX_PRODUCT_PURCHASE_COUNT', ApisearchDefaults::DEFAULT_REAL_TIME_INDEXATION);
7373

7474
$meta_as = new Meta();
7575
$meta_as->page = 'module-apisearch-as_search';
@@ -164,21 +164,21 @@ protected function getConfigForm()
164164
'col' => 3,
165165
'type' => 'text',
166166
'label' => $this->l('Apisearch Cluster Url'),
167-
'placeholder' => Defaults::DEFAULT_AS_CLUSTER_URL,
167+
'placeholder' => ApisearchDefaults::DEFAULT_AS_CLUSTER_URL,
168168
'name' => 'AS_CLUSTER_URL',
169169
),
170170
array(
171171
'col' => 3,
172172
'type' => 'text',
173173
'label' => $this->l('Apisearch Admin Url'),
174-
'placeholder' => Defaults::DEFAULT_AS_ADMIN_URL,
174+
'placeholder' => ApisearchDefaults::DEFAULT_AS_ADMIN_URL,
175175
'name' => 'AS_ADMIN_URL',
176176
),
177177
array(
178178
'col' => 3,
179179
'type' => 'text',
180180
'label' => $this->l('Apisearch Api Version'),
181-
'placeholder' => Defaults::DEFAULT_AS_API_VERSION,
181+
'placeholder' => ApisearchDefaults::DEFAULT_AS_API_VERSION,
182182
'name' => 'AS_API_VERSION',
183183
),
184184
array(
@@ -326,7 +326,7 @@ public function hookHeader()
326326
if ($this->connection->isProperlyConfigured()) {
327327
$admin_url = Configuration::get('AS_ADMIN_URL');
328328
$admin_url = $admin_url == ""
329-
? Defaults::DEFAULT_AS_ADMIN_URL
329+
? ApisearchDefaults::DEFAULT_AS_ADMIN_URL
330330
: $admin_url;
331331

332332
Media::addJsDef(array(

apisearch_index_all.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
include_once dirname(__FILE__) . '/../../config/config.inc.php';
2828
include_once dirname(__FILE__) . '/../../init.php';
2929

30-
require_once __DIR__ . '/model/exporter.php';
31-
require_once __DIR__ . '/model/builder.php';
32-
require_once __DIR__ . '/model/connection.php';
30+
require_once __DIR__ . '/model/apisearch_exporter.php';
31+
require_once __DIR__ . '/model/apisearch_builder.php';
32+
require_once __DIR__ . '/model/apisearch_connection.php';
3333
require_once __DIR__ . '/apisearch.php';
3434

3535
$apisearch = new Apisearch();
36-
$exporter = new Exporter(
37-
new Builder(),
38-
new Connection()
36+
$exporter = new ApisearchExporter(
37+
new ApisearchBuilder(),
38+
new ApisearchConnection()
3939
);
4040

4141
$start = \time();

model/builder.php renamed to model/apisearch_builder.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

3-
require_once __DIR__ . '/defaults.php';
4-
require_once __DIR__ . '/as_product.php';
3+
require_once __DIR__ . '/apisearch_defaults.php';
4+
require_once __DIR__ . '/apisearch_product.php';
55

6-
class Builder
6+
class ApisearchBuilder
77
{
88
private $avoidProductsWithoutImage;
99
private $indexProductPurchaseCount;
@@ -47,7 +47,7 @@ public function buildItems($productsId, $langId, $version, $batch, $shopId, Call
4747
*/
4848
public function buildChunkItems($productsId, $langId, $version, $shopId, Callable $flushCallable)
4949
{
50-
$products = ASProduct::getFullProductsById($productsId, $langId, $shopId);
50+
$products = ApisearchProduct::getFullProductsById($productsId, $langId, $shopId);
5151
$items = array_filter(array_map(function($product) use ($langId, $version) {
5252
return $this->buildItemFromProduct($product, $langId, $version);
5353
}, $products));
@@ -100,7 +100,7 @@ public function buildItemFromProduct($product, $langId, $version)
100100
$attributes = array();
101101
$features = array();
102102
if (in_array($product['visibility'], array('both', 'search'))) {
103-
$combinations = ASProduct::getAttributeCombinations($productId, $langId);
103+
$combinations = ApisearchProduct::getAttributeCombinations($productId, $langId);
104104
$available = false;
105105

106106
foreach ($combinations as $combination) {
@@ -140,7 +140,7 @@ public function buildItemFromProduct($product, $langId, $version)
140140
}
141141

142142
$link = (string)Context::getContext()->link->getProductLink($productId);
143-
$image = (string)Context::getContext()->link->getImageLink($product['link_rewrite'] ?? Defaults::PLUGIN_NAME, $img, 'home_default');
143+
$image = (string)Context::getContext()->link->getImageLink($product['link_rewrite'] ?? ApisearchDefaults::PLUGIN_NAME, $img, 'home_default');
144144
if (rand(0, 10) === 0) {
145145
$available = 'HOLA';
146146
}

model/connection.php renamed to model/apisearch_connection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

33
require_once __DIR__ . '/apisearch_client.php';
4-
require_once __DIR__ . '/defaults.php';
4+
require_once __DIR__ . '/apisearch_defaults.php';
55

66
/**
77
* Class Connection
88
*/
9-
class Connection
9+
class ApisearchConnection
1010
{
1111
private $currentClient;
1212

@@ -42,9 +42,9 @@ public function getConnectionByLanguageId($langId = '')
4242
}
4343

4444
$clusterUrl = Configuration::get('AS_CLUSTER_URL');
45-
$clusterUrl = $clusterUrl == "" ? Defaults::DEFAULT_AS_CLUSTER_URL : $clusterUrl;
45+
$clusterUrl = $clusterUrl == "" ? ApisearchDefaults::DEFAULT_AS_CLUSTER_URL : $clusterUrl;
4646
$apiVersion = Configuration::get('AS_API_VERSION');
47-
$apiVersion = $apiVersion == "" ? Defaults::DEFAULT_AS_API_VERSION : $apiVersion;
47+
$apiVersion = $apiVersion == "" ? ApisearchDefaults::DEFAULT_AS_API_VERSION : $apiVersion;
4848

4949

5050
$appId = Configuration::get('AS_APP');

model/defaults.php renamed to model/apisearch_defaults.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
class Defaults {
3+
class ApisearchDefaults {
44
const DEFAULT_AS_CLUSTER_URL = 'https://eu1.apisearch.cloud';
55
const DEFAULT_AS_ADMIN_URL = 'https://static.apisearch.cloud';
66
const DEFAULT_AS_API_VERSION = 'v1';

model/exporter.php renamed to model/apisearch_exporter.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?php
22

3-
require_once __DIR__ .'/as_product.php';
3+
require_once __DIR__ . '/apisearch_product.php';
44

5-
class Exporter
5+
class ApisearchExporter
66
{
77
private $builder;
88
private $connection;
99

1010
/**
11-
* @param Builder $builder
12-
* @param Connection $connection
11+
* @param ApisearchBuilder $builder
12+
* @param ApisearchConnection $connection
1313
*/
14-
public function __construct(Builder $builder, Connection $connection)
14+
public function __construct(ApisearchBuilder $builder, ApisearchConnection $connection)
1515
{
1616
$this->builder = $builder;
1717
$this->connection = $connection;
@@ -143,7 +143,7 @@ private function getNonFeaturedShopProducts($langId, $shopId)
143143
$offset = 0;
144144
$productsId = array();
145145
while (true) {
146-
$products = ASProduct::getProductsId($langId, $offset, $count, $shopId);
146+
$products = ApisearchProduct::getProductsId($langId, $offset, $count, $shopId);
147147
if (!empty($products)) {
148148
$productsId = array_merge($productsId, array_map(function(array $product) {
149149
return $product['id_product'];

model/hooks.php renamed to model/apisearch_hooks.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?php
22

3-
require_once __DIR__ . '/defaults.php';
3+
require_once __DIR__ . '/apisearch_defaults.php';
44

5-
class Hooks
5+
class ApisearchHooks
66
{
77
private $builder;
88
private $connection;
99

1010
/**
11-
* @param $builder
12-
* @param $connection
11+
* @param ApisearchBuilder $builder
12+
* @param ApisearchConnection $connection
1313
*/
14-
public function __construct($builder, $connection)
14+
public function __construct(ApisearchBuilder $builder, ApisearchConnection $connection)
1515
{
1616
$this->builder = $builder;
1717
$this->connection = $connection;

model/as_manufacturer.php renamed to model/apisearch_manufacturer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
class ASManufacturer
3+
class ApisearchManufacturer
44
{
55
private static $manufacturers = array();
66

model/as_product.php renamed to model/apisearch_product.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

3-
require_once __DIR__ . '/as_manufacturer.php';
4-
require_once __DIR__ . '/as_supplier.php';
3+
require_once __DIR__ . '/apisearch_manufacturer.php';
4+
require_once __DIR__ . '/apisearch_supplier.php';
55

6-
class ASProduct
6+
class ApisearchProduct
77
{
88
/**
99
* @param $langId
@@ -55,8 +55,8 @@ public static function getFullProductsById($productsId, $langId, $shopId)
5555

5656
$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
5757
$productsIndexedById = [];
58-
$manufacturers = ASManufacturer::getManufacturers(array_column($products, 'id_manufacturer'));
59-
$suppliers = ASManufacturer::getManufacturers(array_column($products, 'id_supplier'));
58+
$manufacturers = ApisearchManufacturer::getManufacturers(array_column($products, 'id_manufacturer'));
59+
$suppliers = ApisearchManufacturer::getManufacturers(array_column($products, 'id_supplier'));
6060
foreach ($products as $product) {
6161
$product['manufacturer'] = $manufacturers[$product['id_manufacturer']] ?? '';
6262
$product['supplier'] = $suppliers[$product['id_supplier']] ?? '';

0 commit comments

Comments
 (0)