Skip to content

Commit

Permalink
[BF] - Editing a patch panel port - populates incorrect switch port -…
Browse files Browse the repository at this point in the history
… islandbridgenetworks/IXP-Manager#60
  • Loading branch information
yannrobin committed Oct 6, 2017
1 parent 1a9d5ab commit 0c2fb6c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/Http/Controllers/PatchPanel/PatchPanelPortController.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,19 @@ public function edit( int $id, string $formType = null ): View {
// If we're allocating this port, set the chargable flag to the patch panel's default:
$chargeable = ( $allocating and $ppp->isStateAvailable()) ? $ppp->getPatchPanel()->getChargeable() : $ppp->getChargeable();


if( $ppp->getSwitchPort() ) {
// FIXME: Queries and logic could be improved.
/** @noinspection PhpUndefinedMethodInspection - need to sort D2EM::getRepository factory inspection */
$switchPorts = D2EM::getRepository(SwitcherEntity::class)->getAllPortsNotAssignedToPI( $ppp->getSwitchPort()->getSwitcher()->getId(), [], $ppp->getSwitchPort()->getId() );

// we add the current switch port in the list to display it
$switchPorts[ ] = [ "name" => $ppp->getSwitchPort()->getName(),
"typeid" => $ppp->getSwitchPort()->getType(),
"type" => $ppp->getSwitchPort()->resolveType(),
"id" => $ppp->getSwitchPort()->getId() ];

array_multisort( array_column( $switchPorts, 'id' ), SORT_ASC, $switchPorts );
}

// fill the form with patch panel port data
Expand Down
9 changes: 9 additions & 0 deletions database/Entities/SwitchPort.php
Original file line number Diff line number Diff line change
Expand Up @@ -971,4 +971,13 @@ public function getPatchPanelPort()
{
return $this->patchPanelPort;
}

/**
* Turn the database integer representation of the type into text as
* defined in the self::$TYPES array (or 'Unknown')
* @return string
*/
public function resolveType(): string {
return self::$TYPES[ $this->getType() ];
}
}
11 changes: 11 additions & 0 deletions database/Proxies/__CG__EntitiesSwitchPort.php
Original file line number Diff line number Diff line change
Expand Up @@ -870,4 +870,15 @@ public function getPatchPanelPort()
return parent::getPatchPanelPort();
}

/**
* {@inheritDoc}
*/
public function resolveType(): string
{

$this->__initializer__ && $this->__initializer__->__invoke($this, 'resolveType', []);

return parent::resolveType();
}

}

0 comments on commit 0c2fb6c

Please sign in to comment.