Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

CreateLanguageCommand.php
Go to the documentation of this file.
1 <?php
2
7 namespace EzSystems\PlatformBehatBundle\Command;
8
9 use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
10 use Symfony\Component\Console\Input\InputArgument;
11 use Symfony\Component\Console\Input\InputInterface;
12 use Symfony\Component\Console\Output\OutputInterface;
13
14 class CreateLanguageCommand extends ContainerAwareCommand
15 {
17 private $languageService;
18
20 private $userService;
21
23 private $permissionResolver;
24
25 protected function configure()
26 {
27 $this
28 ->setName('ez:behat:create-language')
29 ->setDescription('Create a Language')
30 ->addArgument('language-code', InputArgument::REQUIRED)
31 ->addArgument('language-name', InputArgument::OPTIONAL, 'Language name', '')
32 ->addArgument(
33 'user',
34 InputArgument::OPTIONAL,
35 'eZ Platform User with access to content / translations',
36 'admin'
37 );
38 }
39
40 protected function initialize(InputInterface $input, OutputInterface $output)
41 {
42 parent::initialize($input, $output);
43
44 $repository = $this->getContainer()->get('ezpublish.api.repository');
45 $this->languageService = $repository->getContentLanguageService();
46 $this->permissionResolver = $repository->getPermissionResolver();
47 $this->userService = $repository->getUserService();
48 }
49
50 protected function execute(InputInterface $input, OutputInterface $output)
51 {
52 // set user with proper permissions to create language (content / translations)
53 $this->permissionResolver->setCurrentUserReference(
54 $this->userService->loadUserByLogin(
55 $input->getArgument('user')
56 )
57 );
58
59 $languageCreateStruct = $this->languageService->newLanguageCreateStruct();
60 $languageCreateStruct->languageCode = $input->getArgument('language-code');
61 $languageCreateStruct->name = $input->getArgument('language-name');
62
63 $this->languageService->createLanguage($languageCreateStruct);
64 }
65 }
EzSystems\PlatformBehatBundle\Command\CreateLanguageCommand
Definition: CreateLanguageCommand.php:15
EzSystems\PlatformBehatBundle\Command\CreateLanguageCommand\execute
execute(InputInterface $input, OutputInterface $output)
Definition: CreateLanguageCommand.php:50
EzSystems\PlatformBehatBundle\Command\CreateLanguageCommand\$userService
$userService
Definition: CreateLanguageCommand.php:20
EzSystems\PlatformBehatBundle\Command\CreateLanguageCommand\$languageService
$languageService
Definition: CreateLanguageCommand.php:17
EzSystems\PlatformBehatBundle\Command\CreateLanguageCommand\initialize
initialize(InputInterface $input, OutputInterface $output)
Definition: CreateLanguageCommand.php:40
EzSystems\PlatformBehatBundle\Command\CreateLanguageCommand\configure
configure()
Definition: CreateLanguageCommand.php:25
EzSystems\PlatformBehatBundle\Command\CreateLanguageCommand\$permissionResolver
$permissionResolver
Definition: CreateLanguageCommand.php:23
EzSystems\PlatformBehatBundle\Command
Definition: CreateLanguageCommand.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.