Skip to content

Commit

Permalink
Correction searchableType (#359)
Browse files Browse the repository at this point in the history
Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
5 people authored Aug 31, 2021
1 parent 95512ed commit 26c6903
Show file tree
Hide file tree
Showing 24 changed files with 358 additions and 292 deletions.
140 changes: 74 additions & 66 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ ifneq "$(COMMANDS_SUPPORTS_MAKE_ARGS)" ""
$(eval $(COMMANDS_ARGS):;@:)
endif

GREEN := \033[0;32m
RED := \033[0;31m
YELLOW := \033[0;33m
NC := \033[0m
NEED := ${GREEN}%-20s${NC}: %s\n
MISSING :=${RED}ARGUMENT missing${NC}\n
ARGUMENTS := make ${PURPLE}%s${NC} ${YELLOW}ARGUMENT${NC}\n

init: ## Init project
@git submodule update --init --recursive --remote

Expand All @@ -34,13 +42,13 @@ else ifeq ($(COMMANDS_ARGS),migrate)
else ifeq ($(COMMANDS_ARGS),validate)
$(DOCKER_EXECPHP) make bdd validate
else
@echo "ARGUMENT missing"
@printf "${MISSING}"
@echo "---"
@echo "make bdd ARGUMENT"
@printf "${ARGUMENTS}" "bdd"
@echo "---"
@echo "fixtures: fixtures"
@echo "migrate: migrate database"
@echo "validate: bdd validate"
@printf "${NEED}" "fixtures" "fixtures"
@printf "${NEED}" "migrate" "migrate database"
@printf "${NEED}" "validate" "bdd validate"
endif

.PHONY: composer
Expand All @@ -62,18 +70,18 @@ else ifeq ($(COMMANDS_ARGS),i)
else ifeq ($(COMMANDS_ARGS),validate)
$(DOCKER_EXECPHP) make composer validate
else
@echo "ARGUMENT missing"
@printf "${MISSING}"
@echo "---"
@echo "make composer ARGUMENT"
@printf "${ARGUMENTS}" "composer"
@echo "---"
@echo "suggests: suggestions package pour PHP"
@echo "i: install"
@echo "outdated: Packet php outdated"
@echo "fund: Discover how to help fund the maintenance of your dependencies."
@echo "prod: Installation version de prod"
@echo "dev: Installation version de dev"
@echo "u: COMPOSER update"
@echo "validate: COMPOSER validate"
@printf "${NEED}" "suggests" "suggestions package pour PHP"
@printf "${NEED}" "i" "install"
@printf "${NEED}" "outdated" "Packet php outdated"
@printf "${NEED}" "fund" "Discover how to help fund the maintenance of your dependencies."
@printf "${NEED}" "prod" "Installation version de prod"
@printf "${NEED}" "dev" "Installation version de dev"
@printf "${NEED}" "u" "COMPOSER update"
@printf "${NEED}" "validate" "COMPOSER validate"
endif

.PHONY: encore
Expand All @@ -86,13 +94,13 @@ else ifeq ($(COMMANDS_ARGS),watch)
else ifeq ($(COMMANDS_ARGS),build)
@npm run encore-build
else
@echo "ARGUMENT missing"
@printf "${MISSING}"
@echo "---"
@echo "make encore ARGUMENT"
@printf "${ARGUMENTS}" "encore"
@echo "---"
@echo "dev: créer les assets en version dev"
@echo "watch: créer les assets en version watch"
@echo "build: créer les assets en version prod"
@printf "${NEED}" "dev" "créer les assets en version dev"
@printf "${NEED}" "watch" "créer les assets en version watch"
@printf "${NEED}" "build" "créer les assets en version prod"
endif

.PHONY: env
Expand All @@ -104,12 +112,12 @@ else ifeq ($(COMMANDS_ARGS),prod)
@rm -rf apps/vendor
@make composer prod -i
else
@echo "ARGUMENT missing"
@printf "${MISSING}"
@echo "---"
@echo "make env ARGUMENT"
@printf "${ARGUMENTS}" "env"
@echo "---"
@echo "dev: environnement dev"
@echo "prod: environnement prod"
@printf "${NEED}" "dev" "environnement dev"
@printf "${NEED}" "prod" "environnement prod"
endif

.PHONY: geocode
Expand Down Expand Up @@ -139,13 +147,13 @@ else ifeq ($(COMMANDS_ARGS),prod)
@make env prod -i
@make encore build -i
else
@echo "ARGUMENT missing"
@printf "${MISSING}"
@echo "---"
@echo "make install ARGUMENT"
@printf "${ARGUMENTS}" "install"
@echo "---"
@echo "all: common"
@echo "dev: dev"
@echo "prod: prod"
@printf "${NEED}" "all" "common"
@printf "${NEED}" "dev" "dev"
@printf "${NEED}" "prod" "prod"
endif

.PHONY: commands
Expand Down Expand Up @@ -217,45 +225,45 @@ else ifeq ($(COMMANDS_ARGS),container)
else ifeq ($(COMMANDS_ARGS),yaml)
$(DOCKER_EXECPHP) make linter yaml
else
@echo "ARGUMENT missing"
@printf "${MISSING}"
@echo "---"
@echo "make linter ARGUMENT"
@printf "${ARGUMENTS}" "linter"
@echo "---"
@echo "all: ## Launch all linter"
@echo "composer: composer"
@echo "readme: linter README.md"
@echo "phpaudit: AUDIT PHP"
@echo "phpfix: PHP-CS-FIXER & PHPCBF"
@echo "stylelint: indique les erreurs dans le code SCSS"
@echo "stylelint-fix: fix les erreurs dans le code SCSS"
@echo "eslint: indique les erreurs sur le code JavaScript à partir d'un standard"
@echo "eslint-fix: fixe le code JavaScript à partir d'un standard"
@echo "phpcbf: fixe le code PHP à partir d'un standard"
@echo "php-cs-fixer: fixe le code PHP à partir d'un standard"
@echo "phpcs: indique les erreurs de code non corrigé par PHPCBF"
@echo "phpcs-onlywarning: indique les erreurs de code non corrigé par PHPCBF"
@echo "phpcs-onlyerror: indique les erreurs de code non corrigé par PHPCBF"
@echo "phploc: phploc"
@echo "phpmd: indique quand le code PHP contient des erreurs de syntaxes ou des erreurs"
@echo "phpmnd: Si des chiffres sont utilisé dans le code PHP, il est conseillé d'utiliser des constantes"
@echo "phpstan: regarde si le code PHP ne peux pas être optimisé"
@echo "twig: indique les erreurs de code de twig"
@echo "container: indique les erreurs de code de container"
@echo "yaml: indique les erreurs de code de yaml"
@echo "jscpd: Copy paste detector"
@echo "jscpd-report: Copy paste detector report"
@printf "${NEED}" "all" "## Launch all linter"
@printf "${NEED}" "composer" "composer"
@printf "${NEED}" "readme" "linter README.md"
@printf "${NEED}" "phpaudit" "AUDIT PHP"
@printf "${NEED}" "phpfix" "PHP-CS-FIXER & PHPCBF"
@printf "${NEED}" "stylelint" "indique les erreurs dans le code SCSS"
@printf "${NEED}" "stylelint-fix" "fix les erreurs dans le code SCSS"
@printf "${NEED}" "eslint" "indique les erreurs sur le code JavaScript à partir d'un standard"
@printf "${NEED}" "eslint-fix" "fixe le code JavaScript à partir d'un standard"
@printf "${NEED}" "phpcbf" "fixe le code PHP à partir d'un standard"
@printf "${NEED}" "php-cs-fixer" "fixe le code PHP à partir d'un standard"
@printf "${NEED}" "phpcs" "indique les erreurs de code non corrigé par PHPCBF"
@printf "${NEED}" "phpcs-onlywarning" "indique les erreurs de code non corrigé par PHPCBF"
@printf "${NEED}" "phpcs-onlyerror" "indique les erreurs de code non corrigé par PHPCBF"
@printf "${NEED}" "phploc" "phploc"
@printf "${NEED}" "phpmd" "indique quand le code PHP contient des erreurs de syntaxes ou des erreurs"
@printf "${NEED}" "phpmnd" "Si des chiffres sont utilisé dans le code PHP, il est conseillé d'utiliser des constantes"
@printf "${NEED}" "phpstan" "regarde si le code PHP ne peux pas être optimisé"
@printf "${NEED}" "twig" "indique les erreurs de code de twig"
@printf "${NEED}" "container" "indique les erreurs de code de container"
@printf "${NEED}" "yaml" "indique les erreurs de code de yaml"
@printf "${NEED}" "jscpd" "Copy paste detector"
@printf "${NEED}" "jscpd-report" "Copy paste detector report"
endif

.PHONY: messenger
messenger: ### Scripts messenger
ifeq ($(COMMANDS_ARGS),consume)
$(DOCKER_EXECPHP) make messenger consume
else
@echo "ARGUMENT missing"
@printf "${MISSING}"
@echo "---"
@echo "make messenger ARGUMENT"
@printf "${ARGUMENTS}" "messenger"
@echo "---"
@echo "consume: Messenger Consume"
@printf "${NEED}" "consume" "Messenger Consume"
endif

.PHONY: tests
Expand All @@ -269,14 +277,14 @@ else ifeq ($(COMMANDS_ARGS),simple-phpunit-unit-integration)
else ifeq ($(COMMANDS_ARGS),simple-phpunit)
@$(DOCKER_EXECPHP) make tests simple-phpunit
else
@echo "ARGUMENT missing"
@printf "${MISSING}"
@echo "---"
@echo "make tests ARGUMENT"
@printf "${ARGUMENTS}" "tests"
@echo "---"
@echo "launch: Launch all tests"
@echo "behat: Lance les tests behat"
@echo "simple-phpunit-unit-integration: lance les tests phpunit"
@echo "simple-phpunit: lance les tests phpunit"
@printf "${NEED}" "launch" "Launch all tests"
@printf "${NEED}" "behat" "Lance les tests behat"
@printf "${NEED}" "simple-phpunit-unit-integration" "lance les tests phpunit"
@printf "${NEED}" "simple-phpunit" "lance les tests phpunit"
endif

.PHONY: translations
Expand All @@ -295,11 +303,11 @@ ifeq ($(COMMANDS_ARGS),tarteaucitron)
rm v1.9.3.zip
mv tarteaucitron.js-1.9.3 apps/public/tarteaucitron
else
@echo "ARGUMENT missing"
@printf "${MISSING}"
@echo "---"
@echo "make libraries ARGUMENT"
@printf "${ARGUMENTS}" "libraries"
@echo "---"
@echo "tarteaucitron: tarteaucitron"
@printf "${NEED}" "tarteaucitron" "tarteaucitron"
endif

DATABASE_BDD := $(shell more docker-compose.yml | grep DATABASE_BDD: | sed -e "s/^.*DATABASE_BDD:[[:space:]]//")
Expand Down
2 changes: 1 addition & 1 deletion apps/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"require-dev": {
"behat/behat": "3.8.1",
"doctrine/doctrine-fixtures-bundle": "3.4.0",
"friendsofphp/php-cs-fixer": "3.0.2",
"friendsofphp/php-cs-fixer": "3.1.0",
"phpstan/phpstan": "0.12.96",
"povils/phpmnd": "2.4.0",
"squizlabs/php_codesniffer": "3.6.0",
Expand Down
17 changes: 9 additions & 8 deletions apps/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/config/packages/liip_imagine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ liip_imagine:
my_thumb :
quality: 75
filters:
thumbnail : {size: [1320, 290], mode: outbound}
thumbnail : {size: [1320, 290]}
42 changes: 36 additions & 6 deletions apps/src/Controller/Api/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Labstag\Controller\Api;

use Labstag\Lib\ApiControllerLib;
use Labstag\Repository\LibelleRepository;
use Labstag\Repository\UserRepository;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -13,6 +14,35 @@
*/
class SearchController extends ApiControllerLib
{
/**
* @Route("/libelle", name="api_search_postlibelle")
*
* @param Request $request
* @return void
*/
public function libelle(Request $request, LibelleRepository $repository): Response
{
$get = $request->query->all();
$return = ['isvalid' => false];
if (!array_key_exists('name', $get)) {
return $this->json($return);
}

$data = $repository->findNom($get['name']);
$result = [
'results' => [],
];

foreach ($data as $user) {
$result['results'][] = [
'id' => $user->getId(),
'text' => (string) $user,
];
}

return $this->json($result);
}

/**
* @Route("/user", name="api_search_user")
*/
Expand All @@ -24,18 +54,18 @@ public function user(Request $request, UserRepository $repository): Response
return $this->json($return);
}

$users = $repository->findUserName($get['name']);
$data = [
$data = $repository->findUserName($get['name']);
$result = [
'results' => [],
];

foreach ($users as $user) {
$data['results'][] = [
foreach ($data as $user) {
$result['results'][] = [
'id' => $user->getId(),
'text' => $user->getUsername(),
'text' => (string) $user,
];
}

return $this->json($data);
return $this->json($result);
}
}
5 changes: 3 additions & 2 deletions apps/src/EventSubscriber/KernelSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class KernelSubscriber implements EventSubscriberInterface
'btn-togglefieldset',
'select-country',
'select-selector',
'select-refuser',
'input-phone',
'input-email',
'input-url',
Expand All @@ -68,6 +67,7 @@ class KernelSubscriber implements EventSubscriberInterface
'select-element',
];
public const LABSTAG_CONTROLLER = '/(Labstag)/';
public const API_CONTROLLER = '/(Api)/';

public const CLIENTNUMBER = 400;

Expand All @@ -82,7 +82,8 @@ public function onKernelResponse($event)
$request = $event->getRequest();
$controller = $request->attributes->get('_controller');
preg_match(self::LABSTAG_CONTROLLER, $controller, $matches);
if (0 == count($matches) || in_array($controller, self::ERROR_CONTROLLER)) {
preg_match(self::API_CONTROLLER, $controller, $apis);
if (0 == count($matches) || in_array($controller, self::ERROR_CONTROLLER) || 0 != count($apis)) {
return;
}

Expand Down
Loading

0 comments on commit 26c6903

Please sign in to comment.