Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Base lexicale BaLex
Manage
Activity
Members
Labels
Plan
Issues
18
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lex gaMe
Base lexicale BaLex
Commits
3170a092
Commit
3170a092
authored
1 year ago
by
Pierre Fleutot
Browse files
Options
Downloads
Patches
Plain Diff
Commande update lexiques utilisateurs
parent
f6163088
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Command/Temp/UpdateLexiconsCommand.php
+73
-0
73 additions, 0 deletions
src/Command/Temp/UpdateLexiconsCommand.php
with
73 additions
and
0 deletions
src/Command/Temp/UpdateLexiconsCommand.php
0 → 100644
+
73
−
0
View file @
3170a092
<?php
namespace
App\Command\Temp
;
use
App\Entity\Label
;
use
App\Entity\Lexicon
;
use
App\Entity\User
;
use
App\Languages\LanguagesIso
;
use
Doctrine\ORM\EntityManagerInterface
;
use
League\Bundle\OAuth2ServerBundle\Model\Client
;
use
Symfony\Component\Console\Attribute\AsCommand
;
use
Symfony\Component\Console\Command\Command
;
use
Symfony\Component\Console\Input\InputInterface
;
use
Symfony\Component\Console\Input\InputOption
;
use
Symfony\Component\Console\Output\OutputInterface
;
use
Symfony\Component\Console\Style\SymfonyStyle
;
use
Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface
;
use
Symfony\Component\Uid\UuidV1
;
class
UpdateLexiconsCommand
extends
Command
{
protected
static
$defaultName
=
"app:lexicon:update"
;
protected
static
$defaultDescription
=
"Création si nécessaire d'un lexique par langue étudiée pour chaque utilisateur."
;
/**
* @var EntityManagerInterface
*/
private
$em
;
public
function
__construct
(
EntityManagerInterface
$em
)
{
parent
::
__construct
();
$this
->
em
=
$em
;
}
// protected function configure(): void
// {
// $this
// ->addOption('email', null, InputOption::VALUE_REQUIRED, 'User email adddress', 'me@davegebler.com')
// ->addOption('password', null, InputOption::VALUE_REQUIRED, 'User password', 'password')
// ->addOption('redirect-uris', null, InputOption::VALUE_REQUIRED, 'Redirect URIs', 'http://localhost:8001/callback')
// ;
// }
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
):
int
{
$io
=
new
SymfonyStyle
(
$input
,
$output
);
$users
=
$this
->
em
->
getRepository
(
User
::
class
)
->
findAll
();
foreach
(
$users
as
$user
)
{
foreach
(
$user
->
getStudiedLanguages
()
as
$studiedLanguage
)
{
if
(
!
$user
->
hasPersonalLexiconForLanguage
(
$studiedLanguage
->
getLanguage
()))
{
$lexicon
=
new
Lexicon
();
$lexicon
->
setUser
(
$user
);
$lexicon
->
setLanguage
(
$studiedLanguage
->
getLanguage
());
$lexicon
->
setCategory
(
Lexicon
::
TYPE_USER
);
$user
->
addLexicon
(
$lexicon
);
$io
->
writeln
(
sprintf
(
"lexique %s créé pour %s"
,
$lexicon
->
getLanguage
(),
$user
));
}
}
}
$this
->
em
->
flush
();
$io
->
success
(
'Succès initialisation.'
);
return
Command
::
SUCCESS
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment