Skip to content

Commit

Permalink
Fix styling with rector and php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
chrizzor committed Sep 6, 2022
1 parent 9eee289 commit e550b00
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 43 deletions.
36 changes: 18 additions & 18 deletions Classes/Ajax/Autocomplete.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use TYPO3\CMS\Core\Http\Response;
use TYPO3\CMS\Core\Http\JsonResponse;
use TYPO3\CMS\Core\Http\Response;

class Autocomplete implements MiddlewareInterface
{

public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$response = $handler->handle($request);
Expand All @@ -21,10 +20,10 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
return $response;
}

include_once 'EidSettings.php';
include_once __DIR__.'/EidSettings.php';

// Configuration options
$solrSuggestUrl = $HOST . $CORE . '/suggest';
$solrSuggestUrl = $HOST.$CORE.'/suggest';

// Autocomplete dictionary
$solrAutocompleteDictionary = 'autocompleteSuggester';
Expand All @@ -51,51 +50,51 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
$dictionaryUrlParams = '';

if ($entity) {
$dictionaryUrlParams .= '&suggest.dictionary=' . $solrEntityDictionary;
$dictionaryUrlParams .= '&suggest.dictionary='.$solrEntityDictionary;
}

if ($autocomplete) {
$dictionaryUrlParams .= '&suggest.dictionary=' . $solrAutocompleteDictionary;
$dictionaryUrlParams .= '&suggest.dictionary='.$solrAutocompleteDictionary;
}

if (!$entity && !$autocomplete) {
return $response;
}


// Get Solr suggestions
$response = file_get_contents(
$solrSuggestUrl . '?suggest=true' . $dictionaryUrlParams . '&suggest.q=' . urlencode($query),
FALSE,
$solrSuggestUrl.'?suggest=true'.$dictionaryUrlParams.'&suggest.q='.urlencode($query),
false,
stream_context_create([
'http' => [
'method' => 'GET',
'follow_location' => 0,
'timeout' => 1.0
]
'timeout' => 1.0,
],
])
);

// Parse JSON response
if ($response !== FALSE) {
$json = json_decode($response, TRUE);
if (false !== $response) {
$json = json_decode($response, true);

if ($autocomplete) {
// get autocomplete
foreach ($json['suggest'][$solrAutocompleteDictionary][$query]['suggestions'] as $suggestion) {
list ($id, $normalized) = explode('', $suggestion['payload']);
list($id, $normalized) = explode('', $suggestion['payload']);
$suggests[] = [
'id' => htmlspecialchars($suggestion['term']),
'term' => htmlspecialchars($suggestion['term']),
'normalized' => htmlspecialchars($suggestion['term']),
'autocomplete' => '1'
'autocomplete' => '1',
];
}
}

if ($entity && $autocomplete) {
// Add break between autocomplete and entity list
$suggests[] = [
'id' => 'br'
'id' => 'br',
];
}

Expand All @@ -104,16 +103,17 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface

// get entities
foreach ($json['suggest'][$solrEntityDictionary][$query]['suggestions'] as $suggestion) {
list ($id, $normalized) = explode('', $suggestion['payload']);
list($id, $normalized) = explode('', $suggestion['payload']);
if (!in_array($id, $idDeduping)) {
if (empty($normalized)) {
$normalized = $suggestion['term'];
}

$suggests[] = [
'id' => str_replace('%s', $id, $entityReplacement),
'term' => htmlspecialchars($suggestion['term']),
'normalized' => htmlspecialchars($normalized),
'autocomplete' => '0'
'autocomplete' => '0',
];
$idDeduping[] = $id;
}
Expand Down
21 changes: 9 additions & 12 deletions Classes/Ajax/GetEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,26 @@

namespace Subugoe\Find\Ajax;


use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use TYPO3\CMS\Core\Http\Response;
use TYPO3\CMS\Core\Http\JsonResponse;
use TYPO3\CMS\Core\Http\Response;

class GetEntity implements MiddlewareInterface
{

public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$response = $handler->handle($request);
if (!isset($request->getQueryParams()['q'], $request->getQueryParams()['getEntity'])) {
return $response;
}

include_once 'EidSettings.php';
include_once __DIR__.'/EidSettings.php';

// Configuration options
$solr_select_url = $HOST . $CORE . '/select';
$solr_select_url = $HOST.$CORE.'/select';

// Array of entity facts
$entity = [];
Expand All @@ -33,25 +31,24 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface

// Get Solr record
$response = file_get_contents(
$solr_select_url . '?q=' . urlencode('id:(' . $query . ')') . '&rows=1',
FALSE,
$solr_select_url.'?q='.urlencode('id:('.$query.')').'&rows=1',
false,
stream_context_create([
'http' => [
'method' => 'GET',
'follow_location' => 0,
'timeout' => 1.0
]
'timeout' => 1.0,
],
])
);

// Parse JSON response
if ($response !== FALSE) {
$json = json_decode($response, TRUE);
if (false !== $response) {
$json = json_decode($response, true);
$entity = $json['response']['docs'][0];
}

// Return result
return new JsonResponse($entity);
}

}
14 changes: 7 additions & 7 deletions Classes/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ public function detailAction(string $id)
if ($this->request->hasArgument('underlyingQuery')) {
$underlyingQueryInfo = $this->request->getArgument('underlyingQuery');
$this->response->addAdditionalHeaderData(
FrontendUtility::addQueryInformationAsJavaScript(
$underlyingQueryInfo['q'],
$this->settings,
(int) $underlyingQueryInfo['position'],
$arguments
)
);
FrontendUtility::addQueryInformationAsJavaScript(
$underlyingQueryInfo['q'],
$this->settings,
(int) $underlyingQueryInfo['position'],
$arguments
)
);
}

$this->addStandardAssignments();
Expand Down
4 changes: 2 additions & 2 deletions Classes/Service/SolrServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ protected function addHighlighting(array $arguments): void
$queryArguments = $queryParameters[$fieldID];
$queryTerms = null;
if (is_array($queryArguments) && array_key_exists('alternate',
$queryArguments) && array_key_exists('queryAlternate', $fieldInfo)
$queryArguments) && array_key_exists('queryAlternate', $fieldInfo)
) {
if (array_key_exists('term', $queryArguments)) {
$queryTerms = $queryArguments['term'];
Expand Down Expand Up @@ -738,7 +738,7 @@ protected function getCount(?array $arguments = null): int
$arguments = $this->getRequestArguments();
}

$count = (int) ($this->settings['paging']['perPage']);
$count = (int) $this->settings['paging']['perPage'];

if (array_key_exists('count', $arguments)) {
$count = (int) $this->requestArguments['count'];
Expand Down
2 changes: 1 addition & 1 deletion Classes/ViewHelpers/Data/NewArrayViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static function renderStatic(array $arguments, \Closure $renderChildrenCl
}
} else {
$result = 'newArray View Helper: Number of keys and values must be the same.'.PHP_EOL.print_r($arguments,
true);
true);
}
} else {
foreach ($arguments['values'] as $value) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/ViewHelpers/Data/TransposeViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static function renderStatic(
}

$output = 'The arrays passed in the »arrays« argument do not have identical numbers of values: ('.implode(', ',
$info).')';
$info).')';
}

return $output;
Expand Down
2 changes: 1 addition & 1 deletion Classes/ViewHelpers/LinkedData/Renderer/RDFRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class RDFRenderer extends AbstractRenderer implements RendererInterface
*/
public function renderItems($items)
{
$doc = new \DomDocument();
$doc = new \DOMDocument();
$this->prefixes['rdf'] = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
$rdf = $doc->createElement($this->prefixedName('rdf:RDF'));
$doc->appendChild($rdf);
Expand Down
2 changes: 1 addition & 1 deletion Classes/ViewHelpers/LinkedData/Renderer/TurtleRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function renderItems($items)
$objectString = $this->turtleString($object);
} else {
if (false === strpos($object, '"') && false === strpos($object, "\r") && false === strpos($object,
"\n")) {
"\n")) {
$objectString = '"'.$object.'"';
} elseif (false === strpos($object, '"""')) {
$objectString = '"""'.$object.'"""';
Expand Down

0 comments on commit e550b00

Please sign in to comment.