Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix getRouteData #41

Merged
merged 3 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"homepage": "http://www.bajb.net"
}
],
"config": {
"allow-plugins": false
},
"require": {
"php": ">=7.0",
"psr/log": "~1.0",
Expand Down
5 changes: 2 additions & 3 deletions src/Http/Visitor/MaxmindVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MaxmindVisitor implements IVisitorInfo
public function configure(ConfigSectionInterface $config)
{
$this->_config = $config;
$mode = $config->getItem('mode', 'reader');
$mode = $config->getItem('mode', 'reader');
if($mode == 'reader')
{
$this->_reader = new Reader(
Expand All @@ -45,7 +45,7 @@ public function configure(ConfigSectionInterface $config)
new \Exception("No maxmind licence key specified")
),
ValueAs::arr($config->getItem('locales', 'en')),
$config->getItem('host', 'geoip.maxmind.com')
['host' => $config->getItem('host', 'geoip.maxmind.com')]
);
}
}
Expand Down Expand Up @@ -85,7 +85,6 @@ protected function _getConfig($key, $default)
* as an ISO 3166-1 alpha-2 country code.
*
* @return string
*
* @throws \Exception
*/
public function getCountry()
Expand Down
13 changes: 7 additions & 6 deletions src/Kernel/CubexKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public function defaultRoute()

/**
* Authentication hook, allowing validation before the router is attempted
*
* To verify the process can process, return true.
* To reject the request, and return a custom response, simply return the
* desired response
Expand All @@ -127,7 +126,6 @@ public function canProcess()

/**
* Handles a Request to convert it to a Response.
*
* When $catch is true, the implementation must catch all exceptions
* and do its best to convert them to a Response instance.
*
Expand All @@ -138,9 +136,7 @@ public function canProcess()
* @param Boolean $catch Whether to catch exceptions or not
*
* @return Response A Response instance
*
* @throws \Exception When an Exception occurs during processing
*
* @api
*/
public function handle(
Expand Down Expand Up @@ -331,7 +327,7 @@ public function autoRoute(Request $request, $pathParts)
*/
public function executeRoute(
IRoute $route, Request $request, $type = self::MASTER_REQUEST,
$catch = true
$catch = true
)
{
$value = $route->getValue();
Expand Down Expand Up @@ -482,7 +478,6 @@ protected function _processResponse(
* @param null|array $params Parameters to send into the method
*
* @return \Cubex\Http\Response|null
*
* @throws \Exception
*/
protected function _getCallableResult($method, $params = null)
Expand Down Expand Up @@ -783,6 +778,12 @@ protected function _getRouteData($key = null, $default = null)
return $this->_processParams;
}

// Since Arrays Value requires an array,we can break out early
if(!is_array($this->_processParams))
{
return $this->_processParams ?? $default;
}

return Arrays::value($this->_processParams, $key, $default);
}
}
4 changes: 2 additions & 2 deletions tests/Cubex/Http/Visitor/MaxmindVisitorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function testNoLicence()
'http_visitor',
[
'mode' => 'client',
'user_id' => '',
'user_id' => 0,
]
)
);
Expand Down Expand Up @@ -112,7 +112,7 @@ public function testClientCreates()
[
'mode' => 'client',
'licence_key' => '',
'user_id' => '',
'user_id' => 0,
]
)
);
Expand Down