Skip to content

Commit

Permalink
Merge pull request #7 from netbrothers-gmbh/6-symfony-63
Browse files Browse the repository at this point in the history
🔀 ready for symfony 6.3
  • Loading branch information
netbrothers-sw authored Aug 22, 2023
2 parents a559204 + 2e23321 commit 57d7eb3
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 96 deletions.
17 changes: 1 addition & 16 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1 @@
###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###

###> symfony/phpunit-bridge ###
.phpunit
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###
/.idea
.idea
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog for NetBrothers SyncAcc
===================================

Version 0.1.0 - 22.08.2023
----------------------------------
- Replace annotations with attributes for using in Symfony ^6.3


Version 0.0.2 - 03.02.2022
----------------------------------
- Fix Bug SyncCommand option `sync-table` does not accept any value.
Expand Down
9 changes: 3 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"name": "netbrothers-gmbh/syncacc-bundle",
"description": "Using NetBrothers Access Control Center in Symfony",
"version": "0.0.2",
"keywords": ["symfony","bundle","permissions","acl"],
"type": "symfony-bundle",
"require": {
"php": ">=7.4",
"symfony/console": "*",
"symfony/dotenv": "*",
"symfony/orm-pack": "*",
"ext-json": "*"
"php": ">=8.1",
"ext-json": "*",
"symfony/console": "^6.3"
},
"autoload": {
"psr-4": {
Expand Down
13 changes: 9 additions & 4 deletions src/Command/SyncCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Doctrine\ORM\EntityManagerInterface;
use NetBrothers\SyncAccBundle\Services\HttpClientService;
use NetBrothers\SyncAccBundle\Services\SyncService;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand All @@ -27,6 +28,10 @@
* Class SyncCommand
* @package NetBrothers\SyncAccBundle\Command
*/
#[AsCommand(
name: 'netbrothers:sync-acc',
description: 'Synchronize permissions with Access Control Center in your local instance.',
)]
class SyncCommand extends Command
{
protected static $defaultName = 'netbrothers:sync-acc';
Expand Down Expand Up @@ -72,11 +77,10 @@ class SyncCommand extends Command
/** @var HttpClientService */
private HttpClientService $httpService;

protected function configure()
protected function configure(): void
{
$this
->setName(self::$defaultName)
->setDescription('Synchronize permissions with Access Control Center in your local instance.')
->setHelp(self::HELP_TEXT)
->addOption(
'sync-table',
Expand All @@ -91,11 +95,12 @@ protected function configure()
* SyncAccCommand constructor.
* @param EntityManagerInterface $entityManager
* @param array $config
* @param string|null $name
* @throws \Exception
*/
public function __construct(EntityManagerInterface $entityManager, array $config = [])
public function __construct(EntityManagerInterface $entityManager, array $config = [], string $name = null)
{
parent::__construct();
parent::__construct($name);
$this->setConfig($config);
$this->httpService = new HttpClientService($this->config, $this->clientConfig);
$this->service = new SyncService($entityManager, $this->httpService);
Expand Down
30 changes: 11 additions & 19 deletions src/Entity/AclAllow.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,37 @@

namespace NetBrothers\SyncAccBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use NetBrothers\SyncAccBundle\Repository\AclAllowRepository;

/**
* Class AclAllow
* @package NetBrothers\SyncAccBundle\Entity
* @ORM\Entity(repositoryClass="NetBrothers\SyncAccBundle\Repository\AclAllowRepository")
*/
#[ORM\Entity(repositoryClass: AclAllowRepository::class)]
class AclAllow
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private int $id;

/**
* @ORM\Column(type="integer")
*/
#[ORM\Column]
private int $idAclRole;

/**
* @ORM\Column(type="string", length=255)
*/
#[ORM\Column(length: 255)]
private string $controllerName;

/**
* @ORM\Column(type="string", length=255)
*/
#[ORM\Column(length: 255)]
private string $actionName;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
#[ORM\Column(length: 255, nullable: true)]
private string $method;

/**
* @ORM\Column(type="integer", nullable=true)
*/
private int $reasonType;
#[ORM\Column(nullable: true)]
private ?int $reasonType = null;

public function getId(): ?int
{
Expand Down
33 changes: 12 additions & 21 deletions src/Entity/AclRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,41 @@
*/

namespace NetBrothers\SyncAccBundle\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use NetBrothers\SyncAccBundle\Repository\AclRoleRepository;

/**
* Class AclRole
* @package NetBrothers\SyncAccBundle\Entity
* @ORM\Entity(repositoryClass="NetBrothers\SyncAccBundle\Repository\AclRoleRepository")
*/
#[ORM\Entity(repositoryClass: AclRoleRepository::class)]
class AclRole
{
/**
* @ORM\Id()
* @ORM\GeneratedValue(strategy="NONE")
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private int $id;

/**
* @ORM\Column(type="string", length=255)
*/
#[ORM\Column(length: 255)]
private string $name;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
#[ORM\Column(length: 255, nullable: true)]
private ?string $displayName = null;

/**
* @ORM\Column(type="text", nullable=true)
*/
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $beschreibung = null;

/**
* @ORM\Column(type="integer", nullable=true, options={"default":0})
*/
#[ORM\Column(nullable: true, options: ['default' => 0])]
private int $hierarchyId = 0;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
#[ORM\Column(length: 255, nullable: true)]
private ?string $defaultRoute = null;

/**
* @ORM\Column(type="boolean", options={"default":false})
*/
#[ORM\Column(options: ["default" => false])]
private bool $isHidden = false;

public function setId(int $id): self
Expand Down
24 changes: 9 additions & 15 deletions src/Entity/SyncAcc.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,26 @@
*/

namespace NetBrothers\SyncAccBundle\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use NetBrothers\SyncAccBundle\Repository\SyncAccRepository;

/**
* Class SyncAcc
* @package NetBrothers\SyncAccBundle\Entity
* @ORM\Entity(repositoryClass="NetBrothers\SyncAccBundle\Repository\SyncAccRepository")
*/
#[ORM\Entity(repositoryClass: SyncAccRepository::class)]
class SyncAcc
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private int $id;

/**
* @ORM\Column(type="string", length=255)
*/
#[ORM\Column(length: 255)]
private string $actionName;

/**
* @ORM\Column(type="datetime")
*/
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $lastCall = null;

public function getId(): ?int
Expand All @@ -47,7 +43,6 @@ public function getActionName(): ?string
public function setActionName(string $actionName): self
{
$this->actionName = $actionName;

return $this;
}

Expand All @@ -56,10 +51,9 @@ public function getLastCall(): ?\DateTimeInterface
return $this->lastCall;
}

public function setLastCall(\DateTimeInterface $lastCall): self
public function setLastCall(?\DateTimeInterface $lastCall = null): self
{
$this->lastCall = $lastCall;

return $this;
}
}
1 change: 0 additions & 1 deletion src/Services/AccService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace NetBrothers\SyncAccBundle\Services;


use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityManagerInterface;
use NetBrothers\SyncAccBundle\Entity\AclAllow;
Expand Down
6 changes: 3 additions & 3 deletions src/Services/HttpClientService.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ public function getRoles(SyncAcc $syncAcc)
/**
* @param SyncAcc $syncAcc
* @param int $idRole
* @return bool
* @return false|mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getPermissionForOneRole(SyncAcc $syncAcc, int $idRole)
public function getPermissionForOneRole(SyncAcc $syncAcc, int $idRole): mixed
{
$url = $this->createUrl($syncAcc, $idRole);
return $this->send($url);
Expand Down Expand Up @@ -124,7 +124,7 @@ private function createUrl(SyncAcc $syncAcc, int $idRole = null): string
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
private function send(string $url)
private function send(string $url): mixed
{
$client = HttpClient::create($this->clientConfig);
$response = $client->request('GET', $url);
Expand Down
6 changes: 3 additions & 3 deletions src/Services/SyncService.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct(EntityManagerInterface $entityManager, HttpClientSer
* @param string $requestAction
* @throws \Exception|TransportExceptionInterface
*/
public function execute(string $requestAction = 'get-roles')
public function execute(string $requestAction = 'get-roles'): void
{
if ($requestAction == 'all') {
$this->requestAction = 'get-roles';
Expand Down Expand Up @@ -84,7 +84,7 @@ public function execute(string $requestAction = 'get-roles')
* @throws TransportExceptionInterface
* @throws \Exception
*/
private function getRoles()
private function getRoles(): void
{
$response = $this->clientService->getRoles($this->tableService->getSyncAccEntity());
if (false === $response) {
Expand All @@ -107,7 +107,7 @@ private function getRoles()
* @throws TransportExceptionInterface
* @throws \Exception
*/
private function getPermissionsForRoles()
private function getPermissionsForRoles(): void
{
$repository = $this->entityManager->getRepository(AclRole::class);
/** @var AclRole $role */
Expand Down
Loading

0 comments on commit 57d7eb3

Please sign in to comment.