(Host/Service)Controller: Change method name and fix syntax

This commit is contained in:
Sukhwinder Dhillon 2025-01-17 08:40:35 +01:00
parent 41601abff7
commit 3602d5ab65
2 changed files with 26 additions and 26 deletions

View file

@ -238,7 +238,7 @@ class HostController extends Controller
public function parentsAction(): Generator
{
$nodesQuery = $this->fetchNodes(true);
$nodesQuery = $this->fetchDependencyNodes(true);
$limitControl = $this->createLimitControl();
$paginationControl = $this->createPaginationControl($nodesQuery);
@ -301,7 +301,7 @@ class HostController extends Controller
public function childrenAction(): Generator
{
$nodesQuery = $this->fetchNodes();
$nodesQuery = $this->fetchDependencyNodes();
$limitControl = $this->createLimitControl();
$paginationControl = $this->createPaginationControl($nodesQuery);
@ -405,13 +405,13 @@ class HostController extends Controller
}
/**
* Fetch the nodes for the current host
* Fetch the dependency nodes of the current host
*
* @param bool $fetchParents Whether to fetch the parents or the children
* @param bool $parents Whether to fetch the parents or the children
*
* @return Query
*/
protected function fetchNodes(bool $fetchParents = false): Query
protected function fetchDependencyNodes(bool $parents = false): Query
{
$query = DependencyNode::on($this->getDb())
->with([
@ -428,7 +428,7 @@ class HostController extends Controller
])
->setResultSetClass(VolatileStateResults::class);
$this->joinFix($query, $this->host->id, $fetchParents);
$this->joinFix($query, $this->host->id, $parents);
$this->applyRestrictions($query);
@ -441,13 +441,13 @@ class HostController extends Controller
$hasDependencyNode = false;
} else {
$hasDependencyNode = DependencyNode::on($this->getDb())
->columns([new Expression('1')])
->filter(Filter::all(
Filter::equal('host_id', $this->host->id),
Filter::unlike('service_id', '*')
))
->disableDefaultSort()
->first() !== null;
->columns([new Expression('1')])
->filter(Filter::all(
Filter::equal('host_id', $this->host->id),
Filter::unlike('service_id', '*')
))
->disableDefaultSort()
->first() !== null;
}
$tabs = $this->getTabs()

View file

@ -108,7 +108,7 @@ class ServiceController extends Controller
public function parentsAction(): Generator
{
$nodesQuery = $this->fetchNodes(true);
$nodesQuery = $this->fetchDependencyNodes(true);
$limitControl = $this->createLimitControl();
$paginationControl = $this->createPaginationControl($nodesQuery);
@ -172,7 +172,7 @@ class ServiceController extends Controller
public function childrenAction(): Generator
{
$nodesQuery = $this->fetchNodes();
$nodesQuery = $this->fetchDependencyNodes();
$limitControl = $this->createLimitControl();
$paginationControl = $this->createPaginationControl($nodesQuery);
@ -375,13 +375,13 @@ class ServiceController extends Controller
}
/**
* Fetch the nodes for the current service
* Fetch the dependency nodes of the current service
*
* @param bool $fetchParents Whether to fetch the parents or the children
* @param bool $parents Whether to fetch the parents or the children
*
* @return Query
*/
protected function fetchNodes(bool $fetchParents = false): Query
protected function fetchDependencyNodes(bool $parents = false): Query
{
$query = DependencyNode::on($this->getDb())
->with([
@ -397,7 +397,7 @@ class ServiceController extends Controller
'redundancy_group.state'
])
->filter(Filter::equal(
sprintf('%s.service.id', $fetchParents ? 'child' : 'parent'),
sprintf('%s.service.id', $parents ? 'child' : 'parent'),
$this->service->id
))
->setResultSetClass(VolatileStateResults::class);
@ -413,13 +413,13 @@ class ServiceController extends Controller
$hasDependencyNode = false;
} else {
$hasDependencyNode = DependencyNode::on($this->getDb())
->columns([new Expression('1')])
->filter(Filter::all(
Filter::equal('service_id', $this->service->id),
Filter::equal('host_id', $this->service->host_id)
))
->disableDefaultSort()
->first() !== null;
->columns([new Expression('1')])
->filter(Filter::all(
Filter::equal('service_id', $this->service->id),
Filter::equal('host_id', $this->service->host_id)
))
->disableDefaultSort()
->first() !== null;
}
$tabs = $this->getTabs()