Skip to content

Commit

Permalink
(Host/Service)Controller: Change method name and fix syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 committed Jan 17, 2025
1 parent 25d1b6b commit 47b30c2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
24 changes: 12 additions & 12 deletions application/controllers/HostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public function servicesAction(): Generator

public function parentsAction(): Generator
{
$nodesQuery = $this->fetchNodes(true);
$nodesQuery = $this->fetchDependencyNodes(true);

$limitControl = $this->createLimitControl();
$paginationControl = $this->createPaginationControl($nodesQuery);
Expand Down Expand Up @@ -304,7 +304,7 @@ public function parentsAction(): Generator

public function childrenAction(): Generator
{
$nodesQuery = $this->fetchNodes();
$nodesQuery = $this->fetchDependencyNodes();

$limitControl = $this->createLimitControl();
$paginationControl = $this->createPaginationControl($nodesQuery);
Expand Down Expand Up @@ -411,13 +411,13 @@ public function searchEditorAction(): void
}

/**
* 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([
Expand All @@ -434,7 +434,7 @@ protected function fetchNodes(bool $fetchParents = false): Query
])
->setResultSetClass(VolatileStateResults::class);

$this->joinFix($query, $this->host->id, $fetchParents);
$this->joinFix($query, $this->host->id, $parents);

$this->applyRestrictions($query);

Expand All @@ -447,12 +447,12 @@ protected function createTabs(): Tabs
$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', '*')
))
->first() !== null;
->columns([new Expression('1')])
->filter(Filter::all(
Filter::equal('host_id', $this->host->id),
Filter::unlike('service_id', '*')
))
->first() !== null;
}

$tabs = $this->getTabs()
Expand Down
24 changes: 12 additions & 12 deletions application/controllers/ServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function indexAction(): void

public function parentsAction(): Generator
{
$nodesQuery = $this->fetchNodes(true);
$nodesQuery = $this->fetchDependencyNodes(true);

$limitControl = $this->createLimitControl();
$paginationControl = $this->createPaginationControl($nodesQuery);
Expand Down Expand Up @@ -175,7 +175,7 @@ public function parentsAction(): Generator

public function childrenAction(): Generator
{
$nodesQuery = $this->fetchNodes();
$nodesQuery = $this->fetchDependencyNodes();

$limitControl = $this->createLimitControl();
$paginationControl = $this->createPaginationControl($nodesQuery);
Expand Down Expand Up @@ -381,13 +381,13 @@ public function searchEditorAction(): void
}

/**
* 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([
Expand All @@ -403,7 +403,7 @@ protected function fetchNodes(bool $fetchParents = false): Query
'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);
Expand All @@ -419,12 +419,12 @@ protected function createTabs(): Tabs
$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)
))
->first() !== null;
->columns([new Expression('1')])
->filter(Filter::all(
Filter::equal('service_id', $this->service->id),
Filter::equal('host_id', $this->service->host_id)
))
->first() !== null;
}

$tabs = $this->getTabs()
Expand Down

0 comments on commit 47b30c2

Please sign in to comment.