Commit e1336b85 authored by Dainis Abols's avatar Dainis Abols
Browse files

Deprecation fixes

parent 45afdc21
......@@ -77,7 +77,7 @@ class ExchangeController extends ActionController
break;
}
header('Content-Type: application/json');
header('Content-Type: application/json; charset=utf-8');
echo ReturnPretty::json($data, $status, true);
die;
}
......
......@@ -2,8 +2,9 @@
namespace Lu\LuApi\Helpers;
use GuzzleHttp\Client as Guzzle;
use GuzzleHttp\Exception\GuzzleException;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Resource\FileRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
......@@ -106,7 +107,7 @@ class DataHelper
);
// Execute
$result = $queryBuilder->execute()->fetchAll();
$result = $queryBuilder->execute()->fetchAllAssociative();
// Read and load groups
foreach($result as $row) {
......@@ -151,7 +152,7 @@ class DataHelper
*
* @param $jsonData
*
* @return string
* @return mixed|null
*/
public function APIDecode($jsonData)
{
......@@ -165,4 +166,30 @@ class DataHelper
return $data;
}
/**
* Fetch results
*
* @param string $url
* @param bool $code
*
* @return int|\Psr\Http\Message\ResponseInterface|null
*/
public function fetchUrl(string $url, bool $code = false)
{
// Fetch fail results
$client = new Guzzle();
try {
$result = $client->get($url, ['verify' => false]);
} catch (GuzzleException $e) {
$result = null;
}
// Check if code requested
if ($code) {
return !empty($result) ? $result->getStatusCode() : 500;
}
return $result;
}
}
\ No newline at end of file
......@@ -120,7 +120,7 @@ class Namedays implements RestModel
);
// Execute
$result = $queryBuilder->execute()->fetchAll();
$result = $queryBuilder->execute()->fetchAllAssociative();
// Read and load groups
foreach($result as $row) {
......@@ -154,7 +154,7 @@ class Namedays implements RestModel
);
// Execute
$result = $queryBuilder->execute()->fetchAll();
$result = $queryBuilder->execute()->fetchAllAssociative();
// Read and load groups
foreach($result as $row) {
......
......@@ -26,7 +26,9 @@ class RequestType extends TypeClass
*/
public function validate($value)
{
$errors = false;
if (!(strlen($value) > 0)) {
$errors = true;
$bt = debug_backtrace()[1];
unset($bt['object']); unset($bt['args']); unset($bt['type']);
......@@ -34,12 +36,13 @@ class RequestType extends TypeClass
}
if (!in_array($value, [RequestType::BE, RequestType::FE])) {
$errors = true;
$bt = debug_backtrace()[1];
unset($bt['object']); unset($bt['args']); unset($bt['type']);
$this->logger->error(sprintf(TypeErrors::REQUEST_TYPE_INVALID, $value) . ": " . print_r($bt, true));
}
return $value;
return $errors ? null : $value;
}
}
......@@ -19,7 +19,7 @@ class Table extends TypeClass
* Validates value
*
* @param $value
* @return mixed
* @return
*/
public function validate($value)
{
......@@ -28,6 +28,7 @@ class Table extends TypeClass
unset($bt['object']); unset($bt['args']); unset($bt['type']);
$this->logger->warning(TypeErrors::TABLE_NAME_EMPTY . ": " . print_r($bt, true));
return null;
}
return $value;
......
......@@ -15,7 +15,7 @@ trait TypeMethods
*/
public function equals($value): bool
{
return $value == $this->value;
return $value == $this->getValue();
}
/**
......
......@@ -19,7 +19,7 @@ class Username extends TypeClass
* Validates value
*
* @param $value
* @return mixed
* @return
*/
public function validate($value)
{
......@@ -28,6 +28,7 @@ class Username extends TypeClass
unset($bt['object']); unset($bt['args']); unset($bt['type']);
$this->logger->info(TypeErrors::USERNAME_EMPTY . ": " . print_r($bt, true));
return null;
}
return $value;
......
......@@ -6,10 +6,10 @@ if (!defined('TYPO3_MODE')) die ('Access denied.');
'Lu.LuApi',
'Pi1',
[
'Exchange' => 'route',
\Lu\LuApi\Controller\ExchangeController::class => 'route'
],
[
'Exchange' => 'route',
\Lu\LuApi\Controller\ExchangeController::class => 'route'
]
);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment