Skip to content

Commit

Permalink
Added Mercure interfaces/traits
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-bacart committed Oct 15, 2021
1 parent 56ee511 commit 083b3a2
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .php-cs-fixer.dist.php
Expand Up @@ -18,9 +18,9 @@
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => ['default' => 'align'],
'phpdoc_add_missing_param_annotation' => ['only_untyped' => false],
'native_function_invocation' => ['include' => ['@compiler_optimized']],
'header_comment' => ['header' => $fileHeaderComment, 'separate' => 'both'],
'phpdoc_add_missing_param_annotation' => false,
'self_accessor' => false,
'fopen_flags' => false,
'combine_consecutive_unsets' => true,
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Expand Up @@ -12,12 +12,13 @@
"php": "^8.0"
},
"require-dev": {
"doctrine/orm": "^2.9",
"doctrine/orm": "^2.10",
"doctrine/mongodb-odm": "^2.2",
"friendsofphp/php-cs-fixer": "^3.1",
"friendsofphp/php-cs-fixer": "^3.2",
"phpstan/phpstan": "^0.12",
"symfony/framework-bundle": "^5.3",
"symfony/lock": "^5.3",
"symfony/mercure": "^0.6",
"symfony/messenger": "^5.3",
"symfony/security-core": "^5.3",
"symfony/security-csrf": "^5.3",
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/LoggerAwareInterface.php
Expand Up @@ -15,7 +15,7 @@

use Psr\Log\LoggerInterface;

interface LoggerAwareInterface extends LoggerInterface
interface LoggerAwareInterface
{
public function setLogger(LoggerInterface $logger): void;
}
21 changes: 21 additions & 0 deletions src/Interfaces/MercureAuthorizationAwareInterface.php
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Bacart package.
*
* (c) Alex Bacart <alex@bacart.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Bacart\SymfonyAware\Interfaces;

use Symfony\Component\Mercure\Authorization;

interface MercureAuthorizationAwareInterface
{
public function setMercureAuthorization(Authorization $mercureAuthorization): void;
}
21 changes: 21 additions & 0 deletions src/Interfaces/MercureHubAwareInterface.php
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Bacart package.
*
* (c) Alex Bacart <alex@bacart.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Bacart\SymfonyAware\Interfaces;

use Symfony\Component\Mercure\HubInterface;

interface MercureHubAwareInterface
{
public function setMercureHub(HubInterface $MercureHub): void;
}
28 changes: 28 additions & 0 deletions src/Traits/MercureAuthorizationAwareTrait.php
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Bacart package.
*
* (c) Alex Bacart <alex@bacart.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Bacart\SymfonyAware\Traits;

use Symfony\Component\Mercure\Authorization;
use Symfony\Contracts\Service\Attribute\Required;

trait MercureAuthorizationAwareTrait
{
protected Authorization $mercureAuthorization;

#[Required]
public function setMercureAuthorization(Authorization $mercureAuthorization): void
{
$this->mercureAuthorization = $mercureAuthorization;
}
}
28 changes: 28 additions & 0 deletions src/Traits/MercureHubAwareTrait.php
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Bacart package.
*
* (c) Alex Bacart <alex@bacart.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Bacart\SymfonyAware\Traits;

use Symfony\Component\Mercure\HubInterface;
use Symfony\Contracts\Service\Attribute\Required;

trait MercureHubAwareTrait
{
protected HubInterface $mercureHub;

#[Required]
public function setMercureHub(HubInterface $mercureHub): void
{
$this->mercureHub = $mercureHub;
}
}

0 comments on commit 083b3a2

Please sign in to comment.