Skip to content

Commit

Permalink
Merge pull request #3 from nucleos/dev
Browse files Browse the repository at this point in the history
Import sonata code
  • Loading branch information
core23 committed Jan 19, 2020
2 parents b78221b + 2fbca23 commit 9826a32
Show file tree
Hide file tree
Showing 92 changed files with 7,621 additions and 50 deletions.
5 changes: 0 additions & 5 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,11 @@ branches:
- "Coding Standards (7.4)"
- "Static Code Analysis (7.4)"
- "Tests (7.3, lowest, ~4.4)"
- "Tests (7.3, lowest, ~5.0)"
- "Tests (7.3, highest, ~4.4)"
- "Tests (7.3, highestf, ~5.0)"
- "Tests (7.4, lowest, ~4.4)"
- "Tests (7.4, lowest, ~5.0)"
- "Tests (7.4, highest, ~4.4)"
- "Tests (7.4, highest, ~5.0)"
- "Code Coverage (7.4)"
- "Mutation Tests (7.4)"
- "Mutation Tests (7.4)"
- "Lint / DOCtor-RST"
strict: true

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ jobs:

symfony:
- ~4.4
- ~5.0

steps:
- name: "Checkout"
Expand Down
78 changes: 45 additions & 33 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,56 @@
],
"require": {
"php": "^7.3",
"ext-json": "*",
"nucleos/user-bundle": "^1.0",
"sonata-project/admin-bundle": "^3.34",
"sonata-project/core-bundle": "^3.12",
"sonata-project/datagrid-bundle": "^2.2.1",
"psr/log": "^1.0",
"sonata-project/admin-bundle": "^3.57",
"sonata-project/doctrine-extensions": "^1.5.1",
"sonata-project/easy-extends-bundle": "^2.2",
"symfony/config": "^3.4 || ^4.2",
"symfony/console": "^3.4 || ^4.2",
"symfony/dependency-injection": "^3.4 || ^4.2",
"symfony/form": "^3.4 || ^4.2",
"symfony/framework-bundle": "^3.4 || ^4.2",
"symfony/http-foundation": "^3.4 || ^4.2",
"symfony/http-kernel": "^3.4 || ^4.2",
"symfony/options-resolver": "^3.4 || ^4.2",
"symfony/security-acl": "^2.8 || ^3.0",
"symfony/security-core": "^3.4 || ^4.2",
"symfony/translation": "^3.4 || ^4.2",
"twig/twig": "^2.9"
"symfony/config": "^4.4",
"symfony/dependency-injection": "^4.4",
"symfony/event-dispatcher": "^4.4",
"symfony/event-dispatcher-contracts": "^1.0 || ^2.0",
"symfony/form": "^4.4",
"symfony/framework-bundle": "^4.4",
"symfony/http-foundation": "^4.4",
"symfony/http-kernel": "^4.4",
"symfony/options-resolver": "^4.4",
"symfony/routing": "^4.4",
"symfony/security-acl": "^3.0",
"symfony/security-core": "^4.4",
"symfony/security-csrf": "^4.4",
"symfony/security-http": "^4.4",
"symfony/translation": "^4.4",
"symfony/translation-contracts": "^1.0 || ^2.0",
"symfony/twig-bridge": "^4.4",
"symfony/twig-bundle": "^4.4",
"twig/twig": "^2.4 || ^3.0"
},
"conflict": {
"friendsofsymfony/rest-bundle": "<2.1 || >=3.0",
"jms/serializer": "<1.3 || >=4.0",
"nelmio/api-doc-bundle": "<2.4",
"sonata-project/doctrine-orm-admin-bundle": "<3.0",
"sonata-project/google-authenticator": "<1.0"
"doctrine/doctrine-bundle": "<1.12",
"doctrine/orm": "<2.7",
"symfony/doctrine-bridge": "<4.4"
},
"require-dev": {
"doctrine/orm": "^2.0",
"friendsofsymfony/rest-bundle": "^2.1",
"jms/serializer-bundle": "^1.0 || ^2.0 || ^3.0",
"bamarni/composer-bin-plugin": "^1.3",
"doctrine/doctrine-bundle": "^1.12 || ^2.0",
"doctrine/orm": "^2.7",
"ergebnis/composer-normalize": "^2.0.1",
"knplabs/knp-menu": "^2.3 || ^3.0",
"matthiasnoback/symfony-config-test": "^4.0",
"matthiasnoback/symfony-dependency-injection-test": "^3.0",
"nelmio/api-doc-bundle": "^2.4",
"sonata-project/google-authenticator": "^1.0 || ^2.0",
"symfony/phpunit-bridge": "^4.3"
},
"suggest": {
"sonata-project/doctrine-orm-admin-bundle": "^3.0",
"sonata-project/google-authenticator": "For google auth user login"
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
"sonata-project/doctrine-orm-admin-bundle": "^3.13",
"symfony/asset": "^4.4",
"symfony/browser-kit": "^4.4",
"symfony/doctrine-bridge": "^4.4",
"twig/extensions": "^1.5"
},
"config": {
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-master": "4.x-dev"
"dev-master": "1.x-dev"
}
},
"autoload": {
Expand All @@ -76,5 +80,13 @@
"psr-4": {
"Nucleos\\UserAdminBundle\\Tests\\": "tests/"
}
},
"scripts": {
"post-install-cmd": [
"@composer bin all install --ansi"
],
"post-update-cmd": [
"@composer bin all update --ansi"
]
}
}
123 changes: 114 additions & 9 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,27 +1,132 @@
parameters:
ignoreErrors:
-
message: "#^Method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch\\(\\) invoked with 2 parameters, 1 required\\.$#"
count: 1
path: src/Action/LoginAction.php

-
message: "#^Call to method Symfony\\\\Component\\\\HttpFoundation\\\\Request\\:\\:hasSession\\(\\) will always evaluate to true\\.$#"
count: 1
path: src/Action/LoginAction.php

-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
count: 1
path: src/DependencyInjection/Configuration.php

-
message: "#^Parameter \\#1 \\$node of method Nucleos\\\\ProfileBundle\\\\DependencyInjection\\\\Configuration\\:\\:addRegistrationSection\\(\\) expects Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\ArrayNodeDefinition, Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition given\\.$#"
message: "#^Method Nucleos\\\\UserAdminBundle\\\\DependencyInjection\\\\NucleosUserAdminExtension\\:\\:load\\(\\) has parameter \\$configs with no value type specified in iterable type array\\.$#"
count: 1
path: src/DependencyInjection/Configuration.php
path: src/DependencyInjection/NucleosUserAdminExtension.php

-
message: "#^Parameter \\#1 \\$node of method Nucleos\\\\ProfileBundle\\\\DependencyInjection\\\\Configuration\\:\\:addProfileSection\\(\\) expects Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\ArrayNodeDefinition, Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition given\\.$#"
message: "#^Method Nucleos\\\\UserAdminBundle\\\\DependencyInjection\\\\NucleosUserAdminExtension\\:\\:fixImpersonating\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#"
count: 1
path: src/DependencyInjection/Configuration.php
path: src/DependencyInjection/NucleosUserAdminExtension.php

-
message: "#^Parameter \\#1 \\$node of method Nucleos\\\\ProfileBundle\\\\DependencyInjection\\\\Configuration\\:\\:addServiceSection\\(\\) expects Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\ArrayNodeDefinition, Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition given\\.$#"
message: "#^Method Nucleos\\\\UserAdminBundle\\\\DependencyInjection\\\\NucleosUserAdminExtension\\:\\:fixImpersonating\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/DependencyInjection/Configuration.php
path: src/DependencyInjection/NucleosUserAdminExtension.php

-
message: "#^Cannot call method end\\(\\) on Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\|null\\.$#"
count: 3
path: src/DependencyInjection/Configuration.php
message: "#^Method Nucleos\\\\UserAdminBundle\\\\DependencyInjection\\\\NucleosUserAdminExtension\\:\\:configureAdminClass\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#"
count: 1
path: src/DependencyInjection/NucleosUserAdminExtension.php

-
message: "#^Method Nucleos\\\\UserAdminBundle\\\\DependencyInjection\\\\NucleosUserAdminExtension\\:\\:configureTranslationDomain\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#"
count: 1
path: src/DependencyInjection/NucleosUserAdminExtension.php

-
message: "#^Method Nucleos\\\\UserAdminBundle\\\\DependencyInjection\\\\NucleosUserAdminExtension\\:\\:configureController\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#"
count: 1
path: src/DependencyInjection/NucleosUserAdminExtension.php

-
message: "#^Property Nucleos\\\\UserAdminBundle\\\\Form\\\\Transformer\\\\RestoreRolesTransformer\\:\\:\\$originalRoles type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Form/Transformer/RestoreRolesTransformer.php

-
message: "#^Method Nucleos\\\\UserAdminBundle\\\\Form\\\\Transformer\\\\RestoreRolesTransformer\\:\\:setOriginalRoles\\(\\) has parameter \\$originalRoles with no value type specified in iterable type array\\.$#"
count: 1
path: src/Form/Transformer/RestoreRolesTransformer.php

-
message: "#^Method Nucleos\\\\UserAdminBundle\\\\Form\\\\Type\\\\SecurityRolesType\\:\\:buildForm\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
count: 1
path: src/Form/Type/SecurityRolesType.php

-
message: "#^Method Nucleos\\\\UserAdminBundle\\\\Form\\\\Type\\\\SecurityRolesType\\:\\:buildView\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
count: 1
path: src/Form/Type/SecurityRolesType.php

-
message: "#^Method Nucleos\\\\UserAdminBundle\\\\Security\\\\Authorization\\\\Voter\\\\UserAclVoter\\:\\:vote\\(\\) has parameter \\$attributes with no value type specified in iterable type array\\.$#"
count: 1
path: src/Security/Authorization/Voter/UserAclVoter.php

-
message: "#^Property Nucleos\\\\UserAdminBundle\\\\Security\\\\EditableRolesBuilder\\:\\:\\$rolesHierarchy type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Security/EditableRolesBuilder.php

-
message: "#^Method Nucleos\\\\UserAdminBundle\\\\Security\\\\EditableRolesBuilder\\:\\:__construct\\(\\) has parameter \\$rolesHierarchy with no value type specified in iterable type array\\.$#"
count: 1
path: src/Security/EditableRolesBuilder.php

-
message: "#^Method Nucleos\\\\UserAdminBundle\\\\Security\\\\RolesBuilder\\\\AdminRolesBuilder\\:\\:getRoles\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Security/RolesBuilder/AdminRolesBuilder.php

-
message: "#^Method Nucleos\\\\UserAdminBundle\\\\Security\\\\RolesBuilder\\\\ExpandableRolesBuilderInterface\\:\\:getExpandedRoles\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Security/RolesBuilder/ExpandableRolesBuilderInterface.php

-
message: "#^Method Nucleos\\\\UserAdminBundle\\\\Security\\\\RolesBuilder\\\\RolesBuilderInterface\\:\\:getRoles\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Security/RolesBuilder/RolesBuilderInterface.php

-
message: "#^Method Nucleos\\\\UserAdminBundle\\\\Security\\\\RolesBuilder\\\\SecurityRolesBuilder\\:\\:__construct\\(\\) has parameter \\$rolesHierarchy with no value type specified in iterable type array\\.$#"
count: 1
path: src/Security/RolesBuilder/SecurityRolesBuilder.php

-
message: "#^Method Nucleos\\\\UserAdminBundle\\\\Security\\\\RolesBuilder\\\\SecurityRolesBuilder\\:\\:getHierarchy\\(\\) should return array\\<array\\> but returns array\\<int\\|string, array\\|string\\>\\.$#"
count: 1
path: src/Security/RolesBuilder/SecurityRolesBuilder.php

-
message: "#^Strict comparison using \\=\\=\\= between false and array\\<int\\|string, array\\(\\)\\|string\\> will always evaluate to false\\.$#"
count: 1
path: src/Security/RolesBuilder/SecurityRolesBuilder.php

-
message: "#^Method Nucleos\\\\UserAdminBundle\\\\Security\\\\RolesBuilder\\\\SecurityRolesBuilder\\:\\:getSecurityRoles\\(\\) has parameter \\$hierarchy with no value type specified in iterable type array\\.$#"
count: 1
path: src/Security/RolesBuilder/SecurityRolesBuilder.php

-
message: "#^Method Nucleos\\\\UserAdminBundle\\\\Security\\\\RolesBuilder\\\\SecurityRolesBuilder\\:\\:recursiveArraySearch\\(\\) has parameter \\$roles with no value type specified in iterable type array\\.$#"
count: 1
path: src/Security/RolesBuilder/SecurityRolesBuilder.php

-
message: "#^Method Nucleos\\\\UserAdminBundle\\\\Tests\\\\Action\\\\LoginActionTest\\:\\:unauthenticatedProvider\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: tests/Action/LoginActionTest.php

-
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertTrue\\(\\) with true and string will always evaluate to true\\.$#"
count: 1
path: tests/Resources/XliffTest.php

2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0"/>
</php>
<testsuites>
<testsuite name="ProfileBundle Test Suite">
<testsuite name="UserAdminBundle Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
Expand Down
82 changes: 82 additions & 0 deletions src/Action/CheckEmailAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

declare(strict_types=1);

/*
* This file is part of the NucleosUserAdminBundle package.
*
* (c) Christian Gripp <mail@core23.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Nucleos\UserAdminBundle\Action;

use Sonata\AdminBundle\Admin\Pool;
use Sonata\AdminBundle\Templating\TemplateRegistryInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Twig\Environment;

final class CheckEmailAction
{
/**
* @var Environment
*/
private $twig;

/**
* @var UrlGeneratorInterface
*/
private $urlGenerator;

/**
* @var Pool
*/
private $adminPool;

/**
* @var TemplateRegistryInterface
*/
private $templateRegistry;

/**
* @var int
*/
private $resetTtl;

public function __construct(
Environment $twig,
UrlGeneratorInterface $urlGenerator,
Pool $adminPool,
TemplateRegistryInterface $templateRegistry,
int $resetTtl
) {
$this->twig = $twig;
$this->urlGenerator = $urlGenerator;
$this->adminPool = $adminPool;
$this->templateRegistry = $templateRegistry;
$this->resetTtl = $resetTtl;
}

public function __invoke(Request $request): Response
{
$username = trim($request->query->get('username', ''));

if ('' === $username) {
// the user does not come from the sendEmail action
return new RedirectResponse($this->urlGenerator->generate('nucleos_user_admin_resetting_request'));
}

return new Response(
$this->twig->render('@NucleosUserAdmin/Admin/Security/Resetting/checkEmail.html.twig', [
'base_template' => $this->templateRegistry->getTemplate('layout'),
'admin_pool' => $this->adminPool,
'tokenLifetime' => ceil($this->resetTtl / 3600),
])
);
}
}
26 changes: 26 additions & 0 deletions src/Action/CheckLoginAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

/*
* This file is part of the NucleosUserAdminBundle package.
*
* (c) Christian Gripp <mail@core23.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Nucleos\UserAdminBundle\Action;

use RuntimeException;

final class CheckLoginAction
{
public function __invoke(): void
{
throw new RuntimeException(
'You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.'
);
}
}
Loading

0 comments on commit 9826a32

Please sign in to comment.