Skip to content

Commit

Permalink
Rename hashKey to subKey where needed
Browse files Browse the repository at this point in the history
  • Loading branch information
hollodotme committed May 12, 2018
1 parent 3f2c49e commit 21b7b1d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 23 deletions.
14 changes: 8 additions & 6 deletions src/Application/Configs/IceHawkConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ private function buildReadRoutes() : void
$quotedBaseUri = preg_quote( $baseUrl, '!' );

$this->readRoutes = [
'^' . $quotedBaseUri . '/?$' => ServerSelectionRequestHandler::class,
'^' . $quotedBaseUri . '/server/(?<serverKey>\d+)/stats/?$' => ServerStatsRequestHandler::class,
'^' . $quotedBaseUri . '/server/(?<serverKey>\d+)(?:/database/(?<database>\d+))?/?$' => ServerDetailsRequestHandler::class,
'^' . $quotedBaseUri . '/server/(?<serverKey>\d+)/database/(?<database>\d+)/keys/?$' => AjaxSearchKeysRequestHandler::class,
'^' . $quotedBaseUri . '/server/(?<serverKey>\d+)/database/(?<database>\d+)/keys/(?<keyName>.+)/hash/(?<hashKey>.+)/?$' => AjaxKeyDetailsRequestHandler::class,
'^' . $quotedBaseUri . '/server/(?<serverKey>\d+)/database/(?<database>\d+)/keys/(?<keyName>.+)/?$' => AjaxKeyDetailsRequestHandler::class,
'^' . $quotedBaseUri . '/?$' => ServerSelectionRequestHandler::class,
'^' . $quotedBaseUri . '/server/(?<serverKey>\d+)/stats/?$' => ServerStatsRequestHandler::class,
'^' . $quotedBaseUri . '/server/(?<serverKey>\d+)(?:/database/(?<database>\d+))?/?$' => ServerDetailsRequestHandler::class,
'^' . $quotedBaseUri . '/server/(?<serverKey>\d+)/database/(?<database>\d+)/keys/?$' => AjaxSearchKeysRequestHandler::class,
'^'
. $quotedBaseUri
. '/server/(?<serverKey>\d+)/database/(?<database>\d+)/keys/(?<keyName>.+)/hash/(?<subKey>.+)/?$' => AjaxKeyDetailsRequestHandler::class,
'^' . $quotedBaseUri . '/server/(?<serverKey>\d+)/database/(?<database>\d+)/keys/(?<keyName>.+)/?$' => AjaxKeyDetailsRequestHandler::class,
];
}
}
10 changes: 5 additions & 5 deletions src/Application/ReadModel/Queries/FetchKeyInformationQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ final class FetchKeyInformationQuery
private $keyName;

/** @var null|string */
private $hashKey;
private $subKey;

public function __construct( string $serverKey, int $database, string $keyName, ?string $hashKey )
public function __construct( string $serverKey, int $database, string $keyName, ?string $subKey )
{
$this->serverKey = $serverKey;
$this->database = $database;
$this->keyName = $keyName;
$this->hashKey = $hashKey;
$this->subKey = $subKey;
}

public function getServerKey() : string
Expand All @@ -39,8 +39,8 @@ public function getKeyName() : string
return $this->keyName;
}

public function getHashKey() : ?string
public function getSubKey() : ?string
{
return $this->hashKey;
return $this->subKey;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function handle( FetchKeyInformationQuery $query ) : FetchKeyInformationR

$keyInfo = $manager->getKeyInfoObject( $query->getKeyName() );

$keyName = new KeyName( $query->getKeyName(), $query->getHashKey() );
$keyName = new KeyName( $query->getKeyName(), $query->getSubKey() );
$keyData = $this->getKeyData( $manager, $keyInfo, $keyName );

$result = new FetchKeyInformationResult();
Expand Down
14 changes: 7 additions & 7 deletions src/Application/Web/Server/Read/AjaxKeyDetailsRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ public function handle( ProvidesReadRequestData $request )
$input = $request->getInput();
$serverKey = (string)$input->get( 'serverKey', '0' );
$key = base64_decode( (string)$input->get( 'keyName' ) );
$hashKey = base64_decode( $input->get( 'hashKey', '' ) );
if ( '' === $hashKey )
$subKey = base64_decode( $input->get( 'subKey', '' ) );
if ( '' === $subKey )
{
$hashKey = null;
$subKey = null;
}
$database = (int)$input->get( 'database', 0 );

$query = new FetchKeyInformationQuery( $serverKey, $database, $key, $hashKey );
$query = new FetchKeyInformationQuery( $serverKey, $database, $key, $subKey );
$result = (new FetchKeyInformationQueryHandler( $this->getEnv() ))->handle( $query );

if ( $result->failed() )
Expand All @@ -42,9 +42,9 @@ public function handle( ProvidesReadRequestData $request )
}

$data = [
'keyData' => $result->getKeyData(),
'keyInfo' => $result->getKeyInfo(),
'hashKey' => $hashKey,
'keyData' => $result->getKeyData(),
'keyInfo' => $result->getKeyInfo(),
'subKey' => $subKey,
];

(new TwigPage())->respond( 'Server/Read/Pages/Includes/KeyData.twig', $data );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="modal-header">
<span class="modal-title">
Content of:
<code>{{ keyInfo.getName }}{% if hashKey is not empty %} &raquo; {{ hashKey }}{% endif %}</code>
<code>{{ keyInfo.getName }}{% if subKey is not empty %} &raquo; {{ subKey }}{% endif %}</code>
</span>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
Expand Down
6 changes: 3 additions & 3 deletions src/Application/Web/Server/Read/Pages/Includes/KeyList.twig
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
(show all members)
</a>
</li>
{% for hashKey in keyInfo.getSubItems %}
{% for member in keyInfo.getSubItems %}
<li>
<a href="{{ appConfig.getBaseUrl }}/server/{{ serverKey }}/database/{{ database }}/keys/{{ keyInfo.getName|base64encode }}/hash/{{ loop.index0|base64encode }}"
data-toggle="modal" data-target="#keyInfoModal" role="button">
Expand Down Expand Up @@ -104,9 +104,9 @@
(show all elements)
</a>
</li>
{% for hashKey,value in keyInfo.getSubItems %}
{% for index,value in keyInfo.getSubItems %}
<li>
<a href="{{ appConfig.getBaseUrl }}/server/{{ serverKey }}/database/{{ database }}/keys/{{ keyInfo.getName|base64encode }}/hash/{{ hashKey|base64encode }}"
<a href="{{ appConfig.getBaseUrl }}/server/{{ serverKey }}/database/{{ database }}/keys/{{ keyInfo.getName|base64encode }}/hash/{{ index|base64encode }}"
data-toggle="modal" data-target="#keyInfoModal" role="button">
List element
</a>
Expand Down

0 comments on commit 21b7b1d

Please sign in to comment.