update php-cs-fixer
This commit is contained in:
parent
574a2afa8b
commit
f517faa071
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
composer.lock
|
composer.lock
|
||||||
vendor
|
vendor
|
||||||
.idea
|
.idea
|
||||||
|
.php_cs.cache
|
||||||
|
|
|
@ -10,7 +10,8 @@ class Application
|
||||||
public $route;
|
public $route;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct()
|
||||||
|
{
|
||||||
$this->http = new HttpMethod();
|
$this->http = new HttpMethod();
|
||||||
$this->browser = new Browser();
|
$this->browser = new Browser();
|
||||||
|
|
||||||
|
@ -20,7 +21,8 @@ class Application
|
||||||
$this->route = $dispacher->route;
|
$this->route = $dispacher->route;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function launch(){
|
public function launch()
|
||||||
|
{
|
||||||
//print_r($this->route);
|
//print_r($this->route);
|
||||||
$controlleur = new Controlleur($this);
|
$controlleur = new Controlleur($this);
|
||||||
//si la page n'est un controlleur d'action alors on affiche l'écran
|
//si la page n'est un controlleur d'action alors on affiche l'écran
|
||||||
|
@ -28,5 +30,4 @@ class Application
|
||||||
print($controlleur->vue->ecran);
|
print($controlleur->vue->ecran);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,8 @@
|
||||||
|
|
||||||
namespace MVC\Classe;
|
namespace MVC\Classe;
|
||||||
|
|
||||||
|
|
||||||
class Asynchonous
|
class Asynchonous
|
||||||
{
|
{
|
||||||
|
|
||||||
private $_css;
|
private $_css;
|
||||||
private $_javascript;
|
private $_javascript;
|
||||||
|
|
||||||
|
@ -37,5 +35,4 @@ class Asynchonous
|
||||||
{
|
{
|
||||||
echo $this->_javascript;
|
echo $this->_javascript;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -44,7 +44,8 @@ class Bdd
|
||||||
* @param array|null $params
|
* @param array|null $params
|
||||||
* @return bool|\PDOStatement
|
* @return bool|\PDOStatement
|
||||||
*/
|
*/
|
||||||
public function faireBindRequete($sql,Array $params = null){
|
public function faireBindRequete($sql, array $params = null)
|
||||||
|
{
|
||||||
$req = $this->bdd->prepare($sql);
|
$req = $this->bdd->prepare($sql);
|
||||||
if ($params) {
|
if ($params) {
|
||||||
foreach ($params as $value) {
|
foreach ($params as $value) {
|
||||||
|
@ -56,7 +57,8 @@ class Bdd
|
||||||
return $req;
|
return $req;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function exploiterResultat($req){
|
public function exploiterResultat($req)
|
||||||
|
{
|
||||||
$res = $req->fetchAll();
|
$res = $req->fetchAll();
|
||||||
foreach ($res as $data) {
|
foreach ($res as $data) {
|
||||||
foreach ($data as $key => $row) {
|
foreach ($data as $key => $row) {
|
||||||
|
|
|
@ -3,10 +3,8 @@
|
||||||
|
|
||||||
namespace MVC\Classe;
|
namespace MVC\Classe;
|
||||||
|
|
||||||
|
|
||||||
class Browser
|
class Browser
|
||||||
{
|
{
|
||||||
|
|
||||||
public $user;
|
public $user;
|
||||||
public $userAgent;
|
public $userAgent;
|
||||||
|
|
||||||
|
@ -29,43 +27,73 @@ class Browser
|
||||||
$t = " " . $t;
|
$t = " " . $t;
|
||||||
|
|
||||||
// Humans / Regular Users
|
// Humans / Regular Users
|
||||||
if (strpos($t, 'opera') || strpos($t, 'opr/')) return 'Opera';
|
if (strpos($t, 'opera') || strpos($t, 'opr/')) {
|
||||||
elseif (strpos($t, 'edge')) return 'Edge';
|
return 'Opera';
|
||||||
elseif (strpos($t, 'chrome')) return 'Chrome';
|
} elseif (strpos($t, 'edge')) {
|
||||||
elseif (strpos($t, 'safari')) return 'Safari';
|
return 'Edge';
|
||||||
elseif (strpos($t, 'firefox')) return 'Firefox';
|
} elseif (strpos($t, 'chrome')) {
|
||||||
elseif (strpos($t, 'msie') || strpos($t, 'trident/7')) return 'Internet Explorer';
|
return 'Chrome';
|
||||||
|
} elseif (strpos($t, 'safari')) {
|
||||||
|
return 'Safari';
|
||||||
|
} elseif (strpos($t, 'firefox')) {
|
||||||
|
return 'Firefox';
|
||||||
|
} elseif (strpos($t, 'msie') || strpos($t, 'trident/7')) {
|
||||||
|
return 'Internet Explorer';
|
||||||
|
}
|
||||||
|
|
||||||
// Application Users
|
// Application Users
|
||||||
elseif (strpos($t, 'curl')) return '[App] Curl';
|
elseif (strpos($t, 'curl')) {
|
||||||
|
return '[App] Curl';
|
||||||
|
}
|
||||||
|
|
||||||
// Search Engines
|
// Search Engines
|
||||||
elseif (strpos($t, 'google')) return '[Bot] Googlebot';
|
elseif (strpos($t, 'google')) {
|
||||||
elseif (strpos($t, 'bing')) return '[Bot] Bingbot';
|
return '[Bot] Googlebot';
|
||||||
elseif (strpos($t, 'slurp')) return '[Bot] Yahoo! Slurp';
|
} elseif (strpos($t, 'bing')) {
|
||||||
elseif (strpos($t, 'duckduckgo')) return '[Bot] DuckDuckBot';
|
return '[Bot] Bingbot';
|
||||||
elseif (strpos($t, 'baidu')) return '[Bot] Baidu';
|
} elseif (strpos($t, 'slurp')) {
|
||||||
elseif (strpos($t, 'yandex')) return '[Bot] Yandex';
|
return '[Bot] Yahoo! Slurp';
|
||||||
elseif (strpos($t, 'sogou')) return '[Bot] Sogou';
|
} elseif (strpos($t, 'duckduckgo')) {
|
||||||
elseif (strpos($t, 'exabot')) return '[Bot] Exabot';
|
return '[Bot] DuckDuckBot';
|
||||||
elseif (strpos($t, 'msn')) return '[Bot] MSN';
|
} elseif (strpos($t, 'baidu')) {
|
||||||
|
return '[Bot] Baidu';
|
||||||
|
} elseif (strpos($t, 'yandex')) {
|
||||||
|
return '[Bot] Yandex';
|
||||||
|
} elseif (strpos($t, 'sogou')) {
|
||||||
|
return '[Bot] Sogou';
|
||||||
|
} elseif (strpos($t, 'exabot')) {
|
||||||
|
return '[Bot] Exabot';
|
||||||
|
} elseif (strpos($t, 'msn')) {
|
||||||
|
return '[Bot] MSN';
|
||||||
|
}
|
||||||
|
|
||||||
// Common Tools and Bots
|
// Common Tools and Bots
|
||||||
elseif (strpos($t, 'mj12bot')) return '[Bot] Majestic';
|
elseif (strpos($t, 'mj12bot')) {
|
||||||
elseif (strpos($t, 'ahrefs')) return '[Bot] Ahrefs';
|
return '[Bot] Majestic';
|
||||||
elseif (strpos($t, 'semrush')) return '[Bot] SEMRush';
|
} elseif (strpos($t, 'ahrefs')) {
|
||||||
elseif (strpos($t, 'rogerbot') || strpos($t, 'dotbot')) return '[Bot] Moz or OpenSiteExplorer';
|
return '[Bot] Ahrefs';
|
||||||
elseif (strpos($t, 'frog') || strpos($t, 'screaming')) return '[Bot] Screaming Frog';
|
} elseif (strpos($t, 'semrush')) {
|
||||||
|
return '[Bot] SEMRush';
|
||||||
|
} elseif (strpos($t, 'rogerbot') || strpos($t, 'dotbot')) {
|
||||||
|
return '[Bot] Moz or OpenSiteExplorer';
|
||||||
|
} elseif (strpos($t, 'frog') || strpos($t, 'screaming')) {
|
||||||
|
return '[Bot] Screaming Frog';
|
||||||
|
}
|
||||||
|
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
elseif (strpos($t, 'facebook')) return '[Bot] Facebook';
|
elseif (strpos($t, 'facebook')) {
|
||||||
elseif (strpos($t, 'pinterest')) return '[Bot] Pinterest';
|
return '[Bot] Facebook';
|
||||||
|
} elseif (strpos($t, 'pinterest')) {
|
||||||
|
return '[Bot] Pinterest';
|
||||||
|
}
|
||||||
|
|
||||||
// Check for strings commonly used in bot user agents
|
// Check for strings commonly used in bot user agents
|
||||||
elseif (strpos($t, 'crawler') || strpos($t, 'api') ||
|
elseif (strpos($t, 'crawler') || strpos($t, 'api') ||
|
||||||
strpos($t, 'spider') || strpos($t, 'http') ||
|
strpos($t, 'spider') || strpos($t, 'http') ||
|
||||||
strpos($t, 'bot') || strpos($t, 'archive') ||
|
strpos($t, 'bot') || strpos($t, 'archive') ||
|
||||||
strpos($t, 'info') || strpos($t, 'data')) return '[Bot] Other';
|
strpos($t, 'info') || strpos($t, 'data')) {
|
||||||
|
return '[Bot] Other';
|
||||||
|
}
|
||||||
|
|
||||||
return 'Other (Unknown)';
|
return 'Other (Unknown)';
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,10 @@
|
||||||
|
|
||||||
namespace MVC\Classe;
|
namespace MVC\Classe;
|
||||||
|
|
||||||
|
|
||||||
use ForceUTF8\Encoding;
|
use ForceUTF8\Encoding;
|
||||||
|
|
||||||
class Caracter
|
class Caracter
|
||||||
{
|
{
|
||||||
|
|
||||||
public static function normalise_ChaineDeCaracteres($chaine)
|
public static function normalise_ChaineDeCaracteres($chaine)
|
||||||
{
|
{
|
||||||
return Encoding::fixUTF8(Caracter::fp_stripslashes($chaine));
|
return Encoding::fixUTF8(Caracter::fp_stripslashes($chaine));
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
namespace MVC\Classe;
|
namespace MVC\Classe;
|
||||||
|
|
||||||
class Controlleur{
|
class Controlleur
|
||||||
|
{
|
||||||
public $modele;
|
public $modele;
|
||||||
public $vue;
|
public $vue;
|
||||||
|
|
||||||
public function __construct($application){
|
public function __construct($application)
|
||||||
|
{
|
||||||
switch ($application->http->method) {
|
switch ($application->http->method) {
|
||||||
//cas des requètes PUT et DELETE
|
//cas des requètes PUT et DELETE
|
||||||
case 'PUT':
|
case 'PUT':
|
||||||
|
@ -20,8 +20,9 @@ class Controlleur{
|
||||||
$this->callHttpResponse($application);
|
$this->callHttpResponse($application);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
// no break
|
||||||
default:
|
default:
|
||||||
if ($application->route != NULL) {
|
if ($application->route != null) {
|
||||||
$conduit = explode('::', $application->route['controller']);
|
$conduit = explode('::', $application->route['controller']);
|
||||||
require CONDUIT_PATH . DIRECTORY_SEPARATOR . $conduit[0] . '.php';
|
require CONDUIT_PATH . DIRECTORY_SEPARATOR . $conduit[0] . '.php';
|
||||||
$conduitRoute = "\\" . $conduit[0];
|
$conduitRoute = "\\" . $conduit[0];
|
||||||
|
@ -30,7 +31,6 @@ class Controlleur{
|
||||||
$class->initialize($application->route);
|
$class->initialize($application->route);
|
||||||
$this->vue = new VueVide();
|
$this->vue = new VueVide();
|
||||||
$this->vue->ecran = $class->$method();
|
$this->vue->ecran = $class->$method();
|
||||||
|
|
||||||
} elseif ($application->url->page['control']) {
|
} elseif ($application->url->page['control']) {
|
||||||
$url_params = $application->url->page['params'];
|
$url_params = $application->url->page['params'];
|
||||||
require TRAITEMENT_PATH . DIRECTORY_SEPARATOR . $application->url->page['name'] . '.php';
|
require TRAITEMENT_PATH . DIRECTORY_SEPARATOR . $application->url->page['name'] . '.php';
|
||||||
|
@ -39,8 +39,6 @@ class Controlleur{
|
||||||
$this->vue = new Vue($this);
|
$this->vue = new Vue($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function callHttpResponse($application)
|
public function callHttpResponse($application)
|
||||||
|
@ -62,5 +60,4 @@ class Controlleur{
|
||||||
$this->vue->ecran = $reponse->$method();
|
$this->vue->ecran = $reponse->$method();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,8 @@
|
||||||
|
|
||||||
namespace MVC\Classe;
|
namespace MVC\Classe;
|
||||||
|
|
||||||
|
|
||||||
class ControlleurAction
|
class ControlleurAction
|
||||||
{
|
{
|
||||||
|
|
||||||
public static function inserer($action, $data = array())
|
public static function inserer($action, $data = array())
|
||||||
{
|
{
|
||||||
$action = explode('.', $action);
|
$action = explode('.', $action);
|
||||||
|
@ -21,13 +19,8 @@ class ControlleurAction
|
||||||
} else {
|
} else {
|
||||||
return $slot->default($data);
|
return $slot->default($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/*HandleError*/
|
/*HandleError*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,10 +9,8 @@ use Symfony\Component\Routing\RequestContext as RequestContext;
|
||||||
use Symfony\Component\Routing\Loader\YamlFileLoader as YamlFileLoader;
|
use Symfony\Component\Routing\Loader\YamlFileLoader as YamlFileLoader;
|
||||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||||
|
|
||||||
|
|
||||||
class Dispacher
|
class Dispacher
|
||||||
{
|
{
|
||||||
|
|
||||||
public $route;
|
public $route;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
|
@ -20,7 +18,7 @@ class Dispacher
|
||||||
|
|
||||||
//Avoid callback from empty homepage
|
//Avoid callback from empty homepage
|
||||||
if ($_SERVER['REQUEST_URI'] == '/' || $_SERVER['REQUEST_URI'] == '') {
|
if ($_SERVER['REQUEST_URI'] == '/' || $_SERVER['REQUEST_URI'] == '') {
|
||||||
$this->route = NULL;
|
$this->route = null;
|
||||||
} else {
|
} else {
|
||||||
//Test the route from config file
|
//Test the route from config file
|
||||||
try {
|
try {
|
||||||
|
@ -38,7 +36,7 @@ class Dispacher
|
||||||
|
|
||||||
$this->route = $parameters;
|
$this->route = $parameters;
|
||||||
} catch (ResourceNotFoundException $e) {
|
} catch (ResourceNotFoundException $e) {
|
||||||
$this->route = NULL;
|
$this->route = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
namespace MVC\Classe;
|
namespace MVC\Classe;
|
||||||
|
|
||||||
|
class Dumper
|
||||||
class Dumper{
|
{
|
||||||
|
public static function dump($var)
|
||||||
public static function dump($var){
|
{
|
||||||
echo "<pre>";
|
echo "<pre>";
|
||||||
if (is_bool($var)) {
|
if (is_bool($var)) {
|
||||||
echo ($var) ? "true" : "false";
|
echo ($var) ? "true" : "false";
|
||||||
|
@ -21,7 +21,6 @@ class Dumper{
|
||||||
*/
|
*/
|
||||||
public static function setPHPvalues()
|
public static function setPHPvalues()
|
||||||
{
|
{
|
||||||
|
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
ini_set('display_startup_errors', 1);
|
ini_set('display_startup_errors', 1);
|
||||||
ini_set('memory_limit', -1);
|
ini_set('memory_limit', -1);
|
||||||
|
|
|
@ -3,10 +3,8 @@
|
||||||
|
|
||||||
namespace MVC\Classe;
|
namespace MVC\Classe;
|
||||||
|
|
||||||
|
|
||||||
class HttpMethod
|
class HttpMethod
|
||||||
{
|
{
|
||||||
|
|
||||||
public $method;
|
public $method;
|
||||||
protected $data;
|
protected $data;
|
||||||
|
|
||||||
|
@ -28,6 +26,7 @@ class HttpMethod
|
||||||
//$this->data['GET'] = ...
|
//$this->data['GET'] = ...
|
||||||
//POST DATA except enctype="multipart/form-data"
|
//POST DATA except enctype="multipart/form-data"
|
||||||
$this->data = json_decode(file_get_contents("php://input"), true);
|
$this->data = json_decode(file_get_contents("php://input"), true);
|
||||||
|
// no break
|
||||||
case 'DELETE':
|
case 'DELETE':
|
||||||
//$this->data['GET'] = ...
|
//$this->data['GET'] = ...
|
||||||
//POST DATA except enctype="multipart/form-data"
|
//POST DATA except enctype="multipart/form-data"
|
||||||
|
@ -44,5 +43,4 @@ class HttpMethod
|
||||||
{
|
{
|
||||||
return $this->data;
|
return $this->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
namespace MVC\Classe;
|
namespace MVC\Classe;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Response
|
* Class Response
|
||||||
*
|
*
|
||||||
|
@ -165,8 +164,6 @@ class HttpMethodRequete
|
||||||
|
|
||||||
/** Pour utiliser ce code il faut mettre la variable safe_mode a ON dans php.ini */
|
/** Pour utiliser ce code il faut mettre la variable safe_mode a ON dans php.ini */
|
||||||
//exec($curl_cmd);
|
//exec($curl_cmd);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -218,5 +215,4 @@ class HttpMethodRequete
|
||||||
{
|
{
|
||||||
return $this->replaceContext('DELETE')->addContent($params)->send();
|
return $this->replaceContext('DELETE')->addContent($params)->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -3,14 +3,10 @@
|
||||||
|
|
||||||
namespace MVC\Classe\Implement;
|
namespace MVC\Classe\Implement;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Action
|
class Action
|
||||||
{
|
{
|
||||||
public function render($view, $data)
|
public function render($view, $data)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
$paths = new \SplPriorityQueue;
|
$paths = new \SplPriorityQueue;
|
||||||
|
|
||||||
$paths->insert(VIEW_PATH . DIRECTORY_SEPARATOR . "system", 100);
|
$paths->insert(VIEW_PATH . DIRECTORY_SEPARATOR . "system", 100);
|
||||||
|
@ -20,6 +16,5 @@ class Action
|
||||||
$renderer = new \Windwalker\Renderer\BladeRenderer($paths, array('cache_path' => VIEW_PATH . DIRECTORY_SEPARATOR . "cache"));
|
$renderer = new \Windwalker\Renderer\BladeRenderer($paths, array('cache_path' => VIEW_PATH . DIRECTORY_SEPARATOR . "cache"));
|
||||||
|
|
||||||
return $renderer->render($view, $data);
|
return $renderer->render($view, $data);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,14 +3,12 @@
|
||||||
|
|
||||||
namespace MVC\Classe\Implement;
|
namespace MVC\Classe\Implement;
|
||||||
|
|
||||||
|
|
||||||
class Conduit extends Action
|
class Conduit extends Action
|
||||||
{
|
{
|
||||||
public function initialize($var)
|
public function initialize($var)
|
||||||
{
|
{
|
||||||
//Export variable from conduit
|
//Export variable from conduit
|
||||||
foreach ($var as $key => $value) {
|
foreach ($var as $key => $value) {
|
||||||
|
|
||||||
if ($key != "controller") {
|
if ($key != "controller") {
|
||||||
if ($key != "_route") {
|
if ($key != "_route") {
|
||||||
$this->$key = $value;
|
$this->$key = $value;
|
||||||
|
|
|
@ -7,7 +7,6 @@ use MVC\Classe\Implement\Contrat\HttpReponseInterface;
|
||||||
|
|
||||||
class HttpReponse extends Action implements HttpReponseInterface
|
class HttpReponse extends Action implements HttpReponseInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public $url;
|
public $url;
|
||||||
public $params;
|
public $params;
|
||||||
public $data;
|
public $data;
|
||||||
|
@ -35,12 +34,9 @@ class HttpReponse extends Action implements HttpReponseInterface
|
||||||
|
|
||||||
public function put()
|
public function put()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -10,7 +10,6 @@ use MVC\Classe\Implement\Contrat\RestReponseInterface;
|
||||||
|
|
||||||
class RestReponse implements RestReponseInterface
|
class RestReponse implements RestReponseInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public $url;
|
public $url;
|
||||||
public $params;
|
public $params;
|
||||||
public $data;
|
public $data;
|
||||||
|
@ -38,21 +37,17 @@ class RestReponse implements RestReponseInterface
|
||||||
|
|
||||||
public function get()
|
public function get()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function post()
|
public function post()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function put()
|
public function put()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,13 +3,11 @@
|
||||||
|
|
||||||
namespace MVC\Classe;
|
namespace MVC\Classe;
|
||||||
|
|
||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Date;
|
use Symfony\Component\Validator\Constraints\Date;
|
||||||
|
|
||||||
class Logger
|
class Logger
|
||||||
{
|
{
|
||||||
|
public static function addLog($type = 'default', $what = "")
|
||||||
static function addLog($type = 'default', $what = "")
|
|
||||||
{
|
{
|
||||||
$file = LOG_PATH . DIRECTORY_SEPARATOR . 'app.' . $type . '.log';
|
$file = LOG_PATH . DIRECTORY_SEPARATOR . 'app.' . $type . '.log';
|
||||||
$browser = new Browser();
|
$browser = new Browser();
|
||||||
|
@ -41,5 +39,4 @@ class Logger
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
namespace MVC\Classe;
|
namespace MVC\Classe;
|
||||||
|
|
||||||
class Modele{
|
class Modele
|
||||||
|
{
|
||||||
public $page;
|
public $page;
|
||||||
|
|
||||||
public function __construct($base_param){
|
public function __construct($base_param)
|
||||||
|
{
|
||||||
if (file_exists(MODELS_PATH.DIRECTORY_SEPARATOR.$base_param['name'].'.model')) {
|
if (file_exists(MODELS_PATH.DIRECTORY_SEPARATOR.$base_param['name'].'.model')) {
|
||||||
$fichier = file(MODELS_PATH.DIRECTORY_SEPARATOR.$base_param['name'].'.model');
|
$fichier = file(MODELS_PATH.DIRECTORY_SEPARATOR.$base_param['name'].'.model');
|
||||||
foreach ($fichier as $ligne_num => $ligne) {
|
foreach ($fichier as $ligne_num => $ligne) {
|
||||||
|
@ -28,7 +28,6 @@ class Modele{
|
||||||
}
|
}
|
||||||
$this->page[$matches[1]] = $matches[2];
|
$this->page[$matches[1]] = $matches[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$this->page['url_params'] = $base_param['params'];
|
$this->page['url_params'] = $base_param['params'];
|
||||||
} else {
|
} else {
|
||||||
|
@ -37,5 +36,4 @@ class Modele{
|
||||||
$this->page['params'] = $base_param['params'];
|
$this->page['params'] = $base_param['params'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,14 @@
|
||||||
|
|
||||||
namespace MVC\Classe;
|
namespace MVC\Classe;
|
||||||
|
|
||||||
class Modular{
|
class Modular
|
||||||
|
{
|
||||||
private $app = "";
|
private $app = "";
|
||||||
private $subapp_dir = "";
|
private $subapp_dir = "";
|
||||||
private $subfile = "index.php";
|
private $subfile = "index.php";
|
||||||
|
|
||||||
public function __construct($appName,$type = 'symfony',$options = array()){
|
public function __construct($appName, $type = 'symfony', $options = array())
|
||||||
|
{
|
||||||
|
|
||||||
//Dumper::dump($options);die();
|
//Dumper::dump($options);die();
|
||||||
|
|
||||||
|
@ -82,11 +83,13 @@ class Modular{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAppName(){
|
public function getAppName()
|
||||||
|
{
|
||||||
return $this->app;
|
return $this->app;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function load($type = "symfony"){
|
public function load($type = "symfony")
|
||||||
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case "symfony":
|
case "symfony":
|
||||||
require MODULES_PATH . DIRECTORY_SEPARATOR . $this->getAppName() . DIRECTORY_SEPARATOR . "public" . DIRECTORY_SEPARATOR . "index.php";
|
require MODULES_PATH . DIRECTORY_SEPARATOR . $this->getAppName() . DIRECTORY_SEPARATOR . "public" . DIRECTORY_SEPARATOR . "index.php";
|
||||||
|
|
|
@ -2,28 +2,29 @@
|
||||||
|
|
||||||
namespace MVC\Classe;
|
namespace MVC\Classe;
|
||||||
|
|
||||||
class ModularRegister{
|
class ModularRegister
|
||||||
|
{
|
||||||
public $registry = array();
|
public $registry = array();
|
||||||
public $index = array();
|
public $index = array();
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct()
|
||||||
|
{
|
||||||
$fichier = file(MODULES_PATH . DIRECTORY_SEPARATOR . "setup" . DIRECTORY_SEPARATOR ."registre.model");
|
$fichier = file(MODULES_PATH . DIRECTORY_SEPARATOR . "setup" . DIRECTORY_SEPARATOR ."registre.model");
|
||||||
foreach ($fichier as $ligne_num => $ligne) {
|
foreach ($fichier as $ligne_num => $ligne) {
|
||||||
if (preg_match("#([ ]*[a-zA-Z0-9-_+éèàùïîç]*)[ ]*[:][ ]*([0-9a-zA-Z-_+ 'éèàùïîç.]*[ ]*)#", $ligne, $matches)) {
|
if (preg_match("#([ ]*[a-zA-Z0-9-_+éèàùïîç]*)[ ]*[:][ ]*([0-9a-zA-Z-_+ 'éèàùïîç.]*[ ]*)#", $ligne, $matches)) {
|
||||||
|
|
||||||
$this->registry[$matches[1]] = $matches[2];
|
$this->registry[$matches[1]] = $matches[2];
|
||||||
$this->index[] = $matches[1];
|
$this->index[] = $matches[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRegistre(){
|
public function getRegistre()
|
||||||
|
{
|
||||||
return $this->registry;
|
return $this->registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIndex(){
|
public function getIndex()
|
||||||
|
{
|
||||||
return $this->index;
|
return $this->index;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,64 +3,62 @@
|
||||||
|
|
||||||
namespace MVC\Classe;
|
namespace MVC\Classe;
|
||||||
|
|
||||||
|
|
||||||
class Session
|
class Session
|
||||||
{
|
{
|
||||||
|
public static function start()
|
||||||
static public function start()
|
|
||||||
{
|
{
|
||||||
session_start();
|
session_start();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
static public function destroy()
|
public static function destroy()
|
||||||
{
|
{
|
||||||
session_destroy();
|
session_destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function setUserProfile($userProfile)
|
public static function setUserProfile($userProfile)
|
||||||
{
|
{
|
||||||
$_SESSION['userProfile'] = $userProfile;
|
$_SESSION['userProfile'] = $userProfile;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
static public function setId($id)
|
public static function setId($id)
|
||||||
{
|
{
|
||||||
$_SESSION['id'] = $id;
|
$_SESSION['id'] = $id;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
static public function setUserName($username)
|
public static function setUserName($username)
|
||||||
{
|
{
|
||||||
$_SESSION['username'] = $username;
|
$_SESSION['username'] = $username;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function setToken($token)
|
public static function setToken($token)
|
||||||
{
|
{
|
||||||
$_SESSION['userToken'] = $token;
|
$_SESSION['userToken'] = $token;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function setStorage($hybriauthStorage)
|
public static function setStorage($hybriauthStorage)
|
||||||
{
|
{
|
||||||
$_SESSION['storage'] = $hybriauthStorage;
|
$_SESSION['storage'] = $hybriauthStorage;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
static public function getStorage()
|
public static function getStorage()
|
||||||
{
|
{
|
||||||
return $_SESSION['storage'] ;
|
return $_SESSION['storage'] ;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function setHybridAuth($hybriauth)
|
public static function setHybridAuth($hybriauth)
|
||||||
{
|
{
|
||||||
$_SESSION['auth'] = $hybriauth;
|
$_SESSION['auth'] = $hybriauth;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
static public function getHybridAuth()
|
public static function getHybridAuth()
|
||||||
{
|
{
|
||||||
return $_SESSION['auth'] ;
|
return $_SESSION['auth'] ;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function isRegistered()
|
public static function isRegistered()
|
||||||
{
|
{
|
||||||
if (isset($_SESSION['userProfile'])) {
|
if (isset($_SESSION['userProfile'])) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -69,7 +67,7 @@ class Session
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function redirectIfNotRegistered()
|
public static function redirectIfNotRegistered()
|
||||||
{
|
{
|
||||||
if (isset($_SESSION['userProfile'])) {
|
if (isset($_SESSION['userProfile'])) {
|
||||||
return ;
|
return ;
|
||||||
|
@ -78,5 +76,4 @@ class Session
|
||||||
die('Ooops, something was wrong...');
|
die('Ooops, something was wrong...');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,9 +2,10 @@
|
||||||
|
|
||||||
namespace MVC\Classe;
|
namespace MVC\Classe;
|
||||||
|
|
||||||
class Tri{
|
class Tri
|
||||||
|
{
|
||||||
public static function cmp($a,$b){
|
public static function cmp($a, $b)
|
||||||
|
{
|
||||||
if ($a == $b) {
|
if ($a == $b) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,6 @@ class Url
|
||||||
$page['control'] = true;
|
$page['control'] = true;
|
||||||
($urlParts[1] == 'index' || $urlParts[1] == '') ? $page['name']='index' : $page['name']=$urlParts[1];
|
($urlParts[1] == 'index' || $urlParts[1] == '') ? $page['name']='index' : $page['name']=$urlParts[1];
|
||||||
unset($urlParts[1]);
|
unset($urlParts[1]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//vérification du nombre de parametres:
|
//vérification du nombre de parametres:
|
||||||
|
@ -132,10 +131,9 @@ class Url
|
||||||
}
|
}
|
||||||
$this->page = $page;
|
$this->page = $page;
|
||||||
$this->pageFile = $pageFile;
|
$this->pageFile = $pageFile;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function link_rewrite($isControlPatern, $page, $params = array())
|
public static function link_rewrite($isControlPatern, $page, $params = array())
|
||||||
{
|
{
|
||||||
if ($isControlPatern) {
|
if ($isControlPatern) {
|
||||||
return self::controlLink_rewrite($page, $params);
|
return self::controlLink_rewrite($page, $params);
|
||||||
|
@ -144,7 +142,7 @@ class Url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function module_link_rewrite($page, $params = array())
|
public static function module_link_rewrite($page, $params = array())
|
||||||
{
|
{
|
||||||
$stringParams = '';
|
$stringParams = '';
|
||||||
foreach ($params as $values) {
|
foreach ($params as $values) {
|
||||||
|
@ -153,17 +151,16 @@ class Url
|
||||||
return '/' . $page . $stringParams;
|
return '/' . $page . $stringParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
static private function link_rewrite_slashParam($page, $params = array())
|
private static function link_rewrite_slashParam($page, $params = array())
|
||||||
{
|
{
|
||||||
$stringParams = '';
|
$stringParams = '';
|
||||||
foreach ($params as $key => $values) {
|
foreach ($params as $key => $values) {
|
||||||
$stringParams .= "/" . $key . "/" . $values;
|
$stringParams .= "/" . $key . "/" . $values;
|
||||||
}
|
}
|
||||||
return '/' . $page . $stringParams;
|
return '/' . $page . $stringParams;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static private function controlLink_rewrite($page, $params = array())
|
private static function controlLink_rewrite($page, $params = array())
|
||||||
{
|
{
|
||||||
$stringParams = '';
|
$stringParams = '';
|
||||||
foreach ($params as $key => $values) {
|
foreach ($params as $key => $values) {
|
||||||
|
@ -172,7 +169,7 @@ class Url
|
||||||
return '/' . 'control' . '/' . $page . $stringParams;
|
return '/' . 'control' . '/' . $page . $stringParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function absolute_link_rewrite($isControlPatern, $page, $params = array())
|
public static function absolute_link_rewrite($isControlPatern, $page, $params = array())
|
||||||
{
|
{
|
||||||
$url = $_SERVER['HTTP_HOST'];
|
$url = $_SERVER['HTTP_HOST'];
|
||||||
if ($isControlPatern) {
|
if ($isControlPatern) {
|
||||||
|
@ -187,7 +184,5 @@ class Url
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($scheme . "://" . $url . $uri);
|
return ($scheme . "://" . $url . $uri);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
namespace MVC\Classe;
|
namespace MVC\Classe;
|
||||||
|
|
||||||
class Vue{
|
class Vue
|
||||||
|
{
|
||||||
public $ecran;
|
public $ecran;
|
||||||
public $block_body;
|
public $block_body;
|
||||||
|
|
||||||
public function __construct($application){
|
public function __construct($application)
|
||||||
|
{
|
||||||
$templateData = array();
|
$templateData = array();
|
||||||
extract($application->modele->page);
|
extract($application->modele->page);
|
||||||
|
|
||||||
|
@ -34,12 +34,9 @@ class Vue{
|
||||||
$templateData[$key] = $value;
|
$templateData[$key] = $value;
|
||||||
}
|
}
|
||||||
echo $renderer->render($name, $templateData);
|
echo $renderer->render($name, $templateData);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
include CONTROLLER_PATH . DIRECTORY_SEPARATOR . $name . '.php';
|
include CONTROLLER_PATH . DIRECTORY_SEPARATOR . $name . '.php';
|
||||||
}
|
}
|
||||||
$this->ecran = ob_get_clean();
|
$this->ecran = ob_get_clean();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,11 @@
|
||||||
|
|
||||||
namespace MVC\Classe;
|
namespace MVC\Classe;
|
||||||
|
|
||||||
|
|
||||||
class VueVide
|
class VueVide
|
||||||
{
|
{
|
||||||
|
|
||||||
public $ecran;
|
public $ecran;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@ class DefaultAction extends Action
|
||||||
|
|
||||||
public function makeHttp11($data)
|
public function makeHttp11($data)
|
||||||
{
|
{
|
||||||
|
|
||||||
$data = array('myval' => 25);
|
$data = array('myval' => 25);
|
||||||
//Dumper::dump($data);
|
//Dumper::dump($data);
|
||||||
\MVC\Classe\Logger::addLog('action', 'http11 make request');
|
\MVC\Classe\Logger::addLog('action', 'http11 make request');
|
||||||
|
|
|
@ -17,6 +17,5 @@ class FooConduit extends Conduit
|
||||||
{
|
{
|
||||||
echo "load of foo";
|
echo "load of foo";
|
||||||
return $this->render('foo', array('page_title' => 'Foo', 'description' => 'FooConduit', 'id' => $this->id));
|
return $this->render('foo', array('page_title' => 'Foo', 'description' => 'FooConduit', 'id' => $this->id));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,5 +11,4 @@ class IndexConduit extends Conduit
|
||||||
echo "IndexControlleur";
|
echo "IndexControlleur";
|
||||||
return $this->render('index', array("templating_a"=>'blade',"templating_b"=>'twig',"templating_c"=>'edge'));
|
return $this->render('index', array("templating_a"=>'blade',"templating_b"=>'twig',"templating_c"=>'edge'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -4,12 +4,13 @@ namespace MVC\Command;
|
||||||
|
|
||||||
class Cache
|
class Cache
|
||||||
{
|
{
|
||||||
|
public static function help()
|
||||||
static public function help(){
|
{
|
||||||
print "explaination of the command\n\n";
|
print "explaination of the command\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function clear(){
|
public static function clear()
|
||||||
|
{
|
||||||
$git_cache_rm = system('rm -f '.VIEW_PATH.'/cache/*', $git_cache_rm_retval);
|
$git_cache_rm = system('rm -f '.VIEW_PATH.'/cache/*', $git_cache_rm_retval);
|
||||||
print $git_cache_rm_retval;
|
print $git_cache_rm_retval;
|
||||||
$git_logs_rm = system('rm -f '.LOG_PATH.'/*', $git_logs_rm_retval);
|
$git_logs_rm = system('rm -f '.LOG_PATH.'/*', $git_logs_rm_retval);
|
||||||
|
@ -18,10 +19,10 @@ class Cache
|
||||||
print "logs && cache cleared ! \n\n";
|
print "logs && cache cleared ! \n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function stabilize(){
|
public static function stabilize()
|
||||||
|
{
|
||||||
$git_cache_rm = system('rm -f '.VIEW_PATH.'/cache/*', $git_cache_rm_retval);
|
$git_cache_rm = system('rm -f '.VIEW_PATH.'/cache/*', $git_cache_rm_retval);
|
||||||
print $git_cache_rm_retval;
|
print $git_cache_rm_retval;
|
||||||
print "cache stabilized ! \n\n";
|
print "cache stabilized ! \n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -4,11 +4,13 @@ namespace MVC\Command;
|
||||||
|
|
||||||
class Module
|
class Module
|
||||||
{
|
{
|
||||||
static public function help(){
|
public static function help()
|
||||||
|
{
|
||||||
print "explaination of the command\n\n";
|
print "explaination of the command\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function add(){
|
public static function add()
|
||||||
|
{
|
||||||
print "adding module...\n\n";
|
print "adding module...\n\n";
|
||||||
print "Quel est le module a ajouter ?\n1.Symfony\n2.Wordpress\n3.Prestashop\n4.PhpList\n5.Wanewsletter\n6.PHPmyNewletter\n>";
|
print "Quel est le module a ajouter ?\n1.Symfony\n2.Wordpress\n3.Prestashop\n4.PhpList\n5.Wanewsletter\n6.PHPmyNewletter\n>";
|
||||||
$module = trim(fgets(STDIN));
|
$module = trim(fgets(STDIN));
|
||||||
|
@ -71,7 +73,8 @@ class Module
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function remove(){
|
public static function remove()
|
||||||
|
{
|
||||||
print "removing module...\n\n";
|
print "removing module...\n\n";
|
||||||
print "Quel est le module a supprimer?\n1.Symfony\n2.Wordpress\n3.Prestashop\n4.PhpList\n5.Wanewsletter\n6.PHPmyNewletter\n>";
|
print "Quel est le module a supprimer?\n1.Symfony\n2.Wordpress\n3.Prestashop\n4.PhpList\n5.Wanewsletter\n6.PHPmyNewletter\n>";
|
||||||
$module = trim(fgets(STDIN));
|
$module = trim(fgets(STDIN));
|
||||||
|
@ -104,8 +107,8 @@ class Module
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static private function addSymfony($name = 'symfony'){
|
private static function addSymfony($name = 'symfony')
|
||||||
|
{
|
||||||
$git_clone = shell_exec('cd '.MODULES_PATH.' && composer create-project symfony/website-skeleton '.$name);
|
$git_clone = shell_exec('cd '.MODULES_PATH.' && composer create-project symfony/website-skeleton '.$name);
|
||||||
print $git_clone;
|
print $git_clone;
|
||||||
$git_chmod = shell_exec('sudo chmod 775 '.MODULES_PATH.'/'.$name.' -R');
|
$git_chmod = shell_exec('sudo chmod 775 '.MODULES_PATH.'/'.$name.' -R');
|
||||||
|
@ -141,10 +144,9 @@ class Module
|
||||||
."\n'.$name.' : Application permettant d'intégrer un module avec symfony"
|
."\n'.$name.' : Application permettant d'intégrer un module avec symfony"
|
||||||
."\n "
|
."\n "
|
||||||
."\n et de créer la base de données!\n";
|
."\n et de créer la base de données!\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
static public function removeSymfony($name = 'symfony'){
|
public static function removeSymfony($name = 'symfony')
|
||||||
|
{
|
||||||
$git_clone = system('rm -Rf '.MODULES_PATH.'/'.$name, $git_clone_retval);
|
$git_clone = system('rm -Rf '.MODULES_PATH.'/'.$name, $git_clone_retval);
|
||||||
print $git_clone_retval;
|
print $git_clone_retval;
|
||||||
$git_ln_1 = system('rm -Rf '.PUBLIC_PATH.'/'.$name, $git_ln_1_retval);
|
$git_ln_1 = system('rm -Rf '.PUBLIC_PATH.'/'.$name, $git_ln_1_retval);
|
||||||
|
@ -157,8 +159,8 @@ class Module
|
||||||
print $git_view_retval;
|
print $git_view_retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function addWordpress($version = '5.4'){
|
public static function addWordpress($version = '5.4')
|
||||||
|
{
|
||||||
$git_clone = shell_exec('cd '.MODULES_PATH.' && git clone https://github.com/WordPress/WordPress.git wordpress');
|
$git_clone = shell_exec('cd '.MODULES_PATH.' && git clone https://github.com/WordPress/WordPress.git wordpress');
|
||||||
print $git_clone;
|
print $git_clone;
|
||||||
$git_fetch = shell_exec('cd '.MODULES_PATH.'/wordpress && git fetch --all --tags');
|
$git_fetch = shell_exec('cd '.MODULES_PATH.'/wordpress && git fetch --all --tags');
|
||||||
|
@ -194,10 +196,9 @@ class Module
|
||||||
."\nwordpress : Application permettant de générer un blog wordpress"
|
."\nwordpress : Application permettant de générer un blog wordpress"
|
||||||
."\n "
|
."\n "
|
||||||
."\n et de créer la base de données!\n";
|
."\n et de créer la base de données!\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
static public function removeWordpress(){
|
public static function removeWordpress()
|
||||||
|
{
|
||||||
$git_clone = system('sudo rm -Rf '.MODULES_PATH.'/wordpress', $git_clone_retval);
|
$git_clone = system('sudo rm -Rf '.MODULES_PATH.'/wordpress', $git_clone_retval);
|
||||||
print $git_clone_retval;
|
print $git_clone_retval;
|
||||||
$git_ln_1 = system('rm -Rf '.PUBLIC_PATH.'/wordpress', $git_ln_1_retval);
|
$git_ln_1 = system('rm -Rf '.PUBLIC_PATH.'/wordpress', $git_ln_1_retval);
|
||||||
|
@ -210,8 +211,8 @@ class Module
|
||||||
print $git_view_retval;
|
print $git_view_retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function addPrestashop($version = '1.7.5.0'){
|
public static function addPrestashop($version = '1.7.5.0')
|
||||||
|
{
|
||||||
$git_clone = shell_exec('cd '.MODULES_PATH.' && git clone https://github.com/PrestaShop/PrestaShop.git prestashop');
|
$git_clone = shell_exec('cd '.MODULES_PATH.' && git clone https://github.com/PrestaShop/PrestaShop.git prestashop');
|
||||||
print $git_clone;
|
print $git_clone;
|
||||||
$git_fetch = shell_exec('cd '.MODULES_PATH.'/prestashop && git fetch --all --tags');
|
$git_fetch = shell_exec('cd '.MODULES_PATH.'/prestashop && git fetch --all --tags');
|
||||||
|
@ -249,8 +250,8 @@ class Module
|
||||||
."\n "
|
."\n "
|
||||||
."\n et de créer la base de données!\n";
|
."\n et de créer la base de données!\n";
|
||||||
}
|
}
|
||||||
static public function removePrestashop(){
|
public static function removePrestashop()
|
||||||
|
{
|
||||||
$git_clone = system('rm -Rf '.MODULES_PATH.'/prestashop', $git_clone_retval);
|
$git_clone = system('rm -Rf '.MODULES_PATH.'/prestashop', $git_clone_retval);
|
||||||
print $git_clone_retval;
|
print $git_clone_retval;
|
||||||
$git_ln_1 = system('rm -Rf '.PUBLIC_PATH.'/prestashop', $git_ln_1_retval);
|
$git_ln_1 = system('rm -Rf '.PUBLIC_PATH.'/prestashop', $git_ln_1_retval);
|
||||||
|
@ -263,7 +264,8 @@ class Module
|
||||||
print $git_view_retval;
|
print $git_view_retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function addPhplist($version = '3.5.2'){
|
public static function addPhplist($version = '3.5.2')
|
||||||
|
{
|
||||||
|
|
||||||
/*$git_clone = shell_exec('cd '.MODULES_PATH.' && git clone https://github.com/phpList/phplist3.git phplist');
|
/*$git_clone = shell_exec('cd '.MODULES_PATH.' && git clone https://github.com/phpList/phplist3.git phplist');
|
||||||
print $git_clone;
|
print $git_clone;
|
||||||
|
@ -347,8 +349,8 @@ class Module
|
||||||
."\n "
|
."\n "
|
||||||
."\n et de créer la base de données!\n";
|
."\n et de créer la base de données!\n";
|
||||||
}
|
}
|
||||||
static public function removePhplist(){
|
public static function removePhplist()
|
||||||
|
{
|
||||||
$git_clone = system('rm -Rf '.MODULES_PATH.'/phplist', $git_clone_retval);
|
$git_clone = system('rm -Rf '.MODULES_PATH.'/phplist', $git_clone_retval);
|
||||||
print $git_clone_retval;
|
print $git_clone_retval;
|
||||||
$git_ln_1 = system('rm -Rf '.PUBLIC_PATH.'/phplist', $git_ln_1_retval);
|
$git_ln_1 = system('rm -Rf '.PUBLIC_PATH.'/phplist', $git_ln_1_retval);
|
||||||
|
@ -362,8 +364,8 @@ class Module
|
||||||
$git_view = system('rm -f '.VIEW_PATH.'/view/phplist.blade.php', $git_view_retval);
|
$git_view = system('rm -f '.VIEW_PATH.'/view/phplist.blade.php', $git_view_retval);
|
||||||
print $git_view_retval;
|
print $git_view_retval;
|
||||||
}
|
}
|
||||||
static public function addWanewsletter($version = 'release-3.0.1'){
|
public static function addWanewsletter($version = 'release-3.0.1')
|
||||||
|
{
|
||||||
$git_clone = shell_exec('cd '.MODULES_PATH.' && git clone https://github.com/wascripts/wanewsletter.git wanewsletter');
|
$git_clone = shell_exec('cd '.MODULES_PATH.' && git clone https://github.com/wascripts/wanewsletter.git wanewsletter');
|
||||||
print $git_clone;
|
print $git_clone;
|
||||||
$git_fetch = shell_exec('cd '.MODULES_PATH.'/wanewsletter && git fetch --all --tags');
|
$git_fetch = shell_exec('cd '.MODULES_PATH.'/wanewsletter && git fetch --all --tags');
|
||||||
|
@ -437,8 +439,8 @@ class Module
|
||||||
."\n "
|
."\n "
|
||||||
."\n et de créer la base de données!\n";
|
."\n et de créer la base de données!\n";
|
||||||
}
|
}
|
||||||
static public function removeWanewsletter(){
|
public static function removeWanewsletter()
|
||||||
|
{
|
||||||
$git_clone = system('rm -Rf '.MODULES_PATH.'/wanewsletter', $git_clone_retval);
|
$git_clone = system('rm -Rf '.MODULES_PATH.'/wanewsletter', $git_clone_retval);
|
||||||
print $git_clone_retval;
|
print $git_clone_retval;
|
||||||
$git_ln_1 = system('rm -Rf '.PUBLIC_PATH.'/wanewsletter', $git_ln_1_retval);
|
$git_ln_1 = system('rm -Rf '.PUBLIC_PATH.'/wanewsletter', $git_ln_1_retval);
|
||||||
|
@ -450,8 +452,8 @@ class Module
|
||||||
$git_view = system('rm -f '.VIEW_PATH.'/view/wanewsletter.blade.php', $git_view_retval);
|
$git_view = system('rm -f '.VIEW_PATH.'/view/wanewsletter.blade.php', $git_view_retval);
|
||||||
print $git_view_retval;
|
print $git_view_retval;
|
||||||
}
|
}
|
||||||
static public function addPHPMyNewsletter($version = 'v2.0.5'){
|
public static function addPHPMyNewsletter($version = 'v2.0.5')
|
||||||
|
{
|
||||||
$git_clone = shell_exec('cd '.MODULES_PATH.' && git clone https://github.com/Arnaud69/phpmynewsletter-2.0.git phpmynewsletter');
|
$git_clone = shell_exec('cd '.MODULES_PATH.' && git clone https://github.com/Arnaud69/phpmynewsletter-2.0.git phpmynewsletter');
|
||||||
print $git_clone;
|
print $git_clone;
|
||||||
$git_fetch = shell_exec('cd '.MODULES_PATH.'/phpmynewsletter && git fetch --all --tags');
|
$git_fetch = shell_exec('cd '.MODULES_PATH.'/phpmynewsletter && git fetch --all --tags');
|
||||||
|
@ -525,8 +527,8 @@ class Module
|
||||||
."\n "
|
."\n "
|
||||||
."\n et de créer la base de données!\n";
|
."\n et de créer la base de données!\n";
|
||||||
}
|
}
|
||||||
static public function removePHPMyNewsletter(){
|
public static function removePHPMyNewsletter()
|
||||||
|
{
|
||||||
$git_clone = system('rm -Rf '.MODULES_PATH.'/phpmynewsletter', $git_clone_retval);
|
$git_clone = system('rm -Rf '.MODULES_PATH.'/phpmynewsletter', $git_clone_retval);
|
||||||
print $git_clone_retval;
|
print $git_clone_retval;
|
||||||
$git_ln_1 = system('rm -Rf '.PUBLIC_PATH.'/phpmynewsletter', $git_ln_1_retval);
|
$git_ln_1 = system('rm -Rf '.PUBLIC_PATH.'/phpmynewsletter', $git_ln_1_retval);
|
||||||
|
|
|
@ -4,12 +4,13 @@ namespace MVC\Command;
|
||||||
|
|
||||||
class Page
|
class Page
|
||||||
{
|
{
|
||||||
|
public static function help()
|
||||||
static public function help(){
|
{
|
||||||
print "explaination of the command\n\n";
|
print "explaination of the command\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function add(){
|
public static function add()
|
||||||
|
{
|
||||||
print "adding page...\n\n";
|
print "adding page...\n\n";
|
||||||
print "Quel est le nom de la page a ajouter? ";
|
print "Quel est le nom de la page a ajouter? ";
|
||||||
$page = trim(fgets(STDIN));
|
$page = trim(fgets(STDIN));
|
||||||
|
@ -31,7 +32,8 @@ class Page
|
||||||
print $git_view;
|
print $git_view;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function remove(){
|
public static function remove()
|
||||||
|
{
|
||||||
print "removing page...\n\n";
|
print "removing page...\n\n";
|
||||||
print "Quel est le nom de la page a supprimer? ";
|
print "Quel est le nom de la page a supprimer? ";
|
||||||
$handle = fopen("php://stdin", "r");
|
$handle = fopen("php://stdin", "r");
|
||||||
|
@ -43,5 +45,4 @@ class Page
|
||||||
$git_view = system('rm -f '.VIEW_PATH.'/view/'.$page.'.blade.php', $git_view_retval);
|
$git_view = system('rm -f '.VIEW_PATH.'/view/'.$page.'.blade.php', $git_view_retval);
|
||||||
print $git_view_retval;
|
print $git_view_retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -4,14 +4,14 @@ namespace MVC\Command;
|
||||||
|
|
||||||
class Symfony
|
class Symfony
|
||||||
{
|
{
|
||||||
|
public static function help()
|
||||||
static public function help(){
|
{
|
||||||
print "explaination of the command\n\n";
|
print "explaination of the command\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function stabilize(){
|
public static function stabilize()
|
||||||
|
{
|
||||||
print "stabilize symfony module...\n\n";
|
print "stabilize symfony module...\n\n";
|
||||||
$symfony_module = shell_exec('sudo cp '.CONSOLE_PATH.'/skel/symfony '.VENDOR_PATH.' -Rf');
|
$symfony_module = shell_exec('sudo cp '.CONSOLE_PATH.'/skel/symfony '.VENDOR_PATH.' -Rf');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
|
|
|
@ -7,32 +7,35 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class OnAuthenticationFailureEvent extends Event
|
||||||
class OnAuthenticationFailureEvent extends Event {
|
{
|
||||||
|
|
||||||
const NAME = "session_auth.event.on_authentication_failure";
|
const NAME = "session_auth.event.on_authentication_failure";
|
||||||
|
|
||||||
public function __construct(Request $request, AuthenticationException $exception) {
|
public function __construct(Request $request, AuthenticationException $exception)
|
||||||
|
{
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
$this->exception = $exception;
|
$this->exception = $exception;
|
||||||
$this->response = new Response($exception->getMessage(), Response::HTTP_FORBIDDEN);
|
$this->response = new Response($exception->getMessage(), Response::HTTP_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRequest() {
|
public function getRequest()
|
||||||
|
{
|
||||||
return $this->request;
|
return $this->request;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getException() {
|
public function getException()
|
||||||
|
{
|
||||||
return $this->exception;
|
return $this->exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getResponse() {
|
public function getResponse()
|
||||||
|
{
|
||||||
return $this->response;
|
return $this->response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setResponse($response) {
|
public function setResponse($response)
|
||||||
|
{
|
||||||
$this->response = $response;
|
$this->response = $response;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,27 +5,29 @@ use Symfony\Component\EventDispatcher\Event;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
class OnAuthenticationSuccessEvent extends Event
|
||||||
class OnAuthenticationSuccessEvent extends Event {
|
{
|
||||||
|
|
||||||
const NAME = "session_auth.event.on_authentication_success";
|
const NAME = "session_auth.event.on_authentication_success";
|
||||||
|
|
||||||
public function __construct(Request $request, TokenInterface $token, $providerKey) {
|
public function __construct(Request $request, TokenInterface $token, $providerKey)
|
||||||
|
{
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
$this->token = $token;
|
$this->token = $token;
|
||||||
$this->providerKey = $providerKey;
|
$this->providerKey = $providerKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRequest() {
|
public function getRequest()
|
||||||
|
{
|
||||||
return $this->request;
|
return $this->request;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getToken() {
|
public function getToken()
|
||||||
|
{
|
||||||
return $this->exception;
|
return $this->exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getProviderKey() {
|
public function getProviderKey()
|
||||||
|
{
|
||||||
return $this->providerKey;
|
return $this->providerKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,8 @@ class AccessDeniedHandler implements AccessDeniedHandlerInterface
|
||||||
public function handle(Request $request, AccessDeniedException $accessDeniedException)
|
public function handle(Request $request, AccessDeniedException $accessDeniedException)
|
||||||
{
|
{
|
||||||
$content = $this->twig->render(
|
$content = $this->twig->render(
|
||||||
'default/unauthorized.html.twig', array()
|
'default/unauthorized.html.twig',
|
||||||
|
array()
|
||||||
);
|
);
|
||||||
$response = new Response($content, Response::HTTP_FORBIDDEN);
|
$response = new Response($content, Response::HTTP_FORBIDDEN);
|
||||||
return $response;
|
return $response;
|
||||||
|
|
|
@ -4,8 +4,8 @@ namespace App\Security;
|
||||||
|
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
|
|
||||||
class AuthUser implements UserInterface{
|
class AuthUser implements UserInterface
|
||||||
|
{
|
||||||
private $id;
|
private $id;
|
||||||
private $username;
|
private $username;
|
||||||
private $status;
|
private $status;
|
||||||
|
@ -43,7 +43,8 @@ class AuthUser implements UserInterface{
|
||||||
return $this->username;
|
return $this->username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUser(){
|
public function getUser()
|
||||||
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,5 +94,4 @@ class AuthUser implements UserInterface{
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,7 +9,6 @@ use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||||
|
|
||||||
|
|
||||||
class AuthUserProvider implements UserProviderInterface
|
class AuthUserProvider implements UserProviderInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -24,7 +23,8 @@ class AuthUserProvider implements UserProviderInterface
|
||||||
*
|
*
|
||||||
* @throws UsernameNotFoundException if the user is not found
|
* @throws UsernameNotFoundException if the user is not found
|
||||||
*/
|
*/
|
||||||
public function loadUserByUsername($username) {
|
public function loadUserByUsername($username)
|
||||||
|
{
|
||||||
$entity_user = $this->entity_user;
|
$entity_user = $this->entity_user;
|
||||||
|
|
||||||
return $this->authService->getUser($username);
|
return $this->authService->getUser($username);
|
||||||
|
@ -49,13 +49,15 @@ class AuthUserProvider implements UserProviderInterface
|
||||||
* @return UserInterface
|
* @return UserInterface
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function refreshUser(UserInterface $user) {
|
public function refreshUser(UserInterface $user)
|
||||||
|
{
|
||||||
$user = $this->_ctrlInstanceUser($user);
|
$user = $this->_ctrlInstanceUser($user);
|
||||||
|
|
||||||
return $this->loadUserByUsername($user->getUsername());
|
return $this->loadUserByUsername($user->getUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _ctrlInstanceUser(UserInterface $user) {
|
private function _ctrlInstanceUser(UserInterface $user)
|
||||||
|
{
|
||||||
$entity_user = $this->entity_user;
|
$entity_user = $this->entity_user;
|
||||||
|
|
||||||
if (!$user instanceof $entity_user) {
|
if (!$user instanceof $entity_user) {
|
||||||
|
|
|
@ -17,7 +17,6 @@ use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||||
use Symfony\Component\Security\Guard\AbstractGuardAuthenticator;
|
use Symfony\Component\Security\Guard\AbstractGuardAuthenticator;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
|
|
||||||
|
|
||||||
class SessionAuthenticator extends AbstractGuardAuthenticator
|
class SessionAuthenticator extends AbstractGuardAuthenticator
|
||||||
{
|
{
|
||||||
public $router;
|
public $router;
|
||||||
|
@ -104,12 +103,11 @@ class SessionAuthenticator extends AbstractGuardAuthenticator
|
||||||
// $url = $this->router->generate('unauthorized');
|
// $url = $this->router->generate('unauthorized');
|
||||||
// return new RedirectResponse($url);
|
// return new RedirectResponse($url);
|
||||||
$content = $this->twig->render(
|
$content = $this->twig->render(
|
||||||
'default/unauthorized.html.twig', array()
|
'default/unauthorized.html.twig',
|
||||||
|
array()
|
||||||
);
|
);
|
||||||
$response = new Response($content, Response::HTTP_FORBIDDEN);
|
$response = new Response($content, Response::HTTP_FORBIDDEN);
|
||||||
return $response;
|
return $response;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,13 +126,11 @@ class SessionAuthenticator extends AbstractGuardAuthenticator
|
||||||
// return new RedirectResponse($url);
|
// return new RedirectResponse($url);
|
||||||
|
|
||||||
$content = $this->twig->render(
|
$content = $this->twig->render(
|
||||||
'default/unauthorized.html.twig', array()
|
'default/unauthorized.html.twig',
|
||||||
|
array()
|
||||||
);
|
);
|
||||||
$response = new Response($content, Response::HTTP_FORBIDDEN);
|
$response = new Response($content, Response::HTTP_FORBIDDEN);
|
||||||
return $response;
|
return $response;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsRememberMe()
|
public function supportsRememberMe()
|
||||||
|
@ -142,11 +138,11 @@ class SessionAuthenticator extends AbstractGuardAuthenticator
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onLogoutSuccess(Request $request) {
|
public function onLogoutSuccess(Request $request)
|
||||||
|
{
|
||||||
//$homepage = $this->config["homepage"];
|
//$homepage = $this->config["homepage"];
|
||||||
//return \phpCAS::logoutWithRedirectService($this->urlGenerator->generate($homepage, array(), UrlGeneratorInterface::ABSOLUTE_URL));
|
//return \phpCAS::logoutWithRedirectService($this->urlGenerator->generate($homepage, array(), UrlGeneratorInterface::ABSOLUTE_URL));
|
||||||
header('Location: /index.php');
|
header('Location: /index.php');
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -11,12 +11,14 @@ use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||||
*
|
*
|
||||||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
|
||||||
*/
|
*/
|
||||||
class Configuration implements ConfigurationInterface {
|
class Configuration implements ConfigurationInterface
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getConfigTreeBuilder() {
|
public function getConfigTreeBuilder()
|
||||||
|
{
|
||||||
$treeBuilder = new TreeBuilder('session_auth');
|
$treeBuilder = new TreeBuilder('session_auth');
|
||||||
$rootNode = $treeBuilder->getRootNode();
|
$rootNode = $treeBuilder->getRootNode();
|
||||||
$rootNode
|
$rootNode
|
||||||
|
@ -57,8 +59,8 @@ class Configuration implements ConfigurationInterface {
|
||||||
return $treeBuilder;
|
return $treeBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _addCasConfig(ArrayNodeDefinition $node) {
|
private function _addCasConfig(ArrayNodeDefinition $node)
|
||||||
|
{
|
||||||
$node
|
$node
|
||||||
->children()
|
->children()
|
||||||
->arrayNode('cas')->info('A déclarer si authentification pas CAS.')
|
->arrayNode('cas')->info('A déclarer si authentification pas CAS.')
|
||||||
|
@ -85,7 +87,8 @@ class Configuration implements ConfigurationInterface {
|
||||||
->end();
|
->end();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _addRsaConfig(ArrayNodeDefinition $node) {
|
private function _addRsaConfig(ArrayNodeDefinition $node)
|
||||||
|
{
|
||||||
$node
|
$node
|
||||||
->children()
|
->children()
|
||||||
->arrayNode('rsa')->addDefaultsIfNotSet()->info('A déclarer si authentification pas RSA.')
|
->arrayNode('rsa')->addDefaultsIfNotSet()->info('A déclarer si authentification pas RSA.')
|
||||||
|
|
|
@ -14,13 +14,14 @@ use Symfony\Component\DependencyInjection\ChildDefinition;
|
||||||
*
|
*
|
||||||
* @link http://symfony.com/doc/current/cookbook/bundles/extension.html
|
* @link http://symfony.com/doc/current/cookbook/bundles/extension.html
|
||||||
*/
|
*/
|
||||||
class SessionAuthExtension extends Extension {
|
class SessionAuthExtension extends Extension
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function load(array $configs, ContainerBuilder $container) {
|
public function load(array $configs, ContainerBuilder $container)
|
||||||
|
{
|
||||||
$configs[0]['environment'] = $container->getParameter("kernel.environment");
|
$configs[0]['environment'] = $container->getParameter("kernel.environment");
|
||||||
$configuration = new Configuration();
|
$configuration = new Configuration();
|
||||||
$config = $this->processConfiguration($configuration, $configs);
|
$config = $this->processConfiguration($configuration, $configs);
|
||||||
|
@ -75,8 +76,8 @@ class SessionAuthExtension extends Extension {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNamespace() {
|
public function getNamespace()
|
||||||
|
{
|
||||||
return 'http://ac-besancon.fr/schema/dic/' . $this->getAlias();
|
return 'http://ac-besancon.fr/schema/dic/' . $this->getAlias();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,30 +5,34 @@ namespace App\Session\AuthBundle\Events;
|
||||||
use Symfony\Component\EventDispatcher\Event;
|
use Symfony\Component\EventDispatcher\Event;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
|
|
||||||
class CheckCredentialsEvent extends Event {
|
class CheckCredentialsEvent extends Event
|
||||||
|
{
|
||||||
const NAME = "besancon_auth.event.check_credentials";
|
const NAME = "besancon_auth.event.check_credentials";
|
||||||
private $access = true;
|
private $access = true;
|
||||||
|
|
||||||
public function __construct($credentials, UserInterface $user_interface) {
|
public function __construct($credentials, UserInterface $user_interface)
|
||||||
|
{
|
||||||
$this->credentials = $credentials;
|
$this->credentials = $credentials;
|
||||||
$this->user_interface = $user_interface;
|
$this->user_interface = $user_interface;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCredentials() {
|
public function getCredentials()
|
||||||
|
{
|
||||||
return $this->credentials;
|
return $this->credentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUserInterface() {
|
public function getUserInterface()
|
||||||
|
{
|
||||||
return $this->user_interface;
|
return $this->user_interface;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAccess() {
|
public function getAccess()
|
||||||
|
{
|
||||||
return $this->access;
|
return $this->access;
|
||||||
}
|
}
|
||||||
public function setAccess($access) {
|
public function setAccess($access)
|
||||||
|
{
|
||||||
$this->access = $access;
|
$this->access = $access;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,32 +7,35 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class OnAuthenticationFailureEvent extends Event
|
||||||
class OnAuthenticationFailureEvent extends Event {
|
{
|
||||||
|
|
||||||
const NAME = "session_auth.event.on_authentication_failure";
|
const NAME = "session_auth.event.on_authentication_failure";
|
||||||
|
|
||||||
public function __construct(Request $request, AuthenticationException $exception) {
|
public function __construct(Request $request, AuthenticationException $exception)
|
||||||
|
{
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
$this->exception = $exception;
|
$this->exception = $exception;
|
||||||
$this->response = new Response($exception->getMessage(), Response::HTTP_FORBIDDEN);
|
$this->response = new Response($exception->getMessage(), Response::HTTP_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRequest() {
|
public function getRequest()
|
||||||
|
{
|
||||||
return $this->request;
|
return $this->request;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getException() {
|
public function getException()
|
||||||
|
{
|
||||||
return $this->exception;
|
return $this->exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getResponse() {
|
public function getResponse()
|
||||||
|
{
|
||||||
return $this->response;
|
return $this->response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setResponse($response) {
|
public function setResponse($response)
|
||||||
|
{
|
||||||
$this->response = $response;
|
$this->response = $response;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,27 +5,29 @@ use Symfony\Component\EventDispatcher\Event;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
class OnAuthenticationSuccessEvent extends Event
|
||||||
class OnAuthenticationSuccessEvent extends Event {
|
{
|
||||||
|
|
||||||
const NAME = "session_auth.event.on_authentication_success";
|
const NAME = "session_auth.event.on_authentication_success";
|
||||||
|
|
||||||
public function __construct(Request $request, TokenInterface $token, $providerKey) {
|
public function __construct(Request $request, TokenInterface $token, $providerKey)
|
||||||
|
{
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
$this->token = $token;
|
$this->token = $token;
|
||||||
$this->providerKey = $providerKey;
|
$this->providerKey = $providerKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRequest() {
|
public function getRequest()
|
||||||
|
{
|
||||||
return $this->request;
|
return $this->request;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getToken() {
|
public function getToken()
|
||||||
|
{
|
||||||
return $this->exception;
|
return $this->exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getProviderKey() {
|
public function getProviderKey()
|
||||||
|
{
|
||||||
return $this->providerKey;
|
return $this->providerKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,8 @@ namespace App\Session\AuthBundle\Security\Abstracts;
|
||||||
use App\Session\AuthBundle\Utils\Config;
|
use App\Session\AuthBundle\Utils\Config;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
abstract class AuthAbstract {
|
abstract class AuthAbstract
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var App\Besancon\AuthBundle\Security\Interfaces\AttributesInterface $ai Instance de CasAttributes ou RsaAttributes
|
* @var App\Besancon\AuthBundle\Security\Interfaces\AttributesInterface $ai Instance de CasAttributes ou RsaAttributes
|
||||||
|
@ -73,6 +74,4 @@ abstract class AuthAbstract {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
abstract public function getUser($username);
|
abstract public function getUser($username);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,8 @@ namespace App\Session\AuthBundle\Security\Abstracts;
|
||||||
use App\Session\AuthBundle\Utils\Config;
|
use App\Session\AuthBundle\Utils\Config;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class AuthFinal extends AuthAbstract {
|
class AuthFinal extends AuthAbstract
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Intancie le getters en fonction de la configuration
|
* Intancie le getters en fonction de la configuration
|
||||||
|
@ -33,7 +34,8 @@ class AuthFinal extends AuthAbstract {
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
public function setGetterAttributes($config) {
|
public function setGetterAttributes($config)
|
||||||
|
{
|
||||||
$type_auth = Config::getDeclaredType($config);
|
$type_auth = Config::getDeclaredType($config);
|
||||||
//dump('calls');
|
//dump('calls');
|
||||||
$getters = "\App\Session\AuthBundle\Security\Getters\\" . $type_auth . "Attributes";
|
$getters = "\App\Session\AuthBundle\Security\Getters\\" . $type_auth . "Attributes";
|
||||||
|
@ -55,7 +57,8 @@ class AuthFinal extends AuthAbstract {
|
||||||
* @return Symfony\Component\HttpFoundation\Response
|
* @return Symfony\Component\HttpFoundation\Response
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
public function onAuthenticationFailure(\Symfony\Component\Security\Core\Exception\AuthenticationException $exception) {
|
public function onAuthenticationFailure(\Symfony\Component\Security\Core\Exception\AuthenticationException $exception)
|
||||||
|
{
|
||||||
return new Response($exception->getMessage(), Response::HTTP_FORBIDDEN);
|
return new Response($exception->getMessage(), Response::HTTP_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,12 +79,12 @@ class AuthFinal extends AuthAbstract {
|
||||||
* @return \Symfony\Component\Security\Core\User\UserInterface
|
* @return \Symfony\Component\Security\Core\User\UserInterface
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getUser($username) {
|
public function getUser($username)
|
||||||
|
{
|
||||||
$roles_service = $this->getRoles();
|
$roles_service = $this->getRoles();
|
||||||
$roles = (!is_null($roles_service) && is_array($roles_service)) ? $roles_service : array();
|
$roles = (!is_null($roles_service) && is_array($roles_service)) ? $roles_service : array();
|
||||||
$user = new \App\Besancon\AuthBundle\Security\User\AuthUser($username, md5("8sQaz87dPPsdanYakq86f" . $username), $roles);
|
$user = new \App\Besancon\AuthBundle\Security\User\AuthUser($username, md5("8sQaz87dPPsdanYakq86f" . $username), $roles);
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,29 +14,35 @@ namespace App\Session\AuthBundle\Security\Abstracts;
|
||||||
*
|
*
|
||||||
* @author belhadjali
|
* @author belhadjali
|
||||||
*/
|
*/
|
||||||
abstract class GetterAbstract {
|
abstract class GetterAbstract
|
||||||
|
{
|
||||||
public function isACP(){
|
public function isACP()
|
||||||
|
{
|
||||||
return $this->getFrEduFonctAdm() == "ACP";
|
return $this->getFrEduFonctAdm() == "ACP";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isDIR(){
|
public function isDIR()
|
||||||
|
{
|
||||||
return $this->getFrEduFonctAdm() == "DIR";
|
return $this->getFrEduFonctAdm() == "DIR";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isDEC(){
|
public function isDEC()
|
||||||
|
{
|
||||||
return $this->getFrEduFonctAdm() == "DEC";
|
return $this->getFrEduFonctAdm() == "DEC";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isDIR1D(){
|
public function isDIR1D()
|
||||||
|
{
|
||||||
return $this->isDEC();
|
return $this->isDEC();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isIEN1D (){
|
public function isIEN1D()
|
||||||
|
{
|
||||||
return $this->getFrEduFonctAdm() == "IEN1D";
|
return $this->getFrEduFonctAdm() == "IEN1D";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isDIO(){
|
public function isDIO()
|
||||||
|
{
|
||||||
return $this->getFrEduFonctAdm() == "IEN1D";
|
return $this->getFrEduFonctAdm() == "IEN1D";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,10 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
use App\Session\AuthBundle\Utils\Config;
|
use App\Session\AuthBundle\Utils\Config;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
class AuthenticatorFactory {
|
class AuthenticatorFactory
|
||||||
|
{
|
||||||
public static function getAuthenticator(AuthInterface $authService, Array $config, UrlGeneratorInterface $urlGenerator,EventDispatcherInterface $dispatcher) {
|
public static function getAuthenticator(AuthInterface $authService, array $config, UrlGeneratorInterface $urlGenerator, EventDispatcherInterface $dispatcher)
|
||||||
|
{
|
||||||
$type_auth = Config::getDeclaredType($config);
|
$type_auth = Config::getDeclaredType($config);
|
||||||
|
|
||||||
$authenticator_class = "App\Session\AuthBundle\Security\\" . $type_auth . "Authenticator";
|
$authenticator_class = "App\Session\AuthBundle\Security\\" . $type_auth . "Authenticator";
|
||||||
|
@ -23,5 +24,4 @@ class AuthenticatorFactory {
|
||||||
|
|
||||||
return $authenticator;
|
return $authenticator;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,12 +28,13 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
use Symfony\Component\Security\Guard\AuthenticatorInterface;
|
use Symfony\Component\Security\Guard\AuthenticatorInterface;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
class CasAuthenticator extends AbstractFormLoginAuthenticator implements LogoutSuccessHandlerInterface, AuthenticatorInterface {
|
class CasAuthenticator extends AbstractFormLoginAuthenticator implements LogoutSuccessHandlerInterface, AuthenticatorInterface
|
||||||
|
{
|
||||||
private $authService;
|
private $authService;
|
||||||
private $urlGenerator;
|
private $urlGenerator;
|
||||||
|
|
||||||
public function __construct(AuthInterface $authService, Array $config, UrlGeneratorInterface $urlGenerator, EventDispatcherInterface $dispatcher) {
|
public function __construct(AuthInterface $authService, array $config, UrlGeneratorInterface $urlGenerator, EventDispatcherInterface $dispatcher)
|
||||||
|
{
|
||||||
$this->urlGenerator = $urlGenerator;
|
$this->urlGenerator = $urlGenerator;
|
||||||
//Récupérer le service déaclaré authService
|
//Récupérer le service déaclaré authService
|
||||||
$this->authService = $authService;
|
$this->authService = $authService;
|
||||||
|
@ -51,22 +52,25 @@ class CasAuthenticator extends AbstractFormLoginAuthenticator implements LogoutS
|
||||||
* Called on every request. Return whatever credentials you want,
|
* Called on every request. Return whatever credentials you want,
|
||||||
* or null to stop authentication.
|
* or null to stop authentication.
|
||||||
*/
|
*/
|
||||||
public function getCredentials(Request $request) {
|
public function getCredentials(Request $request)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUser($credentials, UserProviderInterface $userProvider) {
|
public function getUser($credentials, UserProviderInterface $userProvider)
|
||||||
|
{
|
||||||
$username = \phpCAS::getUser();
|
$username = \phpCAS::getUser();
|
||||||
$user = $userProvider->loadUserByUsername($username);
|
$user = $userProvider->loadUserByUsername($username);
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkCredentials($credentials, UserInterface $user) {
|
public function checkCredentials($credentials, UserInterface $user)
|
||||||
|
{
|
||||||
return $this->authService->ctrlAccess($user);
|
return $this->authService->ctrlAccess($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey) {
|
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey)
|
||||||
|
{
|
||||||
$event = new OnAuthenticationSuccessEvent($request, $token, $providerKey);
|
$event = new OnAuthenticationSuccessEvent($request, $token, $providerKey);
|
||||||
$this->dispatcher->dispatch(OnAuthenticationSuccessEvent::NAME, $event);
|
$this->dispatcher->dispatch(OnAuthenticationSuccessEvent::NAME, $event);
|
||||||
|
|
||||||
|
@ -74,8 +78,8 @@ class CasAuthenticator extends AbstractFormLoginAuthenticator implements LogoutS
|
||||||
// on success, let the request continue
|
// on success, let the request continue
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onAuthenticationFailure(Request $request, AuthenticationException $exception) {
|
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
|
||||||
|
{
|
||||||
$event = new OnAuthenticationFailureEvent($request, $exception);
|
$event = new OnAuthenticationFailureEvent($request, $exception);
|
||||||
$this->dispatcher->dispatch(OnAuthenticationFailureEvent::NAME, $event);
|
$this->dispatcher->dispatch(OnAuthenticationFailureEvent::NAME, $event);
|
||||||
|
|
||||||
|
@ -90,25 +94,28 @@ class CasAuthenticator extends AbstractFormLoginAuthenticator implements LogoutS
|
||||||
// return new RedirectResponse($url);
|
// return new RedirectResponse($url);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public function supportsRememberMe() {
|
public function supportsRememberMe()
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//implementation LogoutSuccessHandlerInterface
|
//implementation LogoutSuccessHandlerInterface
|
||||||
public function onLogoutSuccess(Request $request) {
|
public function onLogoutSuccess(Request $request)
|
||||||
|
{
|
||||||
$homepage = $this->config["homepage"];
|
$homepage = $this->config["homepage"];
|
||||||
return \phpCAS::logoutWithRedirectService($this->urlGenerator->generate($homepage, array(), UrlGeneratorInterface::ABSOLUTE_URL));
|
return \phpCAS::logoutWithRedirectService($this->urlGenerator->generate($homepage, array(), UrlGeneratorInterface::ABSOLUTE_URL));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getLoginUrl() {
|
protected function getLoginUrl()
|
||||||
|
{
|
||||||
return \phpCas::getServerLoginURL();
|
return \phpCas::getServerLoginURL();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supports(Request $request) {
|
public function supports(Request $request)
|
||||||
|
{
|
||||||
if (isset($this->config['environment']) && $this->config['environment'] == "test") {
|
if (isset($this->config['environment']) && $this->config['environment'] == "test") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,8 @@ use Symfony\Component\Security\Core\User\UserChecker;
|
||||||
*
|
*
|
||||||
* @author belhadjali
|
* @author belhadjali
|
||||||
*/
|
*/
|
||||||
class DefaultAuthentication extends AuthFinal implements AuthInterface {
|
class DefaultAuthentication extends AuthFinal implements AuthInterface
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Uniquely identifies the secured area
|
* @var string Uniquely identifies the secured area
|
||||||
|
@ -48,9 +49,11 @@ class DefaultAuthentication extends AuthFinal implements AuthInterface {
|
||||||
'secured_area'
|
'secured_area'
|
||||||
);
|
);
|
||||||
|
|
||||||
$userProvider = new UserProvider( new Authentication(),
|
$userProvider = new UserProvider(
|
||||||
|
new Authentication(),
|
||||||
array('user_entity' => 'App\Session\AuthBundle\Security\Auth\User',
|
array('user_entity' => 'App\Session\AuthBundle\Security\Auth\User',
|
||||||
'type_auth' => 'Cas'));
|
'type_auth' => 'Cas')
|
||||||
|
);
|
||||||
$userChecker = new UserChecker();
|
$userChecker = new UserChecker();
|
||||||
|
|
||||||
$defaultEncoder = new MessageDigestPasswordEncoder('sha512', true, 5000);
|
$defaultEncoder = new MessageDigestPasswordEncoder('sha512', true, 5000);
|
||||||
|
@ -65,7 +68,8 @@ class DefaultAuthentication extends AuthFinal implements AuthInterface {
|
||||||
$userProvider,
|
$userProvider,
|
||||||
$userChecker,
|
$userChecker,
|
||||||
'secured_area',
|
'secured_area',
|
||||||
$encoderFactory);
|
$encoderFactory
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
$authenticatedToken = $provider
|
$authenticatedToken = $provider
|
||||||
|
@ -76,11 +80,13 @@ class DefaultAuthentication extends AuthFinal implements AuthInterface {
|
||||||
//$tokenStorage->setToken($authenticatedToken);
|
//$tokenStorage->setToken($authenticatedToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRoles() {
|
public function getRoles()
|
||||||
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSuccess($token) {
|
public function onSuccess($token)
|
||||||
|
{
|
||||||
|
|
||||||
//dump($this->ai);
|
//dump($this->ai);
|
||||||
//die('success');
|
//die('success');
|
||||||
|
@ -95,12 +101,14 @@ class DefaultAuthentication extends AuthFinal implements AuthInterface {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ctrlAccess(\Symfony\Component\Security\Core\User\UserInterface $user) {
|
public function ctrlAccess(\Symfony\Component\Security\Core\User\UserInterface $user)
|
||||||
|
{
|
||||||
//die('ctrlAccess');
|
//die('ctrlAccess');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUser($username) {
|
public function getUser($username)
|
||||||
|
{
|
||||||
return parent::getUser($username);
|
return parent::getUser($username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,62 +15,75 @@ use App\Session\AuthBundle\Security\Interfaces\AttributesInterface;
|
||||||
* renvoyé par CAS à partir des méthodes d'accès définies dans l'interface AttributesInterface
|
* renvoyé par CAS à partir des méthodes d'accès définies dans l'interface AttributesInterface
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class CasAttributes implements AttributesInterface {
|
class CasAttributes implements AttributesInterface
|
||||||
|
{
|
||||||
public function getFirstName() {
|
public function getFirstName()
|
||||||
|
{
|
||||||
return \phpCAS::getAttribute("prenom");
|
return \phpCAS::getAttribute("prenom");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCompletName() {
|
public function getCompletName()
|
||||||
|
{
|
||||||
return \phpCAS::getAttribute("nomcomplet");
|
return \phpCAS::getAttribute("nomcomplet");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getName()
|
||||||
|
{
|
||||||
return \phpCAS::getAttribute("nom");
|
return \phpCAS::getAttribute("nom");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDiscipline() {
|
public function getDiscipline()
|
||||||
|
{
|
||||||
return \phpCAS::getAttribute("discipline");
|
return \phpCAS::getAttribute("discipline");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFonctM() {
|
public function getFonctM()
|
||||||
|
{
|
||||||
return \phpCAS::getAttribute("fonctm");
|
return \phpCAS::getAttribute("fonctm");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRne() {
|
public function getRne()
|
||||||
|
{
|
||||||
return \phpCAS::getAttribute("rne");
|
return \phpCAS::getAttribute("rne");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFreDuRne() {
|
public function getFreDuRne()
|
||||||
|
{
|
||||||
return \phpCAS::getAttribute("FrEduRne");
|
return \phpCAS::getAttribute("FrEduRne");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFreDuRneResp() {
|
public function getFreDuRneResp()
|
||||||
|
{
|
||||||
return \phpCAS::getAttribute("FrEduRneResp");
|
return \phpCAS::getAttribute("FrEduRneResp");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMail() {
|
public function getMail()
|
||||||
|
{
|
||||||
return \phpCAS::getAttribute("mail");
|
return \phpCAS::getAttribute("mail");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle() {
|
public function getTitle()
|
||||||
|
{
|
||||||
return \phpCAS::getAttribute("title");
|
return \phpCAS::getAttribute("title");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUsername() {
|
public function getUsername()
|
||||||
|
{
|
||||||
return \phpCAS::getUser();
|
return \phpCAS::getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFrEduResDel(){
|
public function getFrEduResDel()
|
||||||
|
{
|
||||||
return \phpCAS::getAttribute("FrEduResDel");
|
return \phpCAS::getAttribute("FrEduResDel");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFrEduFonctAdm() {
|
public function getFrEduFonctAdm()
|
||||||
|
{
|
||||||
return \phpCAS::getAttribute("FrEduFonctAdm");
|
return \phpCAS::getAttribute("FrEduFonctAdm");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGrade() {
|
public function getGrade()
|
||||||
|
{
|
||||||
return \phpCAS::getAttribute("grade");
|
return \phpCAS::getAttribute("grade");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,62 +19,75 @@ use App\Besancon\AuthBundle\Security\Interfaces\AttributesInterface;
|
||||||
* renvoyé par RSA CT à partir des méthodes d'accès définies dans l'interface AttributesInterface
|
* renvoyé par RSA CT à partir des méthodes d'accès définies dans l'interface AttributesInterface
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class RsaAttributes implements AttributesInterface {
|
class RsaAttributes implements AttributesInterface
|
||||||
|
{
|
||||||
public function getCompletName() {
|
public function getCompletName()
|
||||||
|
{
|
||||||
return (isset($_SERVER['HTTP_CN'])) ? $_SERVER['HTTP_CN'] : null;
|
return (isset($_SERVER['HTTP_CN'])) ? $_SERVER['HTTP_CN'] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDiscipline() {
|
public function getDiscipline()
|
||||||
|
{
|
||||||
return (isset($_SERVER['HTTP_DISCIPLINE'])) ? $_SERVER['HTTP_DISCIPLINE'] : null;
|
return (isset($_SERVER['HTTP_DISCIPLINE'])) ? $_SERVER['HTTP_DISCIPLINE'] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFonctM() {
|
public function getFonctM()
|
||||||
|
{
|
||||||
return (isset($_SERVER['HTTP_FONCTM'])) ? $_SERVER['HTTP_FONCTM'] : null;
|
return (isset($_SERVER['HTTP_FONCTM'])) ? $_SERVER['HTTP_FONCTM'] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRne() {
|
public function getRne()
|
||||||
|
{
|
||||||
return (isset($_SERVER['HTTP_RNE'])) ? $_SERVER['HTTP_FREDURNE'] : null;
|
return (isset($_SERVER['HTTP_RNE'])) ? $_SERVER['HTTP_FREDURNE'] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFreDuRne() {
|
public function getFreDuRne()
|
||||||
|
{
|
||||||
return (isset($_SERVER['HTTP_FREDURNE'])) ? explode(',', $_SERVER['HTTP_FREDURNE']) : null;
|
return (isset($_SERVER['HTTP_FREDURNE'])) ? explode(',', $_SERVER['HTTP_FREDURNE']) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFreDuRneResp() {
|
public function getFreDuRneResp()
|
||||||
|
{
|
||||||
return (isset($_SERVER['HTTP_FREDURNERESP'])) ? explode(',', $_SERVER['HTTP_FREDURNERESP']) : null;
|
return (isset($_SERVER['HTTP_FREDURNERESP'])) ? explode(',', $_SERVER['HTTP_FREDURNERESP']) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMail() {
|
public function getMail()
|
||||||
|
{
|
||||||
return (isset($_SERVER['HTTP_CTEMAIL'])) ? $_SERVER['HTTP_CTEMAIL'] : null;
|
return (isset($_SERVER['HTTP_CTEMAIL'])) ? $_SERVER['HTTP_CTEMAIL'] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle() {
|
public function getTitle()
|
||||||
|
{
|
||||||
return (isset($_SERVER['HTTP_TITLE'])) ? $_SERVER['HTTP_TITLE'] : null;
|
return (isset($_SERVER['HTTP_TITLE'])) ? $_SERVER['HTTP_TITLE'] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUsername() {
|
public function getUsername()
|
||||||
|
{
|
||||||
return (isset($_SERVER['HTTP_CT_REMOTE_USER'])) ? $_SERVER['HTTP_CT_REMOTE_USER'] : null;
|
return (isset($_SERVER['HTTP_CT_REMOTE_USER'])) ? $_SERVER['HTTP_CT_REMOTE_USER'] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFrEduResDel() {
|
public function getFrEduResDel()
|
||||||
|
{
|
||||||
return (isset($_SERVER['HTTP_FREDURESDEL'])) ? $_SERVER['HTTP_FREDURESDEL'] : null;
|
return (isset($_SERVER['HTTP_FREDURESDEL'])) ? $_SERVER['HTTP_FREDURESDEL'] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFrEduFonctAdm() {
|
public function getFrEduFonctAdm()
|
||||||
|
{
|
||||||
return (isset($_SERVER['HTTP_FREDUFONCTADM'])) ? $_SERVER['HTTP_FREDUFONCTADM'] : null;
|
return (isset($_SERVER['HTTP_FREDUFONCTADM'])) ? $_SERVER['HTTP_FREDUFONCTADM'] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFirstName() {
|
public function getFirstName()
|
||||||
|
{
|
||||||
return (isset($_SERVER['HTTP_CTFN'])) ? $_SERVER['HTTP_CTFN'] : null;
|
return (isset($_SERVER['HTTP_CTFN'])) ? $_SERVER['HTTP_CTFN'] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getName()
|
||||||
|
{
|
||||||
return (isset($_SERVER['HTTP_CTLN'])) ? $_SERVER['HTTP_CTLN'] : null;
|
return (isset($_SERVER['HTTP_CTLN'])) ? $_SERVER['HTTP_CTLN'] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGrade() {
|
public function getGrade()
|
||||||
|
{
|
||||||
return (isset($_SERVER['HTTP_GRADE'])) ? $_SERVER['HTTP_GRADE'] : null;
|
return (isset($_SERVER['HTTP_GRADE'])) ? $_SERVER['HTTP_GRADE'] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,62 +15,75 @@ use App\Session\AuthBundle\Security\Interfaces\AttributesInterface;
|
||||||
* renvoyé par CAS à partir des méthodes d'accès définies dans l'interface AttributesInterface
|
* renvoyé par CAS à partir des méthodes d'accès définies dans l'interface AttributesInterface
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class SessionAttributes implements AttributesInterface {
|
class SessionAttributes implements AttributesInterface
|
||||||
|
{
|
||||||
public function getFirstName() {
|
public function getFirstName()
|
||||||
|
{
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCompletName() {
|
public function getCompletName()
|
||||||
|
{
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getName()
|
||||||
|
{
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDiscipline() {
|
public function getDiscipline()
|
||||||
|
{
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFonctM() {
|
public function getFonctM()
|
||||||
|
{
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRne() {
|
public function getRne()
|
||||||
|
{
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFreDuRne() {
|
public function getFreDuRne()
|
||||||
|
{
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFreDuRneResp() {
|
public function getFreDuRneResp()
|
||||||
|
{
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMail() {
|
public function getMail()
|
||||||
|
{
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle() {
|
public function getTitle()
|
||||||
|
{
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUsername() {
|
public function getUsername()
|
||||||
|
{
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFrEduResDel(){
|
public function getFrEduResDel()
|
||||||
|
{
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFrEduFonctAdm() {
|
public function getFrEduFonctAdm()
|
||||||
|
{
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGrade() {
|
public function getGrade()
|
||||||
|
{
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,7 +15,6 @@ namespace App\Session\AuthBundle\Security\Interfaces;
|
||||||
*/
|
*/
|
||||||
interface AttributesInterface
|
interface AttributesInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
const NO_VALUE = "X";
|
const NO_VALUE = "X";
|
||||||
|
|
||||||
const FREDURNE_OFFSET_RNE = 0;
|
const FREDURNE_OFFSET_RNE = 0;
|
||||||
|
|
|
@ -12,10 +12,10 @@
|
||||||
*/
|
*/
|
||||||
namespace App\Session\AuthBundle\Security\Interfaces;
|
namespace App\Session\AuthBundle\Security\Interfaces;
|
||||||
|
|
||||||
|
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
|
|
||||||
interface AuthInterface {
|
interface AuthInterface
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contrôle de l'accès à partir des attributs CAS ou RSA
|
* Contrôle de l'accès à partir des attributs CAS ou RSA
|
||||||
|
|
|
@ -30,13 +30,14 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\Security\Guard\AuthenticatorInterface;
|
use Symfony\Component\Security\Guard\AuthenticatorInterface;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
class RsaAuthenticator extends AbstractFormLoginAuthenticator implements LogoutSuccessHandlerInterface, AuthenticatorInterface {
|
class RsaAuthenticator extends AbstractFormLoginAuthenticator implements LogoutSuccessHandlerInterface, AuthenticatorInterface
|
||||||
|
{
|
||||||
private $authService;
|
private $authService;
|
||||||
private $urlGenerator;
|
private $urlGenerator;
|
||||||
private $dispatcher;
|
private $dispatcher;
|
||||||
|
|
||||||
public function __construct(AuthInterface $authService, Array $config, UrlGeneratorInterface $urlGenerator, EventDispatcherInterface $dispatcher) {
|
public function __construct(AuthInterface $authService, array $config, UrlGeneratorInterface $urlGenerator, EventDispatcherInterface $dispatcher)
|
||||||
|
{
|
||||||
$this->urlGenerator = $urlGenerator;
|
$this->urlGenerator = $urlGenerator;
|
||||||
//Récupérer le service déaclaré authService
|
//Récupérer le service déaclaré authService
|
||||||
$this->authService = $authService;
|
$this->authService = $authService;
|
||||||
|
@ -48,7 +49,8 @@ class RsaAuthenticator extends AbstractFormLoginAuthenticator implements LogoutS
|
||||||
* Called on every request. Return whatever credentials you want,
|
* Called on every request. Return whatever credentials you want,
|
||||||
* or null to stop authentication.
|
* or null to stop authentication.
|
||||||
*/
|
*/
|
||||||
public function getCredentials(Request $request) {
|
public function getCredentials(Request $request)
|
||||||
|
{
|
||||||
if (!isset($_SERVER['HTTP_CT_REMOTE_USER']) || empty($_SERVER['HTTP_CT_REMOTE_USER'])) {
|
if (!isset($_SERVER['HTTP_CT_REMOTE_USER']) || empty($_SERVER['HTTP_CT_REMOTE_USER'])) {
|
||||||
$this->returnRequest = $request->getUri();
|
$this->returnRequest = $request->getUri();
|
||||||
throw new \LogicException("Impossible de continuer sous RSA : L'entête HTTP_CT_REMOTE_USER est vide ou manquante");
|
throw new \LogicException("Impossible de continuer sous RSA : L'entête HTTP_CT_REMOTE_USER est vide ou manquante");
|
||||||
|
@ -56,13 +58,15 @@ class RsaAuthenticator extends AbstractFormLoginAuthenticator implements LogoutS
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUser($credentials, UserProviderInterface $userProvider) {
|
public function getUser($credentials, UserProviderInterface $userProvider)
|
||||||
|
{
|
||||||
$username = $_SERVER['HTTP_CT_REMOTE_USER'];
|
$username = $_SERVER['HTTP_CT_REMOTE_USER'];
|
||||||
$user = $userProvider->loadUserByUsername($username);
|
$user = $userProvider->loadUserByUsername($username);
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkCredentials($credentials, UserInterface $user) {
|
public function checkCredentials($credentials, UserInterface $user)
|
||||||
|
{
|
||||||
$this->authService->ctrlAccess($user);
|
$this->authService->ctrlAccess($user);
|
||||||
// check credentials - e.g. make sure the password is valid
|
// check credentials - e.g. make sure the password is valid
|
||||||
// no credential check is needed in this case
|
// no credential check is needed in this case
|
||||||
|
@ -70,8 +74,8 @@ class RsaAuthenticator extends AbstractFormLoginAuthenticator implements LogoutS
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey) {
|
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey)
|
||||||
|
{
|
||||||
$event = new OnAuthenticationSuccessEvent($request, $token, $providerKey);
|
$event = new OnAuthenticationSuccessEvent($request, $token, $providerKey);
|
||||||
$this->dispatcher->dispatch(OnAuthenticationSuccessEvent::NAME, $event);
|
$this->dispatcher->dispatch(OnAuthenticationSuccessEvent::NAME, $event);
|
||||||
|
|
||||||
|
@ -79,8 +83,8 @@ class RsaAuthenticator extends AbstractFormLoginAuthenticator implements LogoutS
|
||||||
// on success, let the request continue
|
// on success, let the request continue
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onAuthenticationFailure(Request $request, AuthenticationException $exception) {
|
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
|
||||||
|
{
|
||||||
$event = new OnAuthenticationFailureEvent($request, $exception);
|
$event = new OnAuthenticationFailureEvent($request, $exception);
|
||||||
$this->dispatcher->dispatch(OnAuthenticationFailureEvent::NAME, $event);
|
$this->dispatcher->dispatch(OnAuthenticationFailureEvent::NAME, $event);
|
||||||
|
|
||||||
|
@ -95,23 +99,27 @@ class RsaAuthenticator extends AbstractFormLoginAuthenticator implements LogoutS
|
||||||
// return new RedirectResponse($url);
|
// return new RedirectResponse($url);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public function supportsRememberMe() {
|
public function supportsRememberMe()
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//implementation LogoutSuccessHandlerInterface
|
//implementation LogoutSuccessHandlerInterface
|
||||||
public function onLogoutSuccess(Request $request) {
|
public function onLogoutSuccess(Request $request)
|
||||||
|
{
|
||||||
$redirect = (isset($_SERVER['HTTP_FREDUURLRETOUR'])) ? $_SERVER['HTTP_FREDUURLRETOUR'] : $this->config['rsa']['logout_url'];
|
$redirect = (isset($_SERVER['HTTP_FREDUURLRETOUR'])) ? $_SERVER['HTTP_FREDUURLRETOUR'] : $this->config['rsa']['logout_url'];
|
||||||
return new RedirectResponse($redirect);
|
return new RedirectResponse($redirect);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getLoginUrl() {
|
protected function getLoginUrl()
|
||||||
|
{
|
||||||
$return_request = urlencode($this->returnRequest);
|
$return_request = urlencode($this->returnRequest);
|
||||||
$params = "?CT_ORIG_URL=" . $return_request;
|
$params = "?CT_ORIG_URL=" . $return_request;
|
||||||
return $this->config['rsa']['login_url'] . $params;
|
return $this->config['rsa']['login_url'] . $params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supports(Request $request) {
|
public function supports(Request $request)
|
||||||
|
{
|
||||||
if (isset($this->config['environment']) && $this->config['environment'] == "test") {
|
if (isset($this->config['environment']) && $this->config['environment'] == "test") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,6 @@ class SessionAuthenticator extends AbstractGuardAuthenticator
|
||||||
// return new JsonResponse($data, Response::HTTP_UNAUTHORIZED);
|
// return new JsonResponse($data, Response::HTTP_UNAUTHORIZED);
|
||||||
$url = $this->router->generate('unauthorized');
|
$url = $this->router->generate('unauthorized');
|
||||||
return new RedirectResponse($url);
|
return new RedirectResponse($url);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,8 +107,6 @@ class SessionAuthenticator extends AbstractGuardAuthenticator
|
||||||
|
|
||||||
$url = $this->router->generate('unauthorized');
|
$url = $this->router->generate('unauthorized');
|
||||||
return new RedirectResponse($url);
|
return new RedirectResponse($url);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsRememberMe()
|
public function supportsRememberMe()
|
||||||
|
@ -117,11 +114,11 @@ class SessionAuthenticator extends AbstractGuardAuthenticator
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onLogoutSuccess(Request $request) {
|
public function onLogoutSuccess(Request $request)
|
||||||
|
{
|
||||||
//$homepage = $this->config["homepage"];
|
//$homepage = $this->config["homepage"];
|
||||||
//return \phpCAS::logoutWithRedirectService($this->urlGenerator->generate($homepage, array(), UrlGeneratorInterface::ABSOLUTE_URL));
|
//return \phpCAS::logoutWithRedirectService($this->urlGenerator->generate($homepage, array(), UrlGeneratorInterface::ABSOLUTE_URL));
|
||||||
header('Location: /index.php');
|
header('Location: /index.php');
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,47 +17,55 @@ namespace App\Session\AuthBundle\Security\User;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
use Symfony\Component\Security\Core\User\EquatableInterface;
|
use Symfony\Component\Security\Core\User\EquatableInterface;
|
||||||
|
|
||||||
class AuthUser implements UserInterface, EquatableInterface {
|
class AuthUser implements UserInterface, EquatableInterface
|
||||||
|
{
|
||||||
private $username;
|
private $username;
|
||||||
private $salt;
|
private $salt;
|
||||||
private $roles = [];
|
private $roles = [];
|
||||||
|
|
||||||
public function __construct($username, $salt, array $roles = []) {
|
public function __construct($username, $salt, array $roles = [])
|
||||||
|
{
|
||||||
$this->username = $username;
|
$this->username = $username;
|
||||||
$this->salt = $salt;
|
$this->salt = $salt;
|
||||||
$this->roles = $roles;
|
$this->roles = $roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRoles() {
|
public function getRoles()
|
||||||
|
{
|
||||||
return $this->roles;
|
return $this->roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRoles($roles) {
|
public function setRoles($roles)
|
||||||
|
{
|
||||||
return $this->roles = $roles;
|
return $this->roles = $roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addRole($role) {
|
public function addRole($role)
|
||||||
|
{
|
||||||
return $this->roles[] = $role;
|
return $this->roles[] = $role;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPassword() {
|
public function getPassword()
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSalt() {
|
public function getSalt()
|
||||||
|
{
|
||||||
return $this->salt;
|
return $this->salt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUsername() {
|
public function getUsername()
|
||||||
|
{
|
||||||
return $this->username;
|
return $this->username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function eraseCredentials() {
|
public function eraseCredentials()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isEqualTo(UserInterface $user) {
|
public function isEqualTo(UserInterface $user)
|
||||||
|
{
|
||||||
if (!$user instanceof AuthUser) {
|
if (!$user instanceof AuthUser) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -72,5 +80,4 @@ class AuthUser implements UserInterface, EquatableInterface {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,10 @@ use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
||||||
|
|
||||||
class AuthUserProvider implements UserProviderInterface {
|
class AuthUserProvider implements UserProviderInterface
|
||||||
|
{
|
||||||
public function __construct(AuthInterface $authService, Array $config) {
|
public function __construct(AuthInterface $authService, array $config)
|
||||||
|
{
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
|
||||||
if (!is_null($this->config['user_entity'])) {
|
if (!is_null($this->config['user_entity'])) {
|
||||||
|
@ -26,13 +27,15 @@ class AuthUserProvider implements UserProviderInterface {
|
||||||
$this->authService = $authService;
|
$this->authService = $authService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadUserByUsername($username) {
|
public function loadUserByUsername($username)
|
||||||
|
{
|
||||||
$entity_user = $this->entity_user;
|
$entity_user = $this->entity_user;
|
||||||
|
|
||||||
return $this->authService->getUser($username);
|
return $this->authService->getUser($username);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _ctrlInstanceUser(UserInterface $user) {
|
private function _ctrlInstanceUser(UserInterface $user)
|
||||||
|
{
|
||||||
$entity_user = $this->entity_user;
|
$entity_user = $this->entity_user;
|
||||||
|
|
||||||
if (!$user instanceof $entity_user) {
|
if (!$user instanceof $entity_user) {
|
||||||
|
@ -44,15 +47,16 @@ class AuthUserProvider implements UserProviderInterface {
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function refreshUser(UserInterface $user) {
|
public function refreshUser(UserInterface $user)
|
||||||
|
{
|
||||||
$user = $this->_ctrlInstanceUser($user);
|
$user = $this->_ctrlInstanceUser($user);
|
||||||
|
|
||||||
return $this->loadUserByUsername($user->getUsername());
|
return $this->loadUserByUsername($user->getUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsClass($class) {
|
public function supportsClass($class)
|
||||||
|
{
|
||||||
$entity_user = $this->entity_user;
|
$entity_user = $this->entity_user;
|
||||||
return $this->entity_class === $class;
|
return $this->entity_class === $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
namespace App\Session\AuthBundle\Utils;
|
namespace App\Session\AuthBundle\Utils;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
|
@ -11,9 +12,10 @@ namespace App\Session\AuthBundle\Utils;
|
||||||
*
|
*
|
||||||
* @author belhadjali
|
* @author belhadjali
|
||||||
*/
|
*/
|
||||||
class Config {
|
class Config
|
||||||
|
{
|
||||||
public static function getDeclaredType($config) {
|
public static function getDeclaredType($config)
|
||||||
|
{
|
||||||
if (!isset($config['type_auth'])) {
|
if (!isset($config['type_auth'])) {
|
||||||
throw new \LogicException('Paramètre type_auth manquant');
|
throw new \LogicException('Paramètre type_auth manquant');
|
||||||
}
|
}
|
||||||
|
@ -25,11 +27,13 @@ class Config {
|
||||||
return self::formatType($type);
|
return self::formatType($type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function formatType($type) {
|
public static function formatType($type)
|
||||||
|
{
|
||||||
return ucfirst(strtolower($type));
|
return ucfirst(strtolower($type));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function typeIsSupported($type) {
|
public static function typeIsSupported($type)
|
||||||
|
{
|
||||||
$type_auth = self::formatType($type);
|
$type_auth = self::formatType($type);
|
||||||
if (!in_array($type_auth, ['Rsa', 'Cas'])) {
|
if (!in_array($type_auth, ['Rsa', 'Cas'])) {
|
||||||
throw new \LogicException('Seuls Cas et Rsa sont supportés pour le moment');
|
throw new \LogicException('Seuls Cas et Rsa sont supportés pour le moment');
|
||||||
|
|
|
@ -14,9 +14,10 @@ namespace App\Utils;
|
||||||
*
|
*
|
||||||
* @author belhadjali
|
* @author belhadjali
|
||||||
*/
|
*/
|
||||||
class Config {
|
class Config
|
||||||
|
{
|
||||||
public static function getDeclaredType($config) {
|
public static function getDeclaredType($config)
|
||||||
|
{
|
||||||
// if (!isset($config['type_auth'])) {
|
// if (!isset($config['type_auth'])) {
|
||||||
// throw new \LogicException('Paramètre type_auth manquant');
|
// throw new \LogicException('Paramètre type_auth manquant');
|
||||||
// }
|
// }
|
||||||
|
@ -29,12 +30,14 @@ namespace App\Utils;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function formatType($type) {
|
public static function formatType($type)
|
||||||
|
{
|
||||||
// return ucfirst(strtolower($type));
|
// return ucfirst(strtolower($type));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function typeIsSupported($type) {
|
public static function typeIsSupported($type)
|
||||||
|
{
|
||||||
// $type_auth = self::formatType($type);
|
// $type_auth = self::formatType($type);
|
||||||
// if (!in_array($type_auth, ['Rsa', 'Cas'])) {
|
// if (!in_array($type_auth, ['Rsa', 'Cas'])) {
|
||||||
// throw new \LogicException('Seuls Cas et Rsa sont supportés pour le moment');
|
// throw new \LogicException('Seuls Cas et Rsa sont supportés pour le moment');
|
||||||
|
|
|
@ -52,7 +52,8 @@ class FilesystemTagAwareAdapter extends AbstractTagAwareAdapter implements Prune
|
||||||
return $ok;
|
return $ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_error_handler(static function () {});
|
set_error_handler(static function () {
|
||||||
|
});
|
||||||
$chars = '+-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
$chars = '+-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -197,7 +198,8 @@ class FilesystemTagAwareAdapter extends AbstractTagAwareAdapter implements Prune
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_error_handler(static function () {});
|
set_error_handler(static function () {
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (rename($tagFolder, $renamed = substr_replace($tagFolder, bin2hex(random_bytes(4)), -9))) {
|
if (rename($tagFolder, $renamed = substr_replace($tagFolder, bin2hex(random_bytes(4)), -9))) {
|
||||||
|
|
7
console/skel/symfony/cache/LockRegistry.php
vendored
7
console/skel/symfony/cache/LockRegistry.php
vendored
|
@ -118,7 +118,9 @@ final class LockRegistry
|
||||||
}
|
}
|
||||||
static $signalingException, $signalingCallback;
|
static $signalingException, $signalingCallback;
|
||||||
$signalingException = $signalingException ?? unserialize("O:9:\"Exception\":1:{s:16:\"\0Exception\0trace\";a:0:{}}");
|
$signalingException = $signalingException ?? unserialize("O:9:\"Exception\":1:{s:16:\"\0Exception\0trace\";a:0:{}}");
|
||||||
$signalingCallback = $signalingCallback ?? function () use ($signalingException) { throw $signalingException; };
|
$signalingCallback = $signalingCallback ?? function () use ($signalingException) {
|
||||||
|
throw $signalingException;
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$value = $pool->get($item->getKey(), $signalingCallback, 0);
|
$value = $pool->get($item->getKey(), $signalingCallback, 0);
|
||||||
|
@ -142,7 +144,8 @@ final class LockRegistry
|
||||||
if (null !== $h = self::$openedFiles[$key] ?? null) {
|
if (null !== $h = self::$openedFiles[$key] ?? null) {
|
||||||
return $h;
|
return $h;
|
||||||
}
|
}
|
||||||
set_error_handler(function () {});
|
set_error_handler(function () {
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
$h = fopen(self::$files[$key], 'r+');
|
$h = fopen(self::$files[$key], 'r+');
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -82,7 +82,9 @@ class ArrayCache implements Psr16CacheInterface, LoggerAwareInterface, Resettabl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->generateItems($keys, microtime(true), function ($k, $v, $hit) use ($default) { return $hit ? $v : $default; });
|
return $this->generateItems($keys, microtime(true), function ($k, $v, $hit) use ($default) {
|
||||||
|
return $hit ? $v : $default;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -86,7 +86,9 @@ trait MemcachedTrait
|
||||||
if (!static::isSupported()) {
|
if (!static::isSupported()) {
|
||||||
throw new CacheException('Memcached >= 2.2.0 is required');
|
throw new CacheException('Memcached >= 2.2.0 is required');
|
||||||
}
|
}
|
||||||
set_error_handler(function ($type, $msg, $file, $line) { throw new \ErrorException($msg, 0, $type, $file, $line); });
|
set_error_handler(function ($type, $msg, $file, $line) {
|
||||||
|
throw new \ErrorException($msg, 0, $type, $file, $line);
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
$options += static::$defaultClientOptions;
|
$options += static::$defaultClientOptions;
|
||||||
$client = new \Memcached($options['persistent_id']);
|
$client = new \Memcached($options['persistent_id']);
|
||||||
|
|
|
@ -61,7 +61,9 @@ trait RedisTrait
|
||||||
|
|
||||||
if ($redisClient instanceof \Predis\ClientInterface && $redisClient->getOptions()->exceptions) {
|
if ($redisClient instanceof \Predis\ClientInterface && $redisClient->getOptions()->exceptions) {
|
||||||
$options = clone $redisClient->getOptions();
|
$options = clone $redisClient->getOptions();
|
||||||
\Closure::bind(function () { $this->options['exceptions'] = false; }, $options, $options)();
|
\Closure::bind(function () {
|
||||||
|
$this->options['exceptions'] = false;
|
||||||
|
}, $options, $options)();
|
||||||
$redisClient = new $redisClient($redisClient->getConnection(), $options);
|
$redisClient = new $redisClient($redisClient->getConnection(), $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +179,9 @@ trait RedisTrait
|
||||||
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): %s', $e->getMessage(), $dsn));
|
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): %s', $e->getMessage(), $dsn));
|
||||||
}
|
}
|
||||||
|
|
||||||
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
|
set_error_handler(function ($type, $msg) use (&$error) {
|
||||||
|
$error = $msg;
|
||||||
|
});
|
||||||
$isConnected = $redis->isConnected();
|
$isConnected = $redis->isConnected();
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
if (!$isConnected) {
|
if (!$isConnected) {
|
||||||
|
|
|
@ -44,7 +44,9 @@ class ExprBuilder
|
||||||
*/
|
*/
|
||||||
public function always(\Closure $then = null)
|
public function always(\Closure $then = null)
|
||||||
{
|
{
|
||||||
$this->ifPart = function ($v) { return true; };
|
$this->ifPart = function ($v) {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
if (null !== $then) {
|
if (null !== $then) {
|
||||||
$this->thenPart = $then;
|
$this->thenPart = $then;
|
||||||
|
@ -65,7 +67,9 @@ class ExprBuilder
|
||||||
public function ifTrue(\Closure $closure = null)
|
public function ifTrue(\Closure $closure = null)
|
||||||
{
|
{
|
||||||
if (null === $closure) {
|
if (null === $closure) {
|
||||||
$closure = function ($v) { return true === $v; };
|
$closure = function ($v) {
|
||||||
|
return true === $v;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->ifPart = $closure;
|
$this->ifPart = $closure;
|
||||||
|
@ -80,7 +84,9 @@ class ExprBuilder
|
||||||
*/
|
*/
|
||||||
public function ifString()
|
public function ifString()
|
||||||
{
|
{
|
||||||
$this->ifPart = function ($v) { return is_string($v); };
|
$this->ifPart = function ($v) {
|
||||||
|
return is_string($v);
|
||||||
|
};
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -92,7 +98,9 @@ class ExprBuilder
|
||||||
*/
|
*/
|
||||||
public function ifNull()
|
public function ifNull()
|
||||||
{
|
{
|
||||||
$this->ifPart = function ($v) { return null === $v; };
|
$this->ifPart = function ($v) {
|
||||||
|
return null === $v;
|
||||||
|
};
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +112,9 @@ class ExprBuilder
|
||||||
*/
|
*/
|
||||||
public function ifEmpty()
|
public function ifEmpty()
|
||||||
{
|
{
|
||||||
$this->ifPart = function ($v) { return empty($v); };
|
$this->ifPart = function ($v) {
|
||||||
|
return empty($v);
|
||||||
|
};
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -116,7 +126,9 @@ class ExprBuilder
|
||||||
*/
|
*/
|
||||||
public function ifArray()
|
public function ifArray()
|
||||||
{
|
{
|
||||||
$this->ifPart = function ($v) { return is_array($v); };
|
$this->ifPart = function ($v) {
|
||||||
|
return is_array($v);
|
||||||
|
};
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +142,9 @@ class ExprBuilder
|
||||||
*/
|
*/
|
||||||
public function ifInArray(array $array)
|
public function ifInArray(array $array)
|
||||||
{
|
{
|
||||||
$this->ifPart = function ($v) use ($array) { return in_array($v, $array, true); };
|
$this->ifPart = function ($v) use ($array) {
|
||||||
|
return in_array($v, $array, true);
|
||||||
|
};
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -144,7 +158,9 @@ class ExprBuilder
|
||||||
*/
|
*/
|
||||||
public function ifNotInArray(array $array)
|
public function ifNotInArray(array $array)
|
||||||
{
|
{
|
||||||
$this->ifPart = function ($v) use ($array) { return !in_array($v, $array, true); };
|
$this->ifPart = function ($v) use ($array) {
|
||||||
|
return !in_array($v, $array, true);
|
||||||
|
};
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -156,8 +172,12 @@ class ExprBuilder
|
||||||
*/
|
*/
|
||||||
public function castToArray()
|
public function castToArray()
|
||||||
{
|
{
|
||||||
$this->ifPart = function ($v) { return !is_array($v); };
|
$this->ifPart = function ($v) {
|
||||||
$this->thenPart = function ($v) { return array($v); };
|
return !is_array($v);
|
||||||
|
};
|
||||||
|
$this->thenPart = function ($v) {
|
||||||
|
return array($v);
|
||||||
|
};
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -183,7 +203,9 @@ class ExprBuilder
|
||||||
*/
|
*/
|
||||||
public function thenEmptyArray()
|
public function thenEmptyArray()
|
||||||
{
|
{
|
||||||
$this->thenPart = function ($v) { return array(); };
|
$this->thenPart = function ($v) {
|
||||||
|
return array();
|
||||||
|
};
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -201,7 +223,9 @@ class ExprBuilder
|
||||||
*/
|
*/
|
||||||
public function thenInvalid($message)
|
public function thenInvalid($message)
|
||||||
{
|
{
|
||||||
$this->thenPart = function ($v) use ($message) {throw new \InvalidArgumentException(sprintf($message, json_encode($v))); };
|
$this->thenPart = function ($v) use ($message) {
|
||||||
|
throw new \InvalidArgumentException(sprintf($message, json_encode($v)));
|
||||||
|
};
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -215,7 +239,9 @@ class ExprBuilder
|
||||||
*/
|
*/
|
||||||
public function thenUnset()
|
public function thenUnset()
|
||||||
{
|
{
|
||||||
$this->thenPart = function ($v) { throw new UnsetKeyException('Unsetting key'); };
|
$this->thenPart = function ($v) {
|
||||||
|
throw new UnsetKeyException('Unsetting key');
|
||||||
|
};
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,8 @@ class EnumNode extends ScalarNode
|
||||||
'The value %s is not allowed for path "%s". Permissible values: %s',
|
'The value %s is not allowed for path "%s". Permissible values: %s',
|
||||||
json_encode($value),
|
json_encode($value),
|
||||||
$this->getPath(),
|
$this->getPath(),
|
||||||
implode(', ', array_map('json_encode', $this->values))));
|
implode(', ', array_map('json_encode', $this->values))
|
||||||
|
));
|
||||||
$ex->setPath($this->getPath());
|
$ex->setPath($this->getPath());
|
||||||
|
|
||||||
throw $ex;
|
throw $ex;
|
||||||
|
|
|
@ -86,7 +86,8 @@ class FileLocator implements FileLocatorInterface
|
||||||
private function isAbsolutePath($file)
|
private function isAbsolutePath($file)
|
||||||
{
|
{
|
||||||
if ($file[0] === '/' || $file[0] === '\\'
|
if ($file[0] === '/' || $file[0] === '\\'
|
||||||
|| (strlen($file) > 3 && ctype_alpha($file[0])
|
|| (
|
||||||
|
strlen($file) > 3 && ctype_alpha($file[0])
|
||||||
&& $file[1] === ':'
|
&& $file[1] === ':'
|
||||||
&& ($file[2] === '\\' || $file[2] === '/')
|
&& ($file[2] === '\\' || $file[2] === '/')
|
||||||
)
|
)
|
||||||
|
|
|
@ -26,7 +26,7 @@ interface LoaderInterface
|
||||||
*
|
*
|
||||||
* @throws \Exception If something went wrong
|
* @throws \Exception If something went wrong
|
||||||
*/
|
*/
|
||||||
public function load($resource, string $type = NULL);
|
public function load($resource, string $type = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this class supports the given resource.
|
* Returns whether this class supports the given resource.
|
||||||
|
@ -36,7 +36,7 @@ interface LoaderInterface
|
||||||
*
|
*
|
||||||
* @return bool True if this class supports the given resource, false otherwise
|
* @return bool True if this class supports the given resource, false otherwise
|
||||||
*/
|
*/
|
||||||
public function supports($resource, string $type = NULL);
|
public function supports($resource, string $type = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the loader resolver.
|
* Gets the loader resolver.
|
||||||
|
|
|
@ -101,7 +101,9 @@ class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface,
|
||||||
$files = iterator_to_array(new \RecursiveIteratorIterator(
|
$files = iterator_to_array(new \RecursiveIteratorIterator(
|
||||||
new \RecursiveCallbackFilterIterator(
|
new \RecursiveCallbackFilterIterator(
|
||||||
new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS),
|
new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS),
|
||||||
function (\SplFileInfo $file) { return '.' !== $file->getBasename()[0]; }
|
function (\SplFileInfo $file) {
|
||||||
|
return '.' !== $file->getBasename()[0];
|
||||||
|
}
|
||||||
),
|
),
|
||||||
\RecursiveIteratorIterator::LEAVES_ONLY
|
\RecursiveIteratorIterator::LEAVES_ONLY
|
||||||
));
|
));
|
||||||
|
|
|
@ -34,13 +34,17 @@ class ExprBuilderTest extends TestCase
|
||||||
$this->assertFinalizedValueIs('new_value', $test, array('key' => true));
|
$this->assertFinalizedValueIs('new_value', $test, array('key' => true));
|
||||||
|
|
||||||
$test = $this->getTestBuilder()
|
$test = $this->getTestBuilder()
|
||||||
->ifTrue(function ($v) { return true; })
|
->ifTrue(function ($v) {
|
||||||
|
return true;
|
||||||
|
})
|
||||||
->then($this->returnClosure('new_value'))
|
->then($this->returnClosure('new_value'))
|
||||||
->end();
|
->end();
|
||||||
$this->assertFinalizedValueIs('new_value', $test);
|
$this->assertFinalizedValueIs('new_value', $test);
|
||||||
|
|
||||||
$test = $this->getTestBuilder()
|
$test = $this->getTestBuilder()
|
||||||
->ifTrue(function ($v) { return false; })
|
->ifTrue(function ($v) {
|
||||||
|
return false;
|
||||||
|
})
|
||||||
->then($this->returnClosure('new_value'))
|
->then($this->returnClosure('new_value'))
|
||||||
->end();
|
->end();
|
||||||
$this->assertFinalizedValueIs('value', $test);
|
$this->assertFinalizedValueIs('value', $test);
|
||||||
|
|
|
@ -35,7 +35,10 @@ class XmlReferenceDumperTest extends TestCase
|
||||||
|
|
||||||
private function getConfigurationAsString()
|
private function getConfigurationAsString()
|
||||||
{
|
{
|
||||||
return str_replace("\n", PHP_EOL, <<<'EOL'
|
return str_replace(
|
||||||
|
"\n",
|
||||||
|
PHP_EOL,
|
||||||
|
<<<'EOL'
|
||||||
<!-- Namespace: http://example.org/schema/dic/acme_root -->
|
<!-- Namespace: http://example.org/schema/dic/acme_root -->
|
||||||
<!-- scalar-required: Required -->
|
<!-- scalar-required: Required -->
|
||||||
<!-- enum-with-default: One of "this"; "that" -->
|
<!-- enum-with-default: One of "this"; "that" -->
|
||||||
|
|
|
@ -30,7 +30,9 @@ class NormalizationTest extends TestCase
|
||||||
->node('encoders', 'array')
|
->node('encoders', 'array')
|
||||||
->useAttributeAsKey('class')
|
->useAttributeAsKey('class')
|
||||||
->prototype('array')
|
->prototype('array')
|
||||||
->beforeNormalization()->ifString()->then(function ($v) { return array('algorithm' => $v); })->end()
|
->beforeNormalization()->ifString()->then(function ($v) {
|
||||||
|
return array('algorithm' => $v);
|
||||||
|
})->end()
|
||||||
->children()
|
->children()
|
||||||
->node('algorithm', 'scalar')->end()
|
->node('algorithm', 'scalar')->end()
|
||||||
->end()
|
->end()
|
||||||
|
@ -135,7 +137,9 @@ class NormalizationTest extends TestCase
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
return array_map(function ($v) { return array($v); }, $configs);
|
return array_map(function ($v) {
|
||||||
|
return array($v);
|
||||||
|
}, $configs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,7 +170,9 @@ class NormalizationTest extends TestCase
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
return array_map(function ($v) { return array($v); }, $configs);
|
return array_map(function ($v) {
|
||||||
|
return array($v);
|
||||||
|
}, $configs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,7 +34,8 @@ class LoaderResolverTest extends TestCase
|
||||||
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
|
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
|
||||||
$loader->expects($this->once())->method('supports')->will($this->returnValue(true));
|
$loader->expects($this->once())->method('supports')->will($this->returnValue(true));
|
||||||
$resolver = new LoaderResolver(array($loader));
|
$resolver = new LoaderResolver(array($loader));
|
||||||
$this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource');
|
$this->assertEquals($loader, $resolver->resolve(function () {
|
||||||
|
}), '->resolve() returns the loader for the given resource');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLoaders()
|
public function testLoaders()
|
||||||
|
|
|
@ -56,7 +56,9 @@ EOF
|
||||||
|
|
||||||
public function testExistsKo()
|
public function testExistsKo()
|
||||||
{
|
{
|
||||||
spl_autoload_register($autoloader = function ($class) use (&$loadedClass) { $loadedClass = $class; });
|
spl_autoload_register($autoloader = function ($class) use (&$loadedClass) {
|
||||||
|
$loadedClass = $class;
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$res = new ClassExistenceResource('MissingFooClass');
|
$res = new ClassExistenceResource('MissingFooClass');
|
||||||
|
|
|
@ -220,7 +220,8 @@ class XmlUtils
|
||||||
{
|
{
|
||||||
$errors = array();
|
$errors = array();
|
||||||
foreach (libxml_get_errors() as $error) {
|
foreach (libxml_get_errors() as $error) {
|
||||||
$errors[] = sprintf('[%s %s] %s (in %s - line %d, column %d)',
|
$errors[] = sprintf(
|
||||||
|
'[%s %s] %s (in %s - line %d, column %d)',
|
||||||
LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR',
|
LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR',
|
||||||
$error->code,
|
$error->code,
|
||||||
trim($error->message),
|
trim($error->message),
|
||||||
|
|
|
@ -290,12 +290,16 @@ class ExpressionLanguageTest extends TestCase
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
function (ExpressionLanguage $el) {
|
function (ExpressionLanguage $el) {
|
||||||
$el->register('fn', function () {}, function () {});
|
$el->register('fn', function () {
|
||||||
|
}, function () {
|
||||||
|
});
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
function (ExpressionLanguage $el) {
|
function (ExpressionLanguage $el) {
|
||||||
$el->addFunction(new ExpressionFunction('fn', function () {}, function () {}));
|
$el->addFunction(new ExpressionFunction('fn', function () {
|
||||||
|
}, function () {
|
||||||
|
}));
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|
|
@ -91,7 +91,8 @@ class ParserTest extends TestCase
|
||||||
'3 - 3',
|
'3 - 3',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
new Node\BinaryNode('*',
|
new Node\BinaryNode(
|
||||||
|
'*',
|
||||||
new Node\BinaryNode('-', new Node\ConstantNode(3), new Node\ConstantNode(3)),
|
new Node\BinaryNode('-', new Node\ConstantNode(3), new Node\ConstantNode(3)),
|
||||||
new Node\ConstantNode(2)
|
new Node\ConstantNode(2)
|
||||||
),
|
),
|
||||||
|
@ -142,9 +143,15 @@ class ParserTest extends TestCase
|
||||||
$this->createGetAttrNode(
|
$this->createGetAttrNode(
|
||||||
$this->createGetAttrNode(
|
$this->createGetAttrNode(
|
||||||
$this->createGetAttrNode(new Node\NameNode('foo'), 'bar', Node\GetAttrNode::METHOD_CALL),
|
$this->createGetAttrNode(new Node\NameNode('foo'), 'bar', Node\GetAttrNode::METHOD_CALL),
|
||||||
'foo', Node\GetAttrNode::METHOD_CALL),
|
'foo',
|
||||||
'baz', Node\GetAttrNode::PROPERTY_CALL),
|
Node\GetAttrNode::METHOD_CALL
|
||||||
'3', Node\GetAttrNode::ARRAY_CALL),
|
),
|
||||||
|
'baz',
|
||||||
|
Node\GetAttrNode::PROPERTY_CALL
|
||||||
|
),
|
||||||
|
'3',
|
||||||
|
Node\GetAttrNode::ARRAY_CALL
|
||||||
|
),
|
||||||
'foo.bar().foo().baz[3]',
|
'foo.bar().foo().baz[3]',
|
||||||
['foo'],
|
['foo'],
|
||||||
],
|
],
|
||||||
|
|
|
@ -601,7 +601,8 @@ class Filesystem
|
||||||
public function isAbsolutePath($file)
|
public function isAbsolutePath($file)
|
||||||
{
|
{
|
||||||
return strspn($file, '/\\', 0, 1)
|
return strspn($file, '/\\', 0, 1)
|
||||||
|| (\strlen($file) > 3 && ctype_alpha($file[0])
|
|| (
|
||||||
|
\strlen($file) > 3 && ctype_alpha($file[0])
|
||||||
&& ':' === $file[1]
|
&& ':' === $file[1]
|
||||||
&& strspn($file, '/\\', 2, 1)
|
&& strspn($file, '/\\', 2, 1)
|
||||||
)
|
)
|
||||||
|
|
|
@ -94,8 +94,12 @@ abstract class AbstractFindAdapter extends AbstractAdapter
|
||||||
$command->setErrorHandler(
|
$command->setErrorHandler(
|
||||||
$this->ignoreUnreadableDirs
|
$this->ignoreUnreadableDirs
|
||||||
// If directory is unreadable and finder is set to ignore it, `stderr` is ignored.
|
// If directory is unreadable and finder is set to ignore it, `stderr` is ignored.
|
||||||
? function ($stderr) { return; }
|
? function ($stderr) {
|
||||||
: function ($stderr) { throw new AccessDeniedException($stderr); }
|
return;
|
||||||
|
}
|
||||||
|
: function ($stderr) {
|
||||||
|
throw new AccessDeniedException($stderr);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$paths = $this->shell->testCommand('uniq') ? $command->add('| uniq')->execute() : array_unique($command->execute());
|
$paths = $this->shell->testCommand('uniq') ? $command->add('| uniq')->execute() : array_unique($command->execute());
|
||||||
|
@ -181,7 +185,8 @@ abstract class AbstractFindAdapter extends AbstractAdapter
|
||||||
|
|
||||||
$command
|
$command
|
||||||
->add($i > 0 ? '-or' : null)
|
->add($i > 0 ? '-or' : null)
|
||||||
->add($expr->isRegex()
|
->add(
|
||||||
|
$expr->isRegex()
|
||||||
? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
|
? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
|
||||||
: ($expr->isCaseSensitive() ? '-name' : '-iname')
|
: ($expr->isCaseSensitive() ? '-name' : '-iname')
|
||||||
)
|
)
|
||||||
|
@ -223,7 +228,8 @@ abstract class AbstractFindAdapter extends AbstractAdapter
|
||||||
|
|
||||||
$command
|
$command
|
||||||
->add($i > 0 ? '-or' : null)
|
->add($i > 0 ? '-or' : null)
|
||||||
->add($expr->isRegex()
|
->add(
|
||||||
|
$expr->isRegex()
|
||||||
? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
|
? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
|
||||||
: ($expr->isCaseSensitive() ? '-path' : '-ipath')
|
: ($expr->isCaseSensitive() ? '-path' : '-ipath')
|
||||||
)
|
)
|
||||||
|
|
|
@ -273,7 +273,9 @@ class Command
|
||||||
array_map(function ($bit) {
|
array_map(function ($bit) {
|
||||||
return $bit instanceof Command ? $bit->join() : ($bit ?: null);
|
return $bit instanceof Command ? $bit->join() : ($bit ?: null);
|
||||||
}, $this->bits),
|
}, $this->bits),
|
||||||
function ($bit) { return null !== $bit; }
|
function ($bit) {
|
||||||
|
return null !== $bit;
|
||||||
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -264,7 +264,9 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||||
public function testSort($adapter)
|
public function testSort($adapter)
|
||||||
{
|
{
|
||||||
$finder = $this->buildFinder($adapter);
|
$finder = $this->buildFinder($adapter);
|
||||||
$this->assertSame($finder, $finder->sort(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealpath(), $b->getRealpath()); }));
|
$this->assertSame($finder, $finder->sort(function (\SplFileInfo $a, \SplFileInfo $b) {
|
||||||
|
return strcmp($a->getRealpath(), $b->getRealpath());
|
||||||
|
}));
|
||||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
$this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +276,9 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||||
public function testFilter($adapter)
|
public function testFilter($adapter)
|
||||||
{
|
{
|
||||||
$finder = $this->buildFinder($adapter);
|
$finder = $this->buildFinder($adapter);
|
||||||
$this->assertSame($finder, $finder->filter(function (\SplFileInfo $f) { return preg_match('/test/', $f) > 0; }));
|
$this->assertSame($finder, $finder->filter(function (\SplFileInfo $f) {
|
||||||
|
return preg_match('/test/', $f) > 0;
|
||||||
|
}));
|
||||||
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
|
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,7 +378,9 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||||
|
|
||||||
$finder = $this->buildFinder($adapter);
|
$finder = $this->buildFinder($adapter);
|
||||||
$a = iterator_to_array($finder->directories()->in(self::$tmpDir));
|
$a = iterator_to_array($finder->directories()->in(self::$tmpDir));
|
||||||
$a = array_values(array_map(function ($a) { return (string) $a; }, $a));
|
$a = array_values(array_map(function ($a) {
|
||||||
|
return (string) $a;
|
||||||
|
}, $a));
|
||||||
sort($a);
|
sort($a);
|
||||||
$this->assertEquals($expected, $a, 'implements the \IteratorAggregate interface');
|
$this->assertEquals($expected, $a, 'implements the \IteratorAggregate interface');
|
||||||
}
|
}
|
||||||
|
@ -632,7 +638,9 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||||
public function getAdaptersTestData()
|
public function getAdaptersTestData()
|
||||||
{
|
{
|
||||||
return array_map(
|
return array_map(
|
||||||
function ($adapter) { return array($adapter); },
|
function ($adapter) {
|
||||||
|
return array($adapter);
|
||||||
|
},
|
||||||
$this->getValidAdapters()
|
$this->getValidAdapters()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,12 @@ class CustomFilterIteratorTest extends IteratorTestCase
|
||||||
public function getAcceptData()
|
public function getAcceptData()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(array(function (\SplFileInfo $fileinfo) { return false; }), array()),
|
array(array(function (\SplFileInfo $fileinfo) {
|
||||||
array(array(function (\SplFileInfo $fileinfo) { return preg_match('/^test/', $fileinfo) > 0; }), array('test.php', 'test.py')),
|
return false;
|
||||||
|
}), array()),
|
||||||
|
array(array(function (\SplFileInfo $fileinfo) {
|
||||||
|
return preg_match('/^test/', $fileinfo) > 0;
|
||||||
|
}), array('test.php', 'test.py')),
|
||||||
array(array('is_dir'), array()),
|
array(array('is_dir'), array()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,28 +49,32 @@ class FilecontentFilterIteratorTest extends IteratorTestCase
|
||||||
{
|
{
|
||||||
$inner = new MockFileListIterator();
|
$inner = new MockFileListIterator();
|
||||||
|
|
||||||
$inner[] = new MockSplFileInfo(array(
|
$inner[] = new MockSplFileInfo(
|
||||||
|
array(
|
||||||
'name' => 'a.txt',
|
'name' => 'a.txt',
|
||||||
'contents' => 'Lorem ipsum...',
|
'contents' => 'Lorem ipsum...',
|
||||||
'type' => 'file',
|
'type' => 'file',
|
||||||
'mode' => 'r+', )
|
'mode' => 'r+', )
|
||||||
);
|
);
|
||||||
|
|
||||||
$inner[] = new MockSplFileInfo(array(
|
$inner[] = new MockSplFileInfo(
|
||||||
|
array(
|
||||||
'name' => 'b.yml',
|
'name' => 'b.yml',
|
||||||
'contents' => 'dolor sit...',
|
'contents' => 'dolor sit...',
|
||||||
'type' => 'file',
|
'type' => 'file',
|
||||||
'mode' => 'r+', )
|
'mode' => 'r+', )
|
||||||
);
|
);
|
||||||
|
|
||||||
$inner[] = new MockSplFileInfo(array(
|
$inner[] = new MockSplFileInfo(
|
||||||
|
array(
|
||||||
'name' => 'some/other/dir/third.php',
|
'name' => 'some/other/dir/third.php',
|
||||||
'contents' => 'amet...',
|
'contents' => 'amet...',
|
||||||
'type' => 'file',
|
'type' => 'file',
|
||||||
'mode' => 'r+', )
|
'mode' => 'r+', )
|
||||||
);
|
);
|
||||||
|
|
||||||
$inner[] = new MockSplFileInfo(array(
|
$inner[] = new MockSplFileInfo(
|
||||||
|
array(
|
||||||
'name' => 'unreadable-file.txt',
|
'name' => 'unreadable-file.txt',
|
||||||
'contents' => false,
|
'contents' => false,
|
||||||
'type' => 'file',
|
'type' => 'file',
|
||||||
|
|
|
@ -24,7 +24,8 @@ class FilterIteratorTest extends RealIteratorTestCase
|
||||||
$i = $this->getMockForAbstractClass('Symfony\Component\Finder\Iterator\FilterIterator', array($i));
|
$i = $this->getMockForAbstractClass('Symfony\Component\Finder\Iterator\FilterIterator', array($i));
|
||||||
$i->expects($this->any())
|
$i->expects($this->any())
|
||||||
->method('accept')
|
->method('accept')
|
||||||
->will($this->returnCallback(function () use ($i) {
|
->will(
|
||||||
|
$this->returnCallback(function () use ($i) {
|
||||||
return (bool) preg_match('/\.php/', (string) $i->current());
|
return (bool) preg_match('/\.php/', (string) $i->current());
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
@ -17,9 +17,13 @@ abstract class IteratorTestCase extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
// set iterator_to_array $use_key to false to avoid values merge
|
// set iterator_to_array $use_key to false to avoid values merge
|
||||||
// this made FinderTest::testAppendWithAnArray() failed with GnuFinderAdapter
|
// this made FinderTest::testAppendWithAnArray() failed with GnuFinderAdapter
|
||||||
$values = array_map(function (\SplFileInfo $fileinfo) { return str_replace('/', DIRECTORY_SEPARATOR, $fileinfo->getPathname()); }, iterator_to_array($iterator, false));
|
$values = array_map(function (\SplFileInfo $fileinfo) {
|
||||||
|
return str_replace('/', DIRECTORY_SEPARATOR, $fileinfo->getPathname());
|
||||||
|
}, iterator_to_array($iterator, false));
|
||||||
|
|
||||||
$expected = array_map(function ($path) { return str_replace('/', DIRECTORY_SEPARATOR, $path); }, $expected);
|
$expected = array_map(function ($path) {
|
||||||
|
return str_replace('/', DIRECTORY_SEPARATOR, $path);
|
||||||
|
}, $expected);
|
||||||
|
|
||||||
sort($values);
|
sort($values);
|
||||||
sort($expected);
|
sort($expected);
|
||||||
|
@ -29,7 +33,9 @@ abstract class IteratorTestCase extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
protected function assertOrderedIterator($expected, \Traversable $iterator)
|
protected function assertOrderedIterator($expected, \Traversable $iterator)
|
||||||
{
|
{
|
||||||
$values = array_map(function (\SplFileInfo $fileinfo) { return $fileinfo->getPathname(); }, iterator_to_array($iterator));
|
$values = array_map(function (\SplFileInfo $fileinfo) {
|
||||||
|
return $fileinfo->getPathname();
|
||||||
|
}, iterator_to_array($iterator));
|
||||||
|
|
||||||
$this->assertEquals($expected, array_values($values));
|
$this->assertEquals($expected, array_values($values));
|
||||||
}
|
}
|
||||||
|
@ -46,7 +52,9 @@ abstract class IteratorTestCase extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
protected function assertOrderedIteratorForGroups($expected, \Traversable $iterator)
|
protected function assertOrderedIteratorForGroups($expected, \Traversable $iterator)
|
||||||
{
|
{
|
||||||
$values = array_values(array_map(function (\SplFileInfo $fileinfo) { return $fileinfo->getPathname(); }, iterator_to_array($iterator)));
|
$values = array_values(array_map(function (\SplFileInfo $fileinfo) {
|
||||||
|
return $fileinfo->getPathname();
|
||||||
|
}, iterator_to_array($iterator)));
|
||||||
|
|
||||||
foreach ($expected as $subarray) {
|
foreach ($expected as $subarray) {
|
||||||
$temp = array();
|
$temp = array();
|
||||||
|
|
|
@ -15,7 +15,9 @@ class MockFileListIterator extends \ArrayIterator
|
||||||
{
|
{
|
||||||
public function __construct(array $filesArray = array())
|
public function __construct(array $filesArray = array())
|
||||||
{
|
{
|
||||||
$files = array_map(function ($file) { return new MockSplFileInfo($file); }, $filesArray);
|
$files = array_map(function ($file) {
|
||||||
|
return new MockSplFileInfo($file);
|
||||||
|
}, $filesArray);
|
||||||
parent::__construct($files);
|
parent::__construct($files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,11 +96,13 @@ class MockSplFileInfo extends \SplFileInfo
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'directory':
|
case 'directory':
|
||||||
$this->type = self::TYPE_DIRECTORY;
|
$this->type = self::TYPE_DIRECTORY;
|
||||||
|
// no break
|
||||||
case 'd':
|
case 'd':
|
||||||
$this->type = self::TYPE_DIRECTORY;
|
$this->type = self::TYPE_DIRECTORY;
|
||||||
break;
|
break;
|
||||||
case 'file':
|
case 'file':
|
||||||
$this->type = self::TYPE_FILE;
|
$this->type = self::TYPE_FILE;
|
||||||
|
// no break
|
||||||
case 'f':
|
case 'f':
|
||||||
$this->type = self::TYPE_FILE;
|
$this->type = self::TYPE_FILE;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -163,7 +163,9 @@ class SortableIteratorTest extends RealIteratorTestCase
|
||||||
array(SortableIterator::SORT_BY_ACCESSED_TIME, $this->toAbsolute($sortByAccessedTime)),
|
array(SortableIterator::SORT_BY_ACCESSED_TIME, $this->toAbsolute($sortByAccessedTime)),
|
||||||
array(SortableIterator::SORT_BY_CHANGED_TIME, $this->toAbsolute($sortByChangedTime)),
|
array(SortableIterator::SORT_BY_CHANGED_TIME, $this->toAbsolute($sortByChangedTime)),
|
||||||
array(SortableIterator::SORT_BY_MODIFIED_TIME, $this->toAbsolute($sortByModifiedTime)),
|
array(SortableIterator::SORT_BY_MODIFIED_TIME, $this->toAbsolute($sortByModifiedTime)),
|
||||||
array(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealpath(), $b->getRealpath()); }, $this->toAbsolute($customComparison)),
|
array(function (\SplFileInfo $a, \SplFileInfo $b) {
|
||||||
|
return strcmp($a->getRealpath(), $b->getRealpath());
|
||||||
|
}, $this->toAbsolute($customComparison)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,9 @@ class File extends \SplFileInfo
|
||||||
{
|
{
|
||||||
$target = $this->getTargetFile($directory, $name);
|
$target = $this->getTargetFile($directory, $name);
|
||||||
|
|
||||||
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
|
set_error_handler(function ($type, $msg) use (&$error) {
|
||||||
|
$error = $msg;
|
||||||
|
});
|
||||||
$renamed = rename($this->getPathname(), $target);
|
$renamed = rename($this->getPathname(), $target);
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
if (!$renamed) {
|
if (!$renamed) {
|
||||||
|
|
|
@ -192,7 +192,9 @@ class UploadedFile extends File
|
||||||
|
|
||||||
$target = $this->getTargetFile($directory, $name);
|
$target = $this->getTargetFile($directory, $name);
|
||||||
|
|
||||||
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
|
set_error_handler(function ($type, $msg) use (&$error) {
|
||||||
|
$error = $msg;
|
||||||
|
});
|
||||||
$moved = move_uploaded_file($this->getPathname(), $target);
|
$moved = move_uploaded_file($this->getPathname(), $target);
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
if (!$moved) {
|
if (!$moved) {
|
||||||
|
|
|
@ -123,7 +123,9 @@ class JsonResponse extends Response
|
||||||
// PHP 5.3 triggers annoying warnings for some
|
// PHP 5.3 triggers annoying warnings for some
|
||||||
// types that can't be serialized as JSON (INF, resources, etc.)
|
// types that can't be serialized as JSON (INF, resources, etc.)
|
||||||
// but doesn't provide the JsonSerializable interface.
|
// but doesn't provide the JsonSerializable interface.
|
||||||
set_error_handler(function () { return false; });
|
set_error_handler(function () {
|
||||||
|
return false;
|
||||||
|
});
|
||||||
$data = @json_encode($data, $this->encodingOptions);
|
$data = @json_encode($data, $this->encodingOptions);
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
} elseif (\PHP_VERSION_ID < 50500) {
|
} elseif (\PHP_VERSION_ID < 50500) {
|
||||||
|
|
|
@ -96,7 +96,8 @@ class RedirectResponse extends Response
|
||||||
<body>
|
<body>
|
||||||
Redirecting to <a href="%1$s">%1$s</a>.
|
Redirecting to <a href="%1$s">%1$s</a>.
|
||||||
</body>
|
</body>
|
||||||
</html>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8')));
|
</html>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8'))
|
||||||
|
);
|
||||||
|
|
||||||
$this->headers->set('Location', $url);
|
$this->headers->set('Location', $url);
|
||||||
|
|
||||||
|
|
|
@ -218,13 +218,19 @@ class RequestTest extends TestCase
|
||||||
$this->assertEquals(array('foo' => ''), $request->query->all());
|
$this->assertEquals(array('foo' => ''), $request->query->all());
|
||||||
|
|
||||||
// assume rewrite rule: (.*) --> app/app.php; app/ is a symlink to a symfony web/ directory
|
// assume rewrite rule: (.*) --> app/app.php; app/ is a symlink to a symfony web/ directory
|
||||||
$request = Request::create('http://test.com/apparthotel-1234', 'GET', array(), array(), array(),
|
$request = Request::create(
|
||||||
|
'http://test.com/apparthotel-1234',
|
||||||
|
'GET',
|
||||||
|
array(),
|
||||||
|
array(),
|
||||||
|
array(),
|
||||||
array(
|
array(
|
||||||
'DOCUMENT_ROOT' => '/var/www/www.test.com',
|
'DOCUMENT_ROOT' => '/var/www/www.test.com',
|
||||||
'SCRIPT_FILENAME' => '/var/www/www.test.com/app/app.php',
|
'SCRIPT_FILENAME' => '/var/www/www.test.com/app/app.php',
|
||||||
'SCRIPT_NAME' => '/app/app.php',
|
'SCRIPT_NAME' => '/app/app.php',
|
||||||
'PHP_SELF' => '/app/app.php/apparthotel-1234',
|
'PHP_SELF' => '/app/app.php/apparthotel-1234',
|
||||||
));
|
)
|
||||||
|
);
|
||||||
$this->assertEquals('http://test.com/apparthotel-1234', $request->getUri());
|
$this->assertEquals('http://test.com/apparthotel-1234', $request->getUri());
|
||||||
$this->assertEquals('/apparthotel-1234', $request->getPathInfo());
|
$this->assertEquals('/apparthotel-1234', $request->getPathInfo());
|
||||||
$this->assertEquals('', $request->getQueryString());
|
$this->assertEquals('', $request->getQueryString());
|
||||||
|
|
|
@ -106,16 +106,20 @@ class AutoExpireFlashBagTest extends TestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->bag->initialize($array);
|
$this->bag->initialize($array);
|
||||||
$this->assertEquals(array(
|
$this->assertEquals(
|
||||||
|
array(
|
||||||
'notice' => 'Foo',
|
'notice' => 'Foo',
|
||||||
'error' => 'Bar',
|
'error' => 'Bar',
|
||||||
), $this->bag->peekAll()
|
),
|
||||||
|
$this->bag->peekAll()
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(array(
|
$this->assertEquals(
|
||||||
|
array(
|
||||||
'notice' => 'Foo',
|
'notice' => 'Foo',
|
||||||
'error' => 'Bar',
|
'error' => 'Bar',
|
||||||
), $this->bag->peekAll()
|
),
|
||||||
|
$this->bag->peekAll()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,9 +142,11 @@ class AutoExpireFlashBagTest extends TestCase
|
||||||
{
|
{
|
||||||
$this->bag->set('notice', 'Foo');
|
$this->bag->set('notice', 'Foo');
|
||||||
$this->bag->set('error', 'Bar');
|
$this->bag->set('error', 'Bar');
|
||||||
$this->assertEquals(array(
|
$this->assertEquals(
|
||||||
|
array(
|
||||||
'notice' => array('A previous flash message'),
|
'notice' => array('A previous flash message'),
|
||||||
), $this->bag->all()
|
),
|
||||||
|
$this->bag->all()
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(array(), $this->bag->all());
|
$this->assertEquals(array(), $this->bag->all());
|
||||||
|
|
|
@ -98,9 +98,11 @@ class FlashBagTest extends TestCase
|
||||||
{
|
{
|
||||||
$this->bag->set('notice', 'Foo');
|
$this->bag->set('notice', 'Foo');
|
||||||
$this->bag->set('error', 'Bar');
|
$this->bag->set('error', 'Bar');
|
||||||
$this->assertEquals(array(
|
$this->assertEquals(
|
||||||
|
array(
|
||||||
'notice' => array('Foo'),
|
'notice' => array('Foo'),
|
||||||
'error' => array('Bar'), ), $this->bag->all()
|
'error' => array('Bar'), ),
|
||||||
|
$this->bag->all()
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(array(), $this->bag->all());
|
$this->assertEquals(array(), $this->bag->all());
|
||||||
|
@ -141,17 +143,21 @@ class FlashBagTest extends TestCase
|
||||||
{
|
{
|
||||||
$this->bag->set('notice', 'Foo');
|
$this->bag->set('notice', 'Foo');
|
||||||
$this->bag->set('error', 'Bar');
|
$this->bag->set('error', 'Bar');
|
||||||
$this->assertEquals(array(
|
$this->assertEquals(
|
||||||
|
array(
|
||||||
'notice' => array('Foo'),
|
'notice' => array('Foo'),
|
||||||
'error' => array('Bar'),
|
'error' => array('Bar'),
|
||||||
), $this->bag->peekAll()
|
),
|
||||||
|
$this->bag->peekAll()
|
||||||
);
|
);
|
||||||
$this->assertTrue($this->bag->has('notice'));
|
$this->assertTrue($this->bag->has('notice'));
|
||||||
$this->assertTrue($this->bag->has('error'));
|
$this->assertTrue($this->bag->has('error'));
|
||||||
$this->assertEquals(array(
|
$this->assertEquals(
|
||||||
|
array(
|
||||||
'notice' => array('Foo'),
|
'notice' => array('Foo'),
|
||||||
'error' => array('Bar'),
|
'error' => array('Bar'),
|
||||||
), $this->bag->peekAll()
|
),
|
||||||
|
$this->bag->peekAll()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,9 @@ class StreamedResponseTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testConstructor()
|
public function testConstructor()
|
||||||
{
|
{
|
||||||
$response = new StreamedResponse(function () { echo 'foo'; }, 404, array('Content-Type' => 'text/plain'));
|
$response = new StreamedResponse(function () {
|
||||||
|
echo 'foo';
|
||||||
|
}, 404, array('Content-Type' => 'text/plain'));
|
||||||
|
|
||||||
$this->assertEquals(404, $response->getStatusCode());
|
$this->assertEquals(404, $response->getStatusCode());
|
||||||
$this->assertEquals('text/plain', $response->headers->get('Content-Type'));
|
$this->assertEquals('text/plain', $response->headers->get('Content-Type'));
|
||||||
|
@ -27,7 +29,9 @@ class StreamedResponseTest extends TestCase
|
||||||
|
|
||||||
public function testPrepareWith11Protocol()
|
public function testPrepareWith11Protocol()
|
||||||
{
|
{
|
||||||
$response = new StreamedResponse(function () { echo 'foo'; });
|
$response = new StreamedResponse(function () {
|
||||||
|
echo 'foo';
|
||||||
|
});
|
||||||
$request = Request::create('/');
|
$request = Request::create('/');
|
||||||
$request->server->set('SERVER_PROTOCOL', 'HTTP/1.1');
|
$request->server->set('SERVER_PROTOCOL', 'HTTP/1.1');
|
||||||
|
|
||||||
|
@ -39,7 +43,9 @@ class StreamedResponseTest extends TestCase
|
||||||
|
|
||||||
public function testPrepareWith10Protocol()
|
public function testPrepareWith10Protocol()
|
||||||
{
|
{
|
||||||
$response = new StreamedResponse(function () { echo 'foo'; });
|
$response = new StreamedResponse(function () {
|
||||||
|
echo 'foo';
|
||||||
|
});
|
||||||
$request = Request::create('/');
|
$request = Request::create('/');
|
||||||
$request->server->set('SERVER_PROTOCOL', 'HTTP/1.0');
|
$request->server->set('SERVER_PROTOCOL', 'HTTP/1.0');
|
||||||
|
|
||||||
|
@ -51,7 +57,9 @@ class StreamedResponseTest extends TestCase
|
||||||
|
|
||||||
public function testPrepareWithHeadRequest()
|
public function testPrepareWithHeadRequest()
|
||||||
{
|
{
|
||||||
$response = new StreamedResponse(function () { echo 'foo'; }, 200, array('Content-Length' => '123'));
|
$response = new StreamedResponse(function () {
|
||||||
|
echo 'foo';
|
||||||
|
}, 200, array('Content-Length' => '123'));
|
||||||
$request = Request::create('/', 'HEAD');
|
$request = Request::create('/', 'HEAD');
|
||||||
|
|
||||||
$response->prepare($request);
|
$response->prepare($request);
|
||||||
|
@ -61,7 +69,9 @@ class StreamedResponseTest extends TestCase
|
||||||
|
|
||||||
public function testPrepareWithCacheHeaders()
|
public function testPrepareWithCacheHeaders()
|
||||||
{
|
{
|
||||||
$response = new StreamedResponse(function () { echo 'foo'; }, 200, array('Cache-Control' => 'max-age=600, public'));
|
$response = new StreamedResponse(function () {
|
||||||
|
echo 'foo';
|
||||||
|
}, 200, array('Cache-Control' => 'max-age=600, public'));
|
||||||
$request = Request::create('/', 'GET');
|
$request = Request::create('/', 'GET');
|
||||||
|
|
||||||
$response->prepare($request);
|
$response->prepare($request);
|
||||||
|
@ -72,7 +82,9 @@ class StreamedResponseTest extends TestCase
|
||||||
{
|
{
|
||||||
$called = 0;
|
$called = 0;
|
||||||
|
|
||||||
$response = new StreamedResponse(function () use (&$called) { ++$called; });
|
$response = new StreamedResponse(function () use (&$called) {
|
||||||
|
++$called;
|
||||||
|
});
|
||||||
|
|
||||||
$response->sendContent();
|
$response->sendContent();
|
||||||
$this->assertEquals(1, $called);
|
$this->assertEquals(1, $called);
|
||||||
|
@ -104,19 +116,24 @@ class StreamedResponseTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testSetContent()
|
public function testSetContent()
|
||||||
{
|
{
|
||||||
$response = new StreamedResponse(function () { echo 'foo'; });
|
$response = new StreamedResponse(function () {
|
||||||
|
echo 'foo';
|
||||||
|
});
|
||||||
$response->setContent('foo');
|
$response->setContent('foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetContent()
|
public function testGetContent()
|
||||||
{
|
{
|
||||||
$response = new StreamedResponse(function () { echo 'foo'; });
|
$response = new StreamedResponse(function () {
|
||||||
|
echo 'foo';
|
||||||
|
});
|
||||||
$this->assertFalse($response->getContent());
|
$this->assertFalse($response->getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreate()
|
public function testCreate()
|
||||||
{
|
{
|
||||||
$response = StreamedResponse::create(function () {}, 204);
|
$response = StreamedResponse::create(function () {
|
||||||
|
}, 204);
|
||||||
|
|
||||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response);
|
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response);
|
||||||
$this->assertEquals(204, $response->getStatusCode());
|
$this->assertEquals(204, $response->getStatusCode());
|
||||||
|
@ -124,18 +141,22 @@ class StreamedResponseTest extends TestCase
|
||||||
|
|
||||||
public function testReturnThis()
|
public function testReturnThis()
|
||||||
{
|
{
|
||||||
$response = new StreamedResponse(function () {});
|
$response = new StreamedResponse(function () {
|
||||||
|
});
|
||||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendContent());
|
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendContent());
|
||||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendContent());
|
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendContent());
|
||||||
|
|
||||||
$response = new StreamedResponse(function () {});
|
$response = new StreamedResponse(function () {
|
||||||
|
});
|
||||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendHeaders());
|
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendHeaders());
|
||||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendHeaders());
|
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendHeaders());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetNotModified()
|
public function testSetNotModified()
|
||||||
{
|
{
|
||||||
$response = new StreamedResponse(function () { echo 'foo'; });
|
$response = new StreamedResponse(function () {
|
||||||
|
echo 'foo';
|
||||||
|
});
|
||||||
$modified = $response->setNotModified();
|
$modified = $response->setNotModified();
|
||||||
$this->assertObjectHasAttribute('headers', $modified);
|
$this->assertObjectHasAttribute('headers', $modified);
|
||||||
$this->assertObjectHasAttribute('content', $modified);
|
$this->assertObjectHasAttribute('content', $modified);
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue