Skip to content

Commit

Permalink
Merge pull request #39 from lchampel/compatible_sf2_sf3
Browse files Browse the repository at this point in the history
compatibilité sf2/sf3
  • Loading branch information
juliens authored Jul 2, 2016
2 parents 3a31219 + 44b6388 commit ea94bea
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ public function load(array $configs, ContainerBuilder $container)

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
wordpress.url_login: ''
wordpress.url_login: ''
wordpress.loader.class: Generic\WordpressBundle\Services\WordpressLoader
wordpress.shortcode_loader.class: Generic\WordpressBundle\Services\WordpressShortcodeLoader
wordpress.metabox_loader.class: Generic\WordpressBundle\Services\WordpressMetaboxLoader
Expand All @@ -22,15 +22,15 @@ services:

wordpress.security.authentication.listener:
class: Generic\WordpressBundle\Security\WordpressAuthenticationListener
arguments: ['@security.firewall.map.context.main', '@security.authentication.manager']
arguments: ['@security.token_storage', '@security.authentication.manager']

wordpress.loader:
class : %wordpress.loader.class%
arguments: [ %kernel.root_dir%/../wordpress, '@wordpress.shortcode_loader', '@wordpress.metabox_loader', '@wordpress.admin_menu_loader', '@wordpress.post_factory' ]

wordpress.shortcode_loader:
class: %wordpress.shortcode_loader.class%

wordpress.metabox_loader:
class: %wordpress.metabox_loader.class%

Expand Down Expand Up @@ -75,9 +75,4 @@ services:
class: %wordpress.wordpress_extension.class%
arguments: [ '@wordpress.loader' ]
tags:
- { name: twig.extension }

# wordpress.controller_resolver:
# class: %wordpress.controller_resolver.class%
# arguments: [@default.controller_resolver, @service_container ]

- { name: twig.extension }
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@

use Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\Security\Http\Firewall\ListenerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Generic\WordpressBundle\Security\WordpressToken;


class WordpressAuthenticationListener implements ListenerInterface
{
protected $securityContext;
protected $tokenStorage;
protected $authenticationManager;

public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager)
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager)
{
$this->securityContext = $securityContext;
$this->tokenStorage = $tokenStorage;
$this->authenticationManager = $authenticationManager;
}

Expand All @@ -28,7 +29,7 @@ public function handle(GetResponseEvent $event)
try {
$response = $this->authenticationManager->authenticate(new WordpressToken());
if ($response->isAuthenticated()) {
$this->securityContext->setToken($response);
$this->tokenStorage->setToken($response);
$session = $request->getSession();
$token_id = uniqid();
$session->set('token_id', $token_id);
Expand Down
20 changes: 16 additions & 4 deletions sources/wordpress/sf2/sf2plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@ class Sf2Plugin
private $kernel = null;
private $in_sf2 = true;

private function isValidSymfonyPath($dir)
private function getDirCacheSymfony($dir)
{
return (file_exists($dir . 'var/bootstrap.php.cache'));
$dirCache = 'app';
if(is_dir($dir.'/var')){
$dirCache = 'var';
}
return $dirCache;
}
private function isValidSymfonyPath($dir)
{
return (file_exists($dir . $this->getDirCacheSymfony($dir) .'/bootstrap.php.cache'));
}

private function calculatePath()
Expand Down Expand Up @@ -63,8 +71,12 @@ private function loadSf2()
}

if ($kernel == null) {
$loader = require_once $path . 'var/bootstrap.php.cache';
$autoload = require_once $path . 'app/autoload.php';

$dircache = $this->getDirCacheSymfony($path);
$loader = require_once $path . $dircache .'/bootstrap.php.cache';
if($dircache == 'var'){
$autoload = require_once $path . 'app/autoload.php';
}
require_once $path . 'app/AppKernel.php';
$debug = true;
if ($env == 'prod') {
Expand Down

0 comments on commit ea94bea

Please sign in to comment.