Skip to content

Commit

Permalink
Update package compatibility with doctrine
Browse files Browse the repository at this point in the history
  • Loading branch information
costin committed Feb 20, 2020
1 parent e499164 commit e3bcccc
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 23 deletions.
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
"mezzio/mezzio-twigrenderer": "^2.2",
"laminas/laminas-view": "^2.10",
"ocramius/proxy-manager": "^2.1",
"laminas/laminas-dependency-plugin": "^1.0"
"laminas/laminas-authentication": "^2.7"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"squizlabs/php_codesniffer": "^2.3",
"dotkernel/dot-authorization": "^2.0",
"dotkernel/dot-authentication": "^2.0",
"dotkernel/dot-navigation": "^2.0",
"dotkernel/dot-flashmessenger": "^2.0",
"laminas/laminas-form": "^2.9"
"laminas/laminas-form": "^2.9",
"doctrine/doctrine-module": "^3.0",
"laminas/laminas-dependency-plugin": "^1.0",
"mezzio/mezzio-authorization": "^1.0"
},
"autoload": {
"psr-4": {
Expand Down
5 changes: 5 additions & 0 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Dot\Twig;

use DoctrineModule\Service\Authentication\AuthenticationServiceFactory;
use Dot\FlashMessenger\View\FlashMessengerRenderer;
use Dot\Navigation\View\NavigationRenderer;
use Dot\Twig\Extension\AuthenticationExtension;
Expand All @@ -21,6 +22,8 @@
use Dot\Twig\Factory\FlashMessengerExtensionFactory;
use Dot\Twig\Factory\NavigationExtensionFactory;
use Dot\Twig\Laminas\View\HelperPluginManagerFactory;
use Laminas\Authentication\AuthenticationService;
use Laminas\Authentication\AuthenticationServiceInterface;
use Laminas\ServiceManager\Factory\InvokableFactory;
use Laminas\ServiceManager\Proxy\LazyServiceFactory;
use Laminas\View\HelperPluginManager;
Expand Down Expand Up @@ -52,6 +55,7 @@ public function getDependencyConfig(): array
NavigationExtension::class => NavigationExtensionFactory::class,
FlashMessengerExtension::class => FlashMessengerExtensionFactory::class,
FormElementsExtension::class => InvokableFactory::class,
AuthenticationService::class => AuthenticationServiceFactory::class
],

'delegators' => [
Expand Down Expand Up @@ -79,6 +83,7 @@ public function getDependencyConfig(): array

'aliases' => [
'ViewHelperManager' => HelperPluginManager::class,
AuthenticationServiceInterface::class => AuthenticationService::class
],
];
}
Expand Down
11 changes: 5 additions & 6 deletions src/Extension/AuthenticationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

namespace Dot\Twig\Extension;

use Dot\Authentication\AuthenticationInterface;
use Dot\Authentication\Identity\IdentityInterface;
use Laminas\Authentication\AuthenticationServiceInterface;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

Expand All @@ -20,14 +19,14 @@
*/
class AuthenticationExtension extends AbstractExtension
{
/** @var AuthenticationInterface */
/** @var AuthenticationServiceInterface */
protected $authentication;

/**
* AuthenticationExtension constructor.
* @param AuthenticationInterface $authentication
* @param AuthenticationServiceInterface $authentication
*/
public function __construct(AuthenticationInterface $authentication)
public function __construct(AuthenticationServiceInterface $authentication)
{
$this->authentication = $authentication;
}
Expand All @@ -53,7 +52,7 @@ public function hasIdentity(): bool
return $this->authentication->hasIdentity();
}

public function getIdentity(): IdentityInterface
public function getIdentity()
{
return $this->authentication->getIdentity();
}
Expand Down
14 changes: 7 additions & 7 deletions src/Extension/AuthorizationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

namespace Dot\Twig\Extension;

use Dot\Authorization\AuthorizationInterface;
use Mezzio\Authorization\AuthorizationInterface;
use Psr\Http\Message\ServerRequestInterface;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

Expand Down Expand Up @@ -45,13 +46,12 @@ public function getFunctions(): array
}

/**
* @param $permission
* @param array $roles
* @param mixed $context
* @return bool
* @param ServerRequestInterface $request
* @param string $role
* @return mixed
*/
public function isGranted(string $permission, array $roles = [], $context = null)
public function isGranted(ServerRequestInterface $request, string $role = '')
{
return $this->authorization->isGranted($permission, $roles, $context);
return $this->authorization->isGranted($role, $request);
}
}
4 changes: 2 additions & 2 deletions src/Factory/AuthenticationExtensionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

namespace Dot\Twig\Factory;

use Dot\Authentication\AuthenticationInterface;
use Dot\Twig\Extension\AuthenticationExtension;
use Laminas\Authentication\AuthenticationServiceInterface;
use Psr\Container\ContainerInterface;

/**
Expand All @@ -25,6 +25,6 @@ class AuthenticationExtensionFactory
*/
public function __invoke(ContainerInterface $container)
{
return new AuthenticationExtension($container->get(AuthenticationInterface::class));
return new AuthenticationExtension($container->get(AuthenticationServiceInterface::class));
}
}
2 changes: 1 addition & 1 deletion src/Factory/AuthorizationExtensionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Dot\Twig\Factory;

use Dot\Authorization\AuthorizationInterface;
use Mezzio\Authorization\AuthorizationInterface;
use Dot\Twig\Extension\AuthorizationExtension;
use Psr\Container\ContainerInterface;

Expand Down
6 changes: 3 additions & 3 deletions src/TwigEnvironmentDelegator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

namespace Dot\Twig;

use Dot\Authentication\AuthenticationInterface;
use Dot\Authorization\AuthorizationInterface;
use Mezzio\Authorization\AuthorizationInterface;
use Dot\FlashMessenger\View\RendererInterface as FlashMessengerRendererInterface;
use Dot\Navigation\View\RendererInterface as NavigationRendererInterface;
use Dot\Twig\Extension\AuthenticationExtension;
use Dot\Twig\Extension\AuthorizationExtension;
use Dot\Twig\Extension\FlashMessengerExtension;
use Dot\Twig\Extension\FormElementsExtension;
use Dot\Twig\Extension\NavigationExtension;
use Laminas\Authentication\AuthenticationServiceInterface;
use Psr\Container\ContainerInterface;
use Twig\Environment;
use Twig\TwigFunction;
Expand Down Expand Up @@ -58,7 +58,7 @@ function ($name) use ($viewHelperManager, $zfRenderer) {
);

//add our default extensions, if dependencies are present
if ($container->has(AuthenticationInterface::class)) {
if ($container->has(AuthenticationServiceInterface::class)) {
$environment->addExtension($container->get(AuthenticationExtension::class));
}

Expand Down

0 comments on commit e3bcccc

Please sign in to comment.