Skip to content

Commit

Permalink
Used new coding standard. Upgraded GridBundle.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrejus Voitovas committed Apr 21, 2022
1 parent 5324861 commit 9c7fc8d
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"require": {
"php": "^8.0",
"sylius/grid-bundle": "1.11-rc.3",
"sylius/grid-bundle": "^1.11",
"sylius/locale-bundle": "^1.11",
"sylius/mailer-bundle": "^1.6",
"sylius/resource-bundle": "^1.9",
Expand Down
4 changes: 2 additions & 2 deletions src/Command/CommandExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public function runCommand($command, $parameters = [], OutputInterface $output =
$this->application->setAutoExit(false);
$exitCode = $this->application->run(new ArrayInput($parameters), $output ?: new NullOutput());

if (1 === $exitCode) {
if ($exitCode === 1) {
throw new RuntimeException('This command terminated with a permission error');
}

if (0 !== $exitCode) {
if ($exitCode !== 0) {
$this->application->setAutoExit(true);

$errorMessage = sprintf('The command terminated with an error code: %u.', $exitCode);
Expand Down
5 changes: 3 additions & 2 deletions src/Command/SetupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Platform\Bundle\AdminBundle\Command;

use Doctrine\ORM\EntityManagerInterface;
use InvalidArgumentException;
use Platform\Bundle\AdminBundle\Installer\Setup\LocaleSetup;
use Platform\Bundle\AdminBundle\Model\AdminUserInterface;
use Sylius\Component\Resource\Factory\FactoryInterface;
Expand Down Expand Up @@ -77,7 +78,7 @@ private function setupAdministratorUser(InputInterface $input, OutputInterface $

try {
$user = $this->configureNewUser($this->userFactory->createNew(), $input, $output);
} catch (\InvalidArgumentException $exception) {
} catch (InvalidArgumentException $exception) {
return;
}

Expand Down Expand Up @@ -110,7 +111,7 @@ private function configureNewUser(
do {
$question = $this->createEmailQuestion($output);
$email = $questionHelper->ask($input, $output, $question);
$exists = null !== $this->userRepository->findOneByEmail($email);
$exists = $this->userRepository->findOneByEmail($email) !== null;

if ($exists) {
$output->writeln('<error>E-Mail is already in use!</error>');
Expand Down
4 changes: 2 additions & 2 deletions src/Context/AdminBasedLocaleContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public function __construct(TokenStorageInterface $tokenStorage)
public function getLocaleCode(): string
{
$token = $this->tokenStorage->getToken();
if (null === $token) {
if ($token === null) {
throw new LocaleNotFoundException();
}

$adminUser = $token->getUser();
if (false === $adminUser instanceof AdminUserInterface) {
if (!$adminUser instanceof AdminUserInterface) {
throw new LocaleNotFoundException();
}

Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/PlatformAdminExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

class PlatformAdminExtension extends Extension
{
/** {@inheritdoc} */
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));

$loader->load('services.xml');
}
Expand Down
8 changes: 5 additions & 3 deletions src/EventListener/CanonicalizerListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ private function canonicalize(LifecycleEventArgs $event): void
{
$item = $event->getEntity();

if ($item instanceof UserInterface) {
$item->setUsernameCanonical($this->canonicalizer->canonicalize($item->getUsername()));
$item->setEmailCanonical($this->canonicalizer->canonicalize($item->getEmail()));
if (!$item instanceof UserInterface) {
return;
}

$item->setUsernameCanonical($this->canonicalizer->canonicalize($item->getUsername()));
$item->setEmailCanonical($this->canonicalizer->canonicalize($item->getEmail()));
}
}
5 changes: 4 additions & 1 deletion src/Installer/Setup/LocaleSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Intl\Languages;

use function trim;
use function sprintf;

class LocaleSetup
{
private RepositoryInterface $repository;
Expand All @@ -30,7 +33,7 @@ public function setup(InputInterface $input, OutputInterface $output): LocaleInt
$output->writeln(sprintf('Adding <info>%s</info> locale.', $name));
$existingLocale = $this->repository->findOneBy(['code' => $this->locale]);

if (null !== $existingLocale) {
if ($existingLocale !== null) {
return $existingLocale;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Resources/views/Security/login.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
{% block title %}Admin platform | {{ 'sylius.ui.administration_panel_login'|trans }}{% endblock %}

{% block stylesheets %}
{% include '@SyliusUi/_stylesheets.html.twig' with {'path': 'assets/admin/css/style.css'} %}
{{ encore_entry_link_tags('app') }}
{% endblock %}

{% block content %}
{% include '@SyliusUi/Security/_login.html.twig' with {'action': path('admin_platform_admin_login_check')} %}
{% endblock %}

{% block javascripts %}
{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'assets/admin/js/app.js'} %}
{{ encore_entry_script_tags('app') }}
{% endblock %}

0 comments on commit 9c7fc8d

Please sign in to comment.