Skip to content

Commit

Permalink
Moved Endpoint Proxies in Namespace Generator to Separate Folder
Browse files Browse the repository at this point in the history
Signed-off-by: saimedhi <[email protected]>
  • Loading branch information
saimedhi committed Jun 20, 2024
1 parent 649de7d commit 686911f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 39 deletions.
15 changes: 15 additions & 0 deletions util/EndpointProxies/indices/getAliasesProxy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

return <<<'EOD'
/**
* Alias function to getAlias()
*
* @deprecated added to prevent BC break introduced in 7.2.0
* @see https://github.com/elastic/elasticsearch-php/issues/940
*/
public function getAliases(array $params = [])
{
return $this->getAlias($params);
}
EOD;
12 changes: 12 additions & 0 deletions util/EndpointProxies/tasks/tasksListProxy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

return <<<'EOD'
/**
* Proxy function to list() to prevent BC break since 7.4.0
*/
public function tasksList(array $params = [])
{
return $this->list($params);
}
EOD;
46 changes: 7 additions & 39 deletions util/NamespaceEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,13 @@ public function renderClass(): string
foreach ($this->endpoints as $endpoint) {
$endpoints .= $this->renderEndpoint($endpoint);
}
// Fix for BC in 7.2.0
switch ($this->name) {
case 'indices':
$endpoints .= $this->getAliasesProxy();
break;
case 'tasks':
$endpoints .= $this->tasksListProxy();
break;

$proxyFolder = 'util/endpointproxies/' . $this->name;
if (is_dir($proxyFolder)) {
$proxyFiles = glob($proxyFolder . '/*.php');
foreach ($proxyFiles as $file) {
$endpoints .= require $file;
}
}
$class = str_replace(':endpoints', $endpoints, $class);

Expand Down Expand Up @@ -159,35 +158,4 @@ function ($matches) {
$name
);
}

protected function getAliasesProxy(): string
{
return <<<'EOD'
/**
* Alias function to getAlias()
*
* @deprecated added to prevent BC break introduced in 7.2.0
* @see https://github.com/elastic/elasticsearch-php/issues/940
*/
public function getAliases(array $params = [])
{
return $this->getAlias($params);
}
EOD;
}

protected function tasksListProxy(): string
{
return <<<'EOD'
/**
* Proxy function to list() to prevent BC break since 7.4.0
*/
public function tasksList(array $params = [])
{
return $this->list($params);
}
EOD;
}
}

0 comments on commit 686911f

Please sign in to comment.