mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 21:43:18 +00:00
Merge
This commit is contained in:
19
bin/doctrine
19
bin/doctrine
@@ -35,12 +35,25 @@ try
|
||||
);
|
||||
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
|
||||
|
||||
$doctrine = new Phrasea\Core\Service\Doctrine($configuration->getDoctrine()->all());
|
||||
$serviceName = $configuration->getOrm();
|
||||
$confService = $configuration->getService($serviceName);
|
||||
|
||||
$app = new Application("Phraseanet Doctrine Console", $doctrine->getVersion());
|
||||
if($confService->get("type") !== 'doctrine')
|
||||
{
|
||||
exit(sprintf("Doctrine is not declared as your ORM but %s is", $confService->get("type")));
|
||||
}
|
||||
|
||||
$ormService = \Alchemy\Phrasea\Core\ServiceBuilder::build(
|
||||
$serviceName
|
||||
, \Alchemy\Phrasea\Core\ServiceBuilder::ORM
|
||||
, $confService->get("type")
|
||||
, $confService->get("options")
|
||||
);
|
||||
|
||||
$em = $doctrine->getEntityManager();
|
||||
$em = $ormService->getService();
|
||||
/* @var $em \Doctrine\ORM\EntityManager */
|
||||
|
||||
$app = new Application("Phraseanet Doctrine Console", $ormService->getVersion());
|
||||
|
||||
$helpers = array(
|
||||
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
environment : dev
|
||||
|
||||
#declare all your environment configuration
|
||||
#Declare all your environment configurations
|
||||
|
||||
#################
|
||||
# DEVELOPPEMENT #
|
||||
@@ -16,80 +16,15 @@ dev:
|
||||
maintenance: false
|
||||
debug: true
|
||||
display_errors: true
|
||||
#Configure your phraseanet application connection
|
||||
database:
|
||||
host: <YOUR_HOST>
|
||||
port: <YOUR_PORT>
|
||||
dbname: <YOUR_DB_NAME>
|
||||
user: <YOUR_USERNAME>
|
||||
password: <YOUR_PASSWORD>
|
||||
|
||||
# Doctrine scope refers to Doctrine configuration
|
||||
# Pls refer to Doctrine documentation abstraction layer for database connection configuration
|
||||
# DBAL connection : http://www.doctrine-project.org/docs/dbal/2.1/en/reference/configuration.html
|
||||
doctrine:
|
||||
#configure the doctrine database connection
|
||||
dbal:
|
||||
driver: <YOUR_DRIVER>
|
||||
host: <YOUR_HOST>
|
||||
port: <YOUR_PORT>
|
||||
dbname: <YOUR_DB_NAME>
|
||||
user: <YOUR_USERNAME>
|
||||
password: <YOUR_PASSWORD>
|
||||
charset: UTF8
|
||||
#configure orm
|
||||
orm:
|
||||
#Available cache driver [memcached, apc, array]
|
||||
#Query cache : is used to cache the transformation of a DQL query to its SQL counterpart
|
||||
#Result cache : is used to cache the results of your queries
|
||||
#Metadata cache : is used to cache entity class metadatas
|
||||
cache:
|
||||
query: array
|
||||
result: array
|
||||
metadata: array
|
||||
#Assign your phraseanet application connection
|
||||
#Connections are defined in connexions.yml configuration file
|
||||
database: main_connexion
|
||||
|
||||
#Configure how to log SQL query
|
||||
#Available type values [echo , monolog]
|
||||
# echo : logs to the standard output using echo/var_dump.
|
||||
# monolog : logs with monolog service using different log handler
|
||||
log:
|
||||
#Active logs
|
||||
enable: false
|
||||
#Define how logs are handling
|
||||
#Available type values [echo , monolog]
|
||||
# echo : logs to the standard output using echo/var_dump.
|
||||
# monolog : logs with monolog service using different log handler
|
||||
type: monolog
|
||||
#Define which handler to use see monolog configuration scope
|
||||
handler: rotate
|
||||
#Define output of logs
|
||||
#Available output [normal, json, yaml]
|
||||
# normal : output logs in a var_dump formatted style
|
||||
# json : output logs in json
|
||||
# yml : output logs yml
|
||||
output: json
|
||||
#Define the logs filename
|
||||
filename: dev-doctrine-query.log
|
||||
#Define how many day of logs is keeping. Override default value
|
||||
max_day: 2
|
||||
|
||||
# Monolog Service Configuration
|
||||
# Handlers type [stream, rotatingFile]
|
||||
# stream : store logs to a single file
|
||||
# rotatingFile: logs to files that are rotated every day and a limited number of files are kept
|
||||
monolog:
|
||||
#Define default ouput
|
||||
output: yaml
|
||||
#Define handlers
|
||||
#Only stream & rotating file are currently available
|
||||
handlers:
|
||||
main:
|
||||
type: stream
|
||||
#Rotate handler is used to rotate logs every day in a new file
|
||||
#max_day is used to keep the defined number of day logs
|
||||
rotate:
|
||||
type: rotatingFile
|
||||
max_day: 10
|
||||
#Assign your template engine service & ORM service
|
||||
#Services are defined in service.yml configuration file
|
||||
template_engine: twig_debug
|
||||
orm: doctrine_dev
|
||||
|
||||
##############
|
||||
# PRODUCTION #
|
||||
@@ -100,42 +35,10 @@ prod:
|
||||
maintenance: false
|
||||
debug: false
|
||||
display_errors: false
|
||||
database:
|
||||
host: <YOUR_HOST>
|
||||
port: <YOUR_PORT>
|
||||
dbname: <YOUR_DB_NAME>
|
||||
user: <YOUR_USERNAME>
|
||||
password: <YOUR_USERNAME>
|
||||
database: main_connexion
|
||||
|
||||
doctrine:
|
||||
dbal:
|
||||
driver: <YOUR_DRIVER>
|
||||
host: <YOUR_HOST>
|
||||
port: <YOUR_PORT>
|
||||
dbname: <YOUR_DB_NAME>
|
||||
user: <YOUR_USERNAME>
|
||||
password: <YOUR_PASSWORD>
|
||||
charset: UTF8
|
||||
orm:
|
||||
cache:
|
||||
query: apc
|
||||
result: apc
|
||||
metadata: apc
|
||||
log:
|
||||
enable: true
|
||||
type: monolog
|
||||
handler: rotate
|
||||
output: json
|
||||
filename: prod-doctrine-query.log
|
||||
|
||||
monolog:
|
||||
output: yaml
|
||||
handlers:
|
||||
main:
|
||||
type: stream
|
||||
rotate:
|
||||
type: rotatingFile
|
||||
max_day: 10
|
||||
template_engine: twig
|
||||
orm: doctrine_prod
|
||||
|
||||
##############
|
||||
# TEST #
|
||||
@@ -146,37 +49,9 @@ test:
|
||||
maintenance: false
|
||||
debug: true
|
||||
display_errors: true
|
||||
database:
|
||||
host: <YOUR_HOST>
|
||||
port: <YOUR_PORT>
|
||||
dbname: <YOUR_DB_NAME>
|
||||
user: <YOUR_USERNAME>
|
||||
password: <YOUR_USERNAME>
|
||||
#doctrine use a sqlite base to run tests
|
||||
doctrine:
|
||||
dbal:
|
||||
driver: pdo_sqlite
|
||||
path: <PATH_TO_A_SQLITE_DB>
|
||||
charset: UTF8
|
||||
orm:
|
||||
cache:
|
||||
query: array
|
||||
result: array
|
||||
metadata: array
|
||||
log:
|
||||
enable: true
|
||||
type: monolog
|
||||
handler: rotate
|
||||
output: json
|
||||
filename: test-doctrine-query.log
|
||||
monolog:
|
||||
output: yaml
|
||||
handlers:
|
||||
main:
|
||||
type: stream
|
||||
rotate:
|
||||
type: rotatingFile
|
||||
max_day: 10
|
||||
|
||||
database: main_connexion
|
||||
|
||||
template_engine: twig_debug
|
||||
orm: doctrine_dev
|
||||
|
||||
|
19
config/connexions.sample.yml
Normal file
19
config/connexions.sample.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
#Here you can define many connexions configurations
|
||||
#Please refer to Doctrine documentation abstraction layer for database connection configuration
|
||||
#DBAL connection : http://www.doctrine-project.org/docs/dbal/2.1/en/reference/configuration.html
|
||||
|
||||
#Define a connexion to MYSQL database named main_connexion
|
||||
main_connexion:
|
||||
host: <HOSTNAME>
|
||||
port: <PORT>
|
||||
user: <USERNAME>
|
||||
password: <PASSWORD>
|
||||
dbname: <DATABASE_NAME>
|
||||
driver: pdo_mysql
|
||||
charset: UTF8
|
||||
|
||||
#Define a connexion to a SQLite database named test_connexion
|
||||
test_connexion:
|
||||
driver: pdo_sqlite
|
||||
path: /PATH/TO/SQLITE/DATABASE
|
||||
charset: UTF8
|
@@ -1,7 +0,0 @@
|
||||
#Twig services options
|
||||
twig:
|
||||
options:
|
||||
charset: utf-8
|
||||
strict_variables: true
|
||||
autoescape: true
|
||||
optimizer: true
|
113
config/services.sample.yml
Normal file
113
config/services.sample.yml
Normal file
@@ -0,0 +1,113 @@
|
||||
#Define a template engine service
|
||||
#Only Twig is avalaible as a template engine service
|
||||
#see http://twig.sensiolabs.org/
|
||||
|
||||
#Define the service name first
|
||||
twig:
|
||||
#Template engine type
|
||||
type: twig
|
||||
options:
|
||||
#When set to true, the generated templates have a __toString() method that you can use to display the generated nodes
|
||||
debug: false
|
||||
#The charset used by the templates
|
||||
charset: utf-8
|
||||
#Twig will silently ignore invalid variables (variables and or attributes/methods that do not exist)
|
||||
#And replace them with a null value. When set to true, Twig throws an exception instead (default to false)
|
||||
strict_variables: true
|
||||
#Escaper adds automatic output escaping to Twig. It defines a new tag, autoescape, and a new filter, raw
|
||||
autoescape: true
|
||||
#Optimize the node tree before compilation
|
||||
optimizer: true
|
||||
|
||||
twig_debug:
|
||||
type: twig
|
||||
options:
|
||||
debug: true
|
||||
charset: utf-8
|
||||
strict_variables: true
|
||||
autoescape: true
|
||||
optimizer: true
|
||||
|
||||
#Doctrine developement service options
|
||||
#Service name
|
||||
doctrine_dev:
|
||||
type: doctrine
|
||||
options:
|
||||
#Set automatically propers values for debug
|
||||
#Query & result caches are setted to Array cache
|
||||
#Auto-generating Proxy Classes is setted to false
|
||||
debug: true
|
||||
#Assign a connexion from connexions.yml to the DataBase Abstraction Layer
|
||||
dbal: main_connexion
|
||||
orm:
|
||||
#Available cache driver [memcached, apc, array]
|
||||
#Query cache : is used to cache the transformation of a DQL query to its SQL counterpart
|
||||
#Result cache : is used to cache the results of your queries
|
||||
#Metadata cache : is used to cache entity class metadatas
|
||||
cache:
|
||||
query: array
|
||||
result: array
|
||||
metadata: array
|
||||
# Assign a service to log doctrine queries
|
||||
log: query_logger
|
||||
|
||||
# Doctrine test service options
|
||||
doctrine_test:
|
||||
type: doctrine
|
||||
options:
|
||||
debug: true
|
||||
#Doctrine use a different connection configuration base to run tests
|
||||
dbal: test_connexion
|
||||
orm:
|
||||
cache:
|
||||
query: array
|
||||
result: array
|
||||
metadata: array
|
||||
log: query_logger
|
||||
|
||||
# Doctrine production service options
|
||||
doctrine_prod:
|
||||
type: doctrine
|
||||
options:
|
||||
debug: false
|
||||
dbal: main_connexion
|
||||
orm:
|
||||
cache:
|
||||
query: apc
|
||||
result: apc
|
||||
metadata: apc
|
||||
log: query_logger
|
||||
|
||||
|
||||
# Define a Log service
|
||||
# This one is defined to handle the logs of doctrine queries
|
||||
# Only Monolog is available as a logger service
|
||||
# Please Notice that for doctrine ONLY a echo logger service is available, see below
|
||||
# Monolog logger use the PHP Monolog library to handle logs using differents handlers
|
||||
query_logger:
|
||||
type: monolog
|
||||
options:
|
||||
#You can precise the output format
|
||||
#This option is only available when log are used to log doctrine queries
|
||||
#Available output [normal, json, yaml]
|
||||
# normal : output logs in a var_dump formatted style
|
||||
# json : output logs in json
|
||||
# yml : output logs yml
|
||||
output: json
|
||||
#Name used for the Monolog channel
|
||||
channel: query-logger
|
||||
#Define how the logs will be handled
|
||||
#Avalaibale Handler are [rotate, stream]
|
||||
#Rotate handler is used to stores logs to files that are rotated every day
|
||||
#And a limited number of files are kept by defining the max_day value
|
||||
#Stream handler is used to stores logs in a single local file
|
||||
handler: rotate
|
||||
max_day: 2
|
||||
#Name of the file where logs are written
|
||||
filename: doctrine-query.log
|
||||
|
||||
# Define a echo log service for Doctrine
|
||||
# echo logger logs doctrine queries to the standard output using echo/var_dump
|
||||
# Notice that echo logger do not have options
|
||||
sql_logger:
|
||||
type: echo
|
@@ -46,39 +46,99 @@ return call_user_func(function()
|
||||
}
|
||||
elseif (\setup::needUpgradeConfigurationFile())
|
||||
{
|
||||
//copy sample
|
||||
$file = __DIR__ . "/../../../../config/config.sample.yml";
|
||||
$file1 = __DIR__ . "/../../../../config/config.yml";
|
||||
if (!copy($file, $file1))
|
||||
$registry = \registry::get_instance();
|
||||
|
||||
//copy config sample
|
||||
$configSampleFile = __DIR__ . "/../../../../config/config.sample.yml";
|
||||
$configFile = __DIR__ . "/../../../../config/config.yml";
|
||||
|
||||
if (!copy($configSampleFile, $configFile))
|
||||
{
|
||||
throw new \Exception(sprintf("Unable to copy %s", $file1));
|
||||
throw new \Exception(sprintf("Unable to copy %s", $configSampleFile));
|
||||
}
|
||||
|
||||
//get connexion credentials
|
||||
$conn = \connection::getPDOConnection();
|
||||
$credentials = $conn->get_credentials();
|
||||
//copy service sample
|
||||
$serviceSampleFile = __DIR__ . "/../../../../config/services.sample.yml";
|
||||
$serviceFile = __DIR__ . "/../../../../config/services.yml";
|
||||
|
||||
if (!copy($serviceSampleFile, $serviceFile))
|
||||
{
|
||||
throw new \Exception(sprintf("Unable to copy %s", $serviceSampleFile));
|
||||
}
|
||||
|
||||
//copy connexion sample
|
||||
$connexionSampleFile = __DIR__ . "/../../../../config/connexions.sample.yml";
|
||||
$connexionFile = __DIR__ . "/../../../../config/connexions.yml";
|
||||
|
||||
if (!copy($connexionSampleFile, $connexionFile))
|
||||
{
|
||||
throw new \Exception(sprintf("Unable to copy %s", $connexionFile));
|
||||
}
|
||||
|
||||
//get configuration object
|
||||
$app = new \Alchemy\Phrasea\Core\Configuration\Application();
|
||||
$appConf = new \Alchemy\Phrasea\Core\Configuration\Application();
|
||||
$parser = new \Alchemy\Phrasea\Core\Configuration\Parser\Yaml();
|
||||
$handler = new \Alchemy\Phrasea\Core\Configuration\Handler($app, $parser);
|
||||
$handler = new \Alchemy\Phrasea\Core\Configuration\Handler($appConf, $parser);
|
||||
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
|
||||
|
||||
//refactor credentials
|
||||
$connexionINI = array();
|
||||
foreach ($credentials as $key => $value)
|
||||
{
|
||||
$key = $key == 'hostname' ? 'host' : $key;
|
||||
$connexionINI[$key] = (string) $value;
|
||||
}
|
||||
//write credentials to config file
|
||||
$configuration->setAllDatabaseConnexion($connexionINI);
|
||||
|
||||
require __DIR__ . "/../../../../config/connexion.inc";
|
||||
|
||||
$connexionINI['host'] = $hostname;
|
||||
$connexionINI['port'] = $port;
|
||||
$connexionINI['user'] = $user;
|
||||
$connexionINI['password'] = $password;
|
||||
$connexionINI['dbname'] = $dbname;
|
||||
$connexionINI['driver'] = 'pdo_mysql';
|
||||
$connexionINI['charset'] = 'UTF8';
|
||||
|
||||
$request = $app["request"];
|
||||
//write servername
|
||||
$serverName = $request->getScheme() . '://' . $request->getHttpHost() . '/';
|
||||
$configuration->setServerName($serverName);
|
||||
|
||||
$app->redirect("/");
|
||||
//write credentials to connexion file
|
||||
$connexionFile = $appConf->getConnexionFile();
|
||||
|
||||
$connexion = array(
|
||||
'main_connexion' => $connexionINI,
|
||||
'test_connexion' => array(
|
||||
'driver' => 'pdo_sqlite',
|
||||
'path' => $registry->get("GV_RootPath") . 'lib/unitTest/tests.sqlite',
|
||||
'charset' => 'UTF8'
|
||||
));
|
||||
|
||||
$yaml = $configuration->getConfigurationHandler()->getParser()->dump($connexion, 2);
|
||||
|
||||
if (!file_put_contents($connexionFile->getPathname(), $yaml) !== false)
|
||||
{
|
||||
throw new \Exception(sprintf(_('Impossible d\'ecrire dans le fichier %s'), $connexionFile->getPathname()));
|
||||
}
|
||||
|
||||
//rewrite service file
|
||||
$serviceFile = $appConf->getServiceFile();
|
||||
$service = $configuration->getConfigurationHandler()->getParser()->parse($serviceFile);
|
||||
$yaml = $configuration->getConfigurationHandler()->getParser()->dump($service, 5);
|
||||
|
||||
if (!file_put_contents($serviceFile->getPathname(), $yaml) !== false)
|
||||
{
|
||||
throw new \Exception(sprintf(_('Impossible d\'ecrire dans le fichier %s'), $serviceFile->getPathname()));
|
||||
}
|
||||
$arrayConf = $configuration->all();
|
||||
|
||||
//rewrite main conf
|
||||
foreach ($arrayConf as $key => $value)
|
||||
{
|
||||
if (is_array($value) && array_key_exists('phraseanet', $value))
|
||||
{
|
||||
$arrayConf[$key]["phraseanet"]["servername"] = $serverName;
|
||||
}
|
||||
}
|
||||
|
||||
$configuration->write($arrayConf);
|
||||
|
||||
$app->redirect("/setup/installer/");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -98,10 +98,9 @@ class Installer implements ControllerProviderInterface
|
||||
\phrasea::use_i18n(\Session_Handler::get_locale());
|
||||
|
||||
$ld_path = array(__DIR__ . '/../../../../../templates/web');
|
||||
|
||||
$loader = new \Twig_Loader_Filesystem($ld_path);
|
||||
$twig = new \Twig_Environment($loader);
|
||||
|
||||
$twig = new \Twig_Environment($loader);
|
||||
$twig->addExtension(new \Twig_Extensions_Extension_I18n());
|
||||
|
||||
$request = $app['request'];
|
||||
@@ -180,15 +179,25 @@ class Installer implements ControllerProviderInterface
|
||||
new \Alchemy\Phrasea\Core\Configuration\Parser\Yaml()
|
||||
);
|
||||
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
|
||||
|
||||
if ($configuration->isInstalled())
|
||||
{
|
||||
// Get Entity Manager using the new configuration
|
||||
$doctrineConf = $configuration->getDoctrine()->all();
|
||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Doctrine($doctrineConf);
|
||||
$serviceName = $configuration->getOrm();
|
||||
$confService = $configuration->getService($serviceName);
|
||||
|
||||
$em = $doctrine->getEntityManager();
|
||||
$ormService = \Alchemy\Phrasea\Core\ServiceBuilder::build(
|
||||
$serviceName
|
||||
, \Alchemy\Phrasea\Core\ServiceBuilder::ORM
|
||||
, $confService->get("type")
|
||||
, $confService->get("options")
|
||||
);
|
||||
|
||||
if ($ormService->getType() === 'doctrine')
|
||||
{
|
||||
/* @var $em \Doctrine\ORM\EntityManager */
|
||||
|
||||
$em = $ormService->getService();
|
||||
|
||||
$metadatas = $em->getMetadataFactory()->getAllMetadata();
|
||||
|
||||
if (!empty($metadatas))
|
||||
@@ -199,6 +208,7 @@ class Installer implements ControllerProviderInterface
|
||||
$tool->createSchema($metadatas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$registry = \registry::get_instance();
|
||||
\setup::create_global_values($registry);
|
||||
|
@@ -50,13 +50,11 @@ class Core extends \Pimple
|
||||
static::initAutoloads();
|
||||
|
||||
|
||||
$handler = new \Alchemy\Phrasea\Core\Configuration\Handler(
|
||||
new \Alchemy\Phrasea\Core\Configuration\Application(),
|
||||
new \Alchemy\Phrasea\Core\Configuration\Parser\Yaml()
|
||||
$handler = new Core\Configuration\Handler(
|
||||
new Core\Configuration\Application(),
|
||||
new Core\Configuration\Parser\Yaml()
|
||||
);
|
||||
$this->configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
|
||||
|
||||
$this->configuration->setEnvironnement($environement);
|
||||
$this->configuration = new Core\Configuration($handler, $environement);
|
||||
|
||||
/**
|
||||
* Set version
|
||||
@@ -66,21 +64,35 @@ class Core extends \Pimple
|
||||
return new Core\Version();
|
||||
});
|
||||
|
||||
$core = $this;
|
||||
|
||||
/**
|
||||
* Set Entity Manager using configuration
|
||||
*/
|
||||
$doctrineConf = $this->configuration->getDoctrine()->all();
|
||||
$this['EM'] = $this->share(function() use ($doctrineConf)
|
||||
$this['EM'] = $this->share(function() use ($core)
|
||||
{
|
||||
$doctrine = new Core\Service\Doctrine($doctrineConf);
|
||||
return $doctrine->getEntityManager();
|
||||
$serviceName = $core->getConfiguration()->getOrm();
|
||||
|
||||
$service = $core->getService(
|
||||
$serviceName
|
||||
, Core\ServiceBuilder::ORM
|
||||
);
|
||||
|
||||
return $service->getService();
|
||||
});
|
||||
|
||||
$twigConf = $this->configuration->getServices()->get('twig');
|
||||
$this["Twig"] = $this->share(function() use ($twigConf)
|
||||
|
||||
|
||||
$this["Twig"] = $this->share(function() use ($core)
|
||||
{
|
||||
$twig = new Core\Service\Twig($twigConf);
|
||||
return $twig->getTwig();
|
||||
$serviceName = $core->getConfiguration()->getTemplating();
|
||||
|
||||
$service = $core->getService(
|
||||
$serviceName
|
||||
, Core\ServiceBuilder::TEMPLATE_ENGINE
|
||||
);
|
||||
|
||||
return $service->getService();
|
||||
});
|
||||
|
||||
if (\setup::is_installed())
|
||||
@@ -149,11 +161,9 @@ class Core extends \Pimple
|
||||
*
|
||||
* @param type $environnement
|
||||
*/
|
||||
private function init($environnement)
|
||||
private function init()
|
||||
{
|
||||
$this->loadConf($environnement);
|
||||
|
||||
if ($this->getConfiguration()->displayErrors())
|
||||
if ($this->getConfiguration()->isDisplayingErrors())
|
||||
{
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
@@ -375,7 +385,6 @@ class Core extends \Pimple
|
||||
public static function initAutoloads()
|
||||
{
|
||||
require_once __DIR__ . '/../../vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
|
||||
|
||||
require_once __DIR__ . '/../../vendor/Twig/lib/Twig/Autoloader.php';
|
||||
require_once __DIR__ . '/../../vendor/Twig-extensions/lib/Twig/Extensions/Autoloader.php';
|
||||
|
||||
@@ -388,13 +397,11 @@ class Core extends \Pimple
|
||||
|
||||
$loader->registerNamespaces(array(
|
||||
'Alchemy' => __DIR__ . '/../..',
|
||||
'Symfony\\Component\\Yaml' => realpath(__DIR__ . '/../../vendor/symfony/src'),
|
||||
'Symfony\\Component\\Console' => realpath(__DIR__ . '/../../vendor/symfony/src'),
|
||||
'Symfony\\Component\\Serializer' => realpath(__DIR__ . '/../../vendor/symfony/src'),
|
||||
'Symfony\\Component\\DependencyInjection' => realpath(__DIR__ . '/../../vendor/symfony/src'),
|
||||
'Symfony' => realpath(__DIR__ . '/../../vendor/symfony/src'),
|
||||
'Doctrine\\ORM' => realpath(__DIR__ . '/../../vendor/doctrine2-orm/lib'),
|
||||
'Doctrine\\DBAL' => realpath(__DIR__ . '/../../vendor/doctrine2-orm/lib/vendor/doctrine-dbal/lib'),
|
||||
'Doctrine\\Common' => realpath(__DIR__ . '/../../vendor/doctrine2-orm/lib/vendor/doctrine-common/lib'),
|
||||
'Doctrine\\Common\\DataFixtures' => realpath(__DIR__ . '/../../vendor/data-fixtures/lib'),
|
||||
'Entities' => realpath(__DIR__ . '/../../Doctrine/'),
|
||||
'Repositories' => realpath(__DIR__ . '/../../Doctrine/'),
|
||||
'Proxies' => realpath(__DIR__ . '/../../Doctrine/'),
|
||||
@@ -440,4 +447,16 @@ class Core extends \Pimple
|
||||
return $this->conf->getEnvironnement();
|
||||
}
|
||||
|
||||
public function getService($serviceName, $serviceScope)
|
||||
{
|
||||
$configuration = $this->configuration->getService($serviceName);
|
||||
|
||||
return Core\ServiceBuilder::build(
|
||||
$serviceName
|
||||
, $serviceScope
|
||||
, $configuration->get('type')
|
||||
, $configuration->get('options')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -47,10 +47,11 @@ class Configuration
|
||||
*
|
||||
* @param type $envName the name of the loaded environnement
|
||||
*/
|
||||
public function __construct(Configuration\Handler $handler)
|
||||
public function __construct(Configuration\Handler $handler, $environment = null)
|
||||
{
|
||||
$this->configurationHandler = $handler;
|
||||
$this->installed = false;
|
||||
$this->environment = $environment;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -89,7 +90,7 @@ class Configuration
|
||||
*/
|
||||
public function getEnvironnement()
|
||||
{
|
||||
if( null === $this->environment)
|
||||
if (null === $this->environment && $this->isInstalled())
|
||||
{
|
||||
$this->getConfiguration();
|
||||
}
|
||||
@@ -106,37 +107,6 @@ class Configuration
|
||||
$this->environment = $environement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the DBAL Doctrine configuration
|
||||
*
|
||||
* @return ParameterBag
|
||||
*/
|
||||
public function getDoctrine()
|
||||
{
|
||||
$doctrine = $this->getConfiguration()->get('doctrine', array()); //get doctrine scope
|
||||
|
||||
if (count($doctrine) > 0)
|
||||
{
|
||||
$doctrine["debug"] = $this->isDebug(); //set debug
|
||||
|
||||
if (!!$doctrine["log"]['enable'])
|
||||
{
|
||||
$logger = isset($doctrine["log"]["type"]) ? $doctrine["log"]["type"] : 'monolog';
|
||||
|
||||
if (!in_array($doctrine["log"]["type"], $this->getAvailableDoctrineLogger()))
|
||||
{
|
||||
throw new \Exception(sprintf('Unknow logger %s', $logger));
|
||||
}
|
||||
|
||||
$doctrineLogger = $this->getConfiguration()->get($logger); //set logger
|
||||
|
||||
$doctrine["logger"] = $doctrineLogger;
|
||||
}
|
||||
}
|
||||
|
||||
return new ParameterBag($doctrine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if current environnement is on debug mode
|
||||
* Default to false
|
||||
@@ -182,7 +152,7 @@ class Configuration
|
||||
* Default to false
|
||||
* @return boolean
|
||||
*/
|
||||
public function displayErrors()
|
||||
public function isDisplayingErrors()
|
||||
{
|
||||
$phraseanet = $this->getPhraseanet();
|
||||
|
||||
@@ -204,7 +174,7 @@ class Configuration
|
||||
*/
|
||||
public function getPhraseanet()
|
||||
{
|
||||
$phraseanetConf = $this->getConfiguration()->get('phraseanet', array());
|
||||
$phraseanetConf = $this->getConfiguration()->get('phraseanet');
|
||||
return new ParameterBag($phraseanetConf);
|
||||
}
|
||||
|
||||
@@ -227,13 +197,13 @@ class Configuration
|
||||
{
|
||||
if (null === $this->configuration)
|
||||
{
|
||||
$this->configuration = new Configuration\Parameter();
|
||||
$this->configuration = new ParameterBag();
|
||||
|
||||
if ($this->installed)
|
||||
{
|
||||
$configuration = $this->configurationHandler->handle($this->environment);
|
||||
$this->environment = $this->configurationHandler->getSelectedEnvironnment();
|
||||
$this->configuration = new Configuration\Parameter($configuration);
|
||||
$this->configuration = new ParameterBag($configuration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,9 +225,39 @@ class Configuration
|
||||
*
|
||||
* @return ParameterBag
|
||||
*/
|
||||
public function getConnexion()
|
||||
public function getConnexion($name = 'main_connexion')
|
||||
{
|
||||
return new ParameterBag($this->getPhraseanet()->get('database'));
|
||||
$connexions = $this->getConnexions();
|
||||
|
||||
try
|
||||
{
|
||||
$conn = $connexions->get($name);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
throw new \Exception(sprintf('Unknow connexion name %s declared in %s'
|
||||
, $name
|
||||
, $this->configurationHandler
|
||||
->getSpecification()
|
||||
->getConnexionFile()
|
||||
->getPathname()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return new Parameterbag($conn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all connexions defined in connexions.yml
|
||||
* @return ParameterBag
|
||||
*/
|
||||
public function getConnexions()
|
||||
{
|
||||
return new ParameterBag($this->configurationHandler->getParser()->parse(
|
||||
$this->configurationHandler->getSpecification()->getConnexionFile()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -282,96 +282,15 @@ class Configuration
|
||||
}
|
||||
|
||||
/**
|
||||
* Write into the main file connexion credentials defined in $connexion
|
||||
* @param array $connexion Array of connexion credentials
|
||||
* @return Configuration
|
||||
*/
|
||||
public function setAllDatabaseConnexion(Array $connexion)
|
||||
{
|
||||
$arrayConf = $this->all();
|
||||
|
||||
foreach ($arrayConf as $key => $value)
|
||||
{
|
||||
if (is_array($value) && array_key_exists('phraseanet', $value))
|
||||
{
|
||||
foreach ($arrayConf[$key]['phraseanet'] as $kee => $value)
|
||||
{
|
||||
if ($kee === 'database')
|
||||
{
|
||||
$arrayConf[$key]['phraseanet']['database'] = $connexion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$connexion["driver"] = 'pdo_mysql';
|
||||
$connexion['charset'] = 'UTF8';
|
||||
|
||||
foreach ($arrayConf as $key => $value)
|
||||
{
|
||||
if (is_array($value) && array_key_exists('phraseanet', $value))
|
||||
{
|
||||
foreach ($arrayConf[$key]['doctrine'] as $kee => $value)
|
||||
{
|
||||
if ($kee === 'dbal')
|
||||
{
|
||||
if ($key == 'test')
|
||||
{
|
||||
$arrayConf[$key]['doctrine']['dbal'] = $this->getTestDBCredentials();
|
||||
}
|
||||
else
|
||||
{
|
||||
$arrayConf[$key]['doctrine']['dbal'] = $connexion;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->write($arrayConf, FILE_APPEND, true);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all services defined in service.yml
|
||||
* Return all services defined in services.yml
|
||||
* @return ParameterBag
|
||||
*/
|
||||
public function getServices()
|
||||
{
|
||||
$serviceFile = $this->configurationHandler->getSpecification()->getServiceFile();
|
||||
$services = $this->configurationHandler->getParser()->parse($serviceFile);
|
||||
|
||||
return new ParameterBag($services);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write into the main file the serverName
|
||||
* @param type $serverName
|
||||
* @return Configuration
|
||||
*/
|
||||
public function setServerName($serverName)
|
||||
{
|
||||
$arrayConf = $this->all();
|
||||
|
||||
foreach ($arrayConf as $key => $value)
|
||||
{
|
||||
if (is_array($value) && array_key_exists('phraseanet', $value))
|
||||
{
|
||||
foreach ($arrayConf[$key]['phraseanet'] as $kee => $value)
|
||||
{
|
||||
if ($kee === 'servername')
|
||||
{
|
||||
$arrayConf[$key]['phraseanet']['servername'] = $serverName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->write($arrayConf, FILE_APPEND, true);
|
||||
|
||||
return $this;
|
||||
return new ParameterBag($this->configurationHandler->getParser()->parse(
|
||||
$this->getServiceFile()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -427,16 +346,97 @@ class Configuration
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the test database credentials
|
||||
* @return Array
|
||||
* Return configuration service for template_engine
|
||||
* @return string
|
||||
*/
|
||||
private function getTestDBCredentials()
|
||||
public function getTemplating()
|
||||
{
|
||||
return array(
|
||||
'driver' => 'pdo_sqlite',
|
||||
'path' => __DIR__ . '/../../../unitTest/tests.sqlite',
|
||||
'charset' => 'UTF8'
|
||||
return $this->getConfiguration()->get('template_engine');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return configuration service for orm
|
||||
* @return string
|
||||
*/
|
||||
public function getOrm()
|
||||
{
|
||||
return $this->getConfiguration()->get('orm');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the selected service configuration
|
||||
*
|
||||
* @param type $name
|
||||
* @return ParameterBag
|
||||
*/
|
||||
public function getService($name = 'twig')
|
||||
{
|
||||
$services = $this->getServices();
|
||||
|
||||
try
|
||||
{
|
||||
$template = $services->get($name);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
throw new \Exception(sprintf('Unknow service name %s declared in %s'
|
||||
, $name
|
||||
, $this->configurationHandler
|
||||
->getSpecification()
|
||||
->getServiceFile()
|
||||
->getPathname()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return new ParameterBag($template);
|
||||
}
|
||||
|
||||
/**
|
||||
* return the service file
|
||||
* @return \SplFileObject
|
||||
*/
|
||||
public function getServiceFile()
|
||||
{
|
||||
return $this->configurationHandler->getSpecification()->getServiceFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the connexion file
|
||||
* @return \SplFileObject
|
||||
*/
|
||||
public function getConnexionFile()
|
||||
{
|
||||
return $this->configurationHandler->getSpecification()->getConnexionFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the configuration
|
||||
* @return Configuration
|
||||
*/
|
||||
public function refresh()
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->configurationHandler->getSpecification()->getConfigurationFile();
|
||||
|
||||
$this->installed = true;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$this->installed = false;
|
||||
}
|
||||
|
||||
$this->configuration = new ParameterBag();
|
||||
|
||||
if ($this->installed)
|
||||
{
|
||||
$configuration = $this->configurationHandler->handle($this->environment);
|
||||
$this->environment = $this->configurationHandler->getSelectedEnvironnment();
|
||||
$this->configuration = new ParameterBag($configuration);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
@@ -97,7 +97,17 @@ class Application implements Specification
|
||||
*/
|
||||
public function getServiceFile()
|
||||
{
|
||||
return new \SplFileObject(__DIR__ . '/../../../../../config/service.yml');
|
||||
return new \SplFileObject(__DIR__ . '/../../../../../config/services.yml');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the main configuration file
|
||||
*
|
||||
* @return \SplFileObject
|
||||
*/
|
||||
public function getConnexionFile()
|
||||
{
|
||||
return new \SplFileObject(__DIR__ . '/../../../../../config/connexions.yml');
|
||||
}
|
||||
|
||||
}
|
||||
|
54
lib/Alchemy/Phrasea/Core/Service/Log/Doctrine/Monolog.php
Normal file
54
lib/Alchemy/Phrasea/Core/Service/Log/Doctrine/Monolog.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Service\Log\Doctrine;
|
||||
|
||||
use Alchemy\Phrasea\Core,
|
||||
Alchemy\Phrasea\Core\Service,
|
||||
Alchemy\Phrasea\Core\Service\ServiceAbstract,
|
||||
Alchemy\Phrasea\Core\Service\ServiceInterface;
|
||||
|
||||
use Alchemy\Phrasea\Core\Service\Log\Monolog as ParentLog;
|
||||
use Doctrine\Logger\MonologSQLLogger;
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Monolog extends ParentLog implements ServiceInterface
|
||||
{
|
||||
const JSON_OUTPUT = 'json';
|
||||
const YAML_OUTPUT = 'yaml';
|
||||
const VAR_DUMP_OUTPUT = 'normal';
|
||||
|
||||
protected $outputs = array(
|
||||
self::JSON_OUTPUT, self::YAML_OUTPUT, self::VAR_DUMP_OUTPUT
|
||||
);
|
||||
|
||||
public function getService()
|
||||
{
|
||||
$output = isset($this->options["output"]) ? $this->options["output"] : self::JSON_OUTPUT;
|
||||
|
||||
if (!in_array($output, $this->outputs))
|
||||
{
|
||||
throw new \Exception(sprintf('Unknow log output class %s', $output));
|
||||
}
|
||||
|
||||
return new MonologSQLLogger($this->monolog, $output);
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return 'doctrine_monolog';
|
||||
}
|
||||
|
||||
}
|
48
lib/Alchemy/Phrasea/Core/Service/Log/Doctrine/Normal.php
Normal file
48
lib/Alchemy/Phrasea/Core/Service/Log/Doctrine/Normal.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Service\Log\Doctrine;
|
||||
|
||||
use Alchemy\Phrasea\Core,
|
||||
Alchemy\Phrasea\Core\Service,
|
||||
Alchemy\Phrasea\Core\Service\ServiceAbstract,
|
||||
Alchemy\Phrasea\Core\Service\ServiceInterface;
|
||||
|
||||
use Doctrine\DBAL\Logging\EchoSQLLogger;
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Normal extends ServiceAbstract implements ServiceInterface
|
||||
{
|
||||
public function __construct($name, Array $options)
|
||||
{
|
||||
parent::__construct($name, $options);
|
||||
}
|
||||
|
||||
public function getService()
|
||||
{
|
||||
return new EchoSQLLogger();
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return 'echo';
|
||||
}
|
||||
|
||||
public function getScope()
|
||||
{
|
||||
return 'log';
|
||||
}
|
||||
|
||||
}
|
111
lib/Alchemy/Phrasea/Core/Service/Log/Monolog.php
Normal file
111
lib/Alchemy/Phrasea/Core/Service/Log/Monolog.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Service\Log;
|
||||
|
||||
use Alchemy\Phrasea\Core,
|
||||
Alchemy\Phrasea\Core\Service,
|
||||
Alchemy\Phrasea\Core\Service\ServiceAbstract,
|
||||
Alchemy\Phrasea\Core\Service\ServiceInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Monolog extends ServiceAbstract implements ServiceInterface
|
||||
{
|
||||
const DEFAULT_MAX_DAY = 10;
|
||||
|
||||
protected $handlers = array(
|
||||
'rotate' => 'RotatingFile'
|
||||
,'stream' => 'Stream'
|
||||
);
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \Monolog\Logger
|
||||
*/
|
||||
protected $monolog;
|
||||
|
||||
public function __construct($name, Array $options)
|
||||
{
|
||||
parent::__construct($name, $options);
|
||||
|
||||
//defaut to main handler
|
||||
$handler = isset($options["handler"]) ? $options["handler"] : false;
|
||||
|
||||
if (!$handler)
|
||||
{
|
||||
throw new \Exception("You must specify at least one monolog handler");
|
||||
}
|
||||
|
||||
if (!array_key_exists($handler, $this->handlers))
|
||||
{
|
||||
throw new \Exception(sprintf('Unknow monolog handler %s'), $handlerType);
|
||||
}
|
||||
|
||||
$handlerName = $this->handlers[$handler];
|
||||
|
||||
$handlerClassName = sprintf('\Monolog\Handler\%sHandler', $handlerName);
|
||||
|
||||
if (!class_exists($handlerClassName))
|
||||
{
|
||||
throw new \Exception(sprintf('Unknow monolog handler class %s', $handlerClassName));
|
||||
}
|
||||
|
||||
if (!isset($options["filename"]))
|
||||
{
|
||||
throw new \Exception('you must specify a file to write "filename: my_filename"');
|
||||
}
|
||||
|
||||
$logPath = __DIR__ . '/../../../../logs';
|
||||
|
||||
$file = sprintf('%s/%s', $logPath, $options["filename"]);
|
||||
|
||||
if ($handler == 'rotate')
|
||||
{
|
||||
$maxDay = isset($options["max_day"]) ? (int) $options["max_day"] : self::DEFAULT_MAX_DAY;
|
||||
|
||||
$handlerInstance = new $handlerClassName($file, $maxDay);
|
||||
}
|
||||
else
|
||||
{
|
||||
$handlerInstance = new $handlerClassName($file);
|
||||
}
|
||||
|
||||
$channel = isset($options["channel"]) ? $options["channel"] : false;
|
||||
|
||||
$monologLogger = new \Monolog\Logger($channel);
|
||||
|
||||
$monologLogger->pushHandler($handlerInstance);
|
||||
|
||||
$this->monolog = $monologLogger;
|
||||
}
|
||||
|
||||
public function getService()
|
||||
{
|
||||
return $this->monolog;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return 'monolog';
|
||||
}
|
||||
|
||||
public function getScope()
|
||||
{
|
||||
return 'log';
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,10 +9,15 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Service;
|
||||
namespace Alchemy\Phrasea\Core\Service\Orm;
|
||||
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Doctrine\Common\Cache\AbstractCache;
|
||||
use Alchemy\Phrasea\Core,
|
||||
Alchemy\Phrasea\Core\Service,
|
||||
Alchemy\Phrasea\Core\Service\ServiceAbstract,
|
||||
Alchemy\Phrasea\Core\Service\ServiceInterface;
|
||||
|
||||
use Doctrine\DBAL\Types\Type,
|
||||
Doctrine\Common\Cache\AbstractCache;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -20,38 +25,43 @@ use Doctrine\Common\Cache\AbstractCache;
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Doctrine
|
||||
class Doctrine extends ServiceAbstract implements ServiceInterface
|
||||
{
|
||||
const MEMCACHED = 'memcached';
|
||||
const ARRAYCACHE = 'array';
|
||||
const APC = 'apc';
|
||||
|
||||
protected $outputs = array(
|
||||
'json', 'yaml', 'normal'
|
||||
);
|
||||
protected $loggers = array(
|
||||
'monolog', 'echo'
|
||||
);
|
||||
protected $entityManager;
|
||||
|
||||
public function __construct(Array $doctrineConfiguration = array())
|
||||
public function __construct($name, Array $options = array())
|
||||
{
|
||||
require_once __DIR__ . '/../../../../vendor/doctrine2-orm/lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php';
|
||||
parent::__construct($name, $options);
|
||||
|
||||
static::loadClasses();
|
||||
|
||||
$config = new \Doctrine\ORM\Configuration();
|
||||
|
||||
$handler = new Core\Configuration\Handler(
|
||||
new Core\Configuration\Application(),
|
||||
new Core\Configuration\Parser\Yaml()
|
||||
);
|
||||
|
||||
$phraseaConfig = new Core\Configuration($handler);
|
||||
|
||||
/*
|
||||
* debug mode
|
||||
*/
|
||||
$debug = isset($doctrineConfiguration["debug"]) ? : false;
|
||||
$debug = isset($options["debug"]) ? : false;
|
||||
/*
|
||||
* doctrine cache
|
||||
*/
|
||||
$cache = isset($doctrineConfiguration["orm"]["cache"]) ? $doctrineConfiguration["orm"]["cache"] : false;
|
||||
/*
|
||||
* doctrine log configuration
|
||||
*/
|
||||
$log = isset($doctrineConfiguration["log"]) ? $doctrineConfiguration["log"] : false;
|
||||
/*
|
||||
* service logger configuration
|
||||
*/
|
||||
$logger = !isset($doctrineConfiguration['logger']) ? : $doctrineConfiguration['logger'];
|
||||
$cache = isset($options["orm"]["cache"]) ? $options["orm"]["cache"] : false;
|
||||
|
||||
/*
|
||||
* default query cache & meta chache
|
||||
@@ -59,10 +69,17 @@ class Doctrine
|
||||
$metaCache = $this->getCache();
|
||||
$queryCache = $this->getCache();
|
||||
|
||||
//Handle logs
|
||||
$logServiceName = isset($options["log"]) ? $options["log"] : false;
|
||||
|
||||
if ($logServiceName)
|
||||
{
|
||||
$serviceConf = $phraseaConfig->getService($logServiceName);
|
||||
$this->handleLogs($config, $logServiceName, $serviceConf->all());
|
||||
}
|
||||
|
||||
//handle cache
|
||||
$this->handleCache($metaCache, $queryCache, $cache, $debug);
|
||||
//Handle logs
|
||||
$this->handleLogs($config, $log, $logger);
|
||||
|
||||
//set caches
|
||||
$config->setMetadataCacheImpl($metaCache);
|
||||
@@ -74,7 +91,7 @@ class Doctrine
|
||||
$chainDriverImpl = new \Doctrine\ORM\Mapping\Driver\DriverChain();
|
||||
|
||||
$driverYaml = new \Doctrine\ORM\Mapping\Driver\YamlDriver(
|
||||
array(__DIR__ . '/../../../../conf.d/Doctrine')
|
||||
array(__DIR__ . '/../../../../../conf.d/Doctrine')
|
||||
);
|
||||
|
||||
$chainDriverImpl->addDriver($driverYaml, 'Entities');
|
||||
@@ -83,15 +100,24 @@ class Doctrine
|
||||
|
||||
$config->setMetadataDriverImpl($chainDriverImpl);
|
||||
|
||||
$config->setProxyDir(realpath(__DIR__ . '/../../../../Doctrine/Proxies'));
|
||||
$config->setProxyDir(realpath(__DIR__ . '/../../../../../Doctrine/Proxies'));
|
||||
|
||||
$config->setProxyNamespace('Proxies');
|
||||
|
||||
$dbalConf = isset($doctrineConfiguration["dbal"]) ? $doctrineConfiguration["dbal"] : false;
|
||||
$connexion = isset($options["dbal"]) ? $options["dbal"] : false;
|
||||
|
||||
if (!$dbalConf)
|
||||
if(!$connexion)
|
||||
{
|
||||
throw new \Exception("Unable to read dbal configuration");
|
||||
throw new \Exception("Missing dbal connexion for doctrine");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$dbalConf = $phraseaConfig->getConnexion($connexion)->all();
|
||||
}
|
||||
catch(\Exception $e)
|
||||
{
|
||||
throw new \Exception(sprintf("Unable to read %s configuration", $connexion));
|
||||
}
|
||||
|
||||
$evm = new \Doctrine\Common\EventManager();
|
||||
@@ -117,52 +143,54 @@ class Doctrine
|
||||
|
||||
protected static function loadClasses()
|
||||
{
|
||||
require_once __DIR__ . '/../../../../../vendor/doctrine2-orm/lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php';
|
||||
|
||||
|
||||
$classLoader = new \Doctrine\Common\ClassLoader(
|
||||
'Doctrine\ORM'
|
||||
, realpath(__DIR__ . '/../../../../vendor/doctrine2-orm/lib')
|
||||
, realpath(__DIR__ . '/../../../../../vendor/doctrine2-orm/lib')
|
||||
);
|
||||
$classLoader->register();
|
||||
|
||||
$classLoader = new \Doctrine\Common\ClassLoader(
|
||||
'Doctrine\DBAL'
|
||||
, realpath(__DIR__ . '/../../../../vendor/doctrine2-orm/lib/vendor/doctrine-dbal/lib')
|
||||
);
|
||||
$classLoader->register();
|
||||
|
||||
$classLoader = new \Doctrine\Common\ClassLoader(
|
||||
'Doctrine\Common\DataFixtures'
|
||||
, realpath(__DIR__ . '/../../../../vendor/data-fixtures/lib')
|
||||
);
|
||||
$classLoader->register();
|
||||
|
||||
$classLoader = new \Doctrine\Common\ClassLoader(
|
||||
'PhraseaFixture'
|
||||
, realpath(__DIR__ . '/../../../../conf.d/')
|
||||
, realpath(__DIR__ . '/../../../../../vendor/doctrine2-orm/lib/vendor/doctrine-dbal/lib')
|
||||
);
|
||||
$classLoader->register();
|
||||
|
||||
$classLoader = new \Doctrine\Common\ClassLoader(
|
||||
'Doctrine\Common'
|
||||
, realpath(__DIR__ . '/../../../../vendor/doctrine2-orm/lib/vendor/doctrine-common/lib')
|
||||
, realpath(__DIR__ . '/../../../../../vendor/doctrine2-orm/lib/vendor/doctrine-common/lib')
|
||||
);
|
||||
$classLoader->register();
|
||||
|
||||
$classLoader = new \Doctrine\Common\ClassLoader(
|
||||
'Doctrine\Common\DataFixtures'
|
||||
, realpath(__DIR__ . '/../../../../../vendor/data-fixtures/lib')
|
||||
);
|
||||
$classLoader->register();
|
||||
|
||||
$classLoader = new \Doctrine\Common\ClassLoader(
|
||||
'PhraseaFixture'
|
||||
, realpath(__DIR__ . '/../../../../../conf.d/')
|
||||
);
|
||||
$classLoader->register();
|
||||
|
||||
$classLoader = new \Doctrine\Common\ClassLoader(
|
||||
'Entities'
|
||||
, realpath(__DIR__ . '/../../../../Doctrine')
|
||||
, realpath(__DIR__ . '/../../../../../Doctrine')
|
||||
);
|
||||
$classLoader->register();
|
||||
|
||||
$classLoader = new \Doctrine\Common\ClassLoader(
|
||||
'Repositories'
|
||||
, realpath(__DIR__ . '/../../../../Doctrine')
|
||||
, realpath(__DIR__ . '/../../../../../Doctrine')
|
||||
);
|
||||
$classLoader->register();
|
||||
|
||||
$classLoader = new \Doctrine\Common\ClassLoader(
|
||||
'Proxies'
|
||||
, realpath(__DIR__ . '/../../../../Doctrine')
|
||||
, realpath(__DIR__ . '/../../../../../Doctrine')
|
||||
);
|
||||
$classLoader->register();
|
||||
|
||||
@@ -175,34 +203,34 @@ class Doctrine
|
||||
|
||||
$classLoader = new \Doctrine\Common\ClassLoader(
|
||||
'Doctrine\Logger'
|
||||
, realpath(__DIR__ . '/../../../../')
|
||||
, realpath(__DIR__ . '/../../../../../../../')
|
||||
);
|
||||
|
||||
$classLoader->register();
|
||||
|
||||
$classLoader = new \Doctrine\Common\ClassLoader(
|
||||
'Monolog'
|
||||
, realpath(__DIR__ . '/../../../../vendor/Silex/vendor/monolog/src')
|
||||
, realpath(__DIR__ . '/../../../../../vendor/Silex/vendor/monolog/src')
|
||||
);
|
||||
|
||||
$classLoader->register();
|
||||
|
||||
$classLoader = new \Doctrine\Common\ClassLoader(
|
||||
'Types'
|
||||
, realpath(__DIR__ . '/../../../../Doctrine')
|
||||
, realpath(__DIR__ . '/../../../../../Doctrine')
|
||||
);
|
||||
|
||||
$classLoader->register();
|
||||
|
||||
$classLoader = new \Doctrine\Common\ClassLoader(
|
||||
'Gedmo'
|
||||
, __DIR__ . "/../../../../vendor/doctrine2-gedmo/lib"
|
||||
, __DIR__ . "/../../../../../vendor/doctrine2-gedmo/lib"
|
||||
);
|
||||
$classLoader->register();
|
||||
|
||||
$classLoader = new \Doctrine\Common\ClassLoader(
|
||||
'DoctrineExtensions'
|
||||
, __DIR__ . "/../../../../vendor/doctrine2-beberlei/lib"
|
||||
, __DIR__ . "/../../../../../vendor/doctrine2-beberlei/lib"
|
||||
);
|
||||
$classLoader->register();
|
||||
|
||||
@@ -215,14 +243,25 @@ class Doctrine
|
||||
|
||||
$platform = $this->entityManager->getConnection()->getDatabasePlatform();
|
||||
|
||||
if(!Type::hasType('blob'))
|
||||
if (!Type::hasType('blob'))
|
||||
{
|
||||
Type::addType('blob', 'Types\Blob');
|
||||
if(!Type::hasType('enum'))
|
||||
}
|
||||
|
||||
if (!Type::hasType('enum'))
|
||||
{
|
||||
Type::addType('enum', 'Types\Enum');
|
||||
if(!Type::hasType('longblob'))
|
||||
}
|
||||
|
||||
if (!Type::hasType('longblob'))
|
||||
{
|
||||
Type::addType('longblob', 'Types\LongBlob');
|
||||
if(!Type::hasType('varbinary'))
|
||||
}
|
||||
|
||||
if (!Type::hasType('varbinary'))
|
||||
{
|
||||
Type::addType('varbinary', 'Types\VarBinary');
|
||||
}
|
||||
|
||||
$platform->registerDoctrineTypeMapping('enum', 'enum');
|
||||
$platform->registerDoctrineTypeMapping('blob', 'blob');
|
||||
@@ -285,99 +324,53 @@ class Doctrine
|
||||
* @param type $log
|
||||
* @param type $logger
|
||||
*/
|
||||
private function handleLogs(\Doctrine\ORM\Configuration &$config, $log, $logger)
|
||||
private function handleLogs(\Doctrine\ORM\Configuration &$config, $serviceName, Array $serviceConf)
|
||||
{
|
||||
$logEnable = isset($log["enable"]) ? !!$log["enable"] : false;
|
||||
$logType = $serviceConf['type'];
|
||||
$logService = null;
|
||||
|
||||
if ($logEnable)
|
||||
{
|
||||
$loggerService = isset($log["type"]) ? $log["type"] : '';
|
||||
|
||||
switch ($loggerService)
|
||||
switch ($logType)
|
||||
{
|
||||
case 'monolog':
|
||||
//defaut to main handler
|
||||
$doctrineHandler = isset($log["handler"]) ? $log["handler"] : 'main';
|
||||
|
||||
if (!isset($logger["handlers"]))
|
||||
{
|
||||
throw new \Exception("You must specify at least on monolog handler");
|
||||
}
|
||||
|
||||
if (!array_key_exists($doctrineHandler, $logger["handlers"]))
|
||||
{
|
||||
throw new \Exception(sprintf('Unknow monolog handler %s'), $handlerType);
|
||||
}
|
||||
|
||||
$handlerName = ucfirst($logger["handlers"][$doctrineHandler]["type"]);
|
||||
|
||||
$handlerClassName = sprintf('\Monolog\Handler\%sHandler', $handlerName);
|
||||
|
||||
if (!class_exists($handlerClassName))
|
||||
{
|
||||
throw new \Exception(sprintf('Unknow monolog handler class %s', $handlerClassName));
|
||||
}
|
||||
|
||||
if (!isset($log["filename"]))
|
||||
{
|
||||
throw new \Exception('you must specify a file to write "filename: my_filename"');
|
||||
}
|
||||
|
||||
$logPath = __DIR__ . '/../../../../../logs';
|
||||
$file = sprintf('%s/%s', $logPath, $log["filename"]);
|
||||
|
||||
if ($doctrineHandler == 'rotate')
|
||||
{
|
||||
$maxDay = isset($log["max_day"]) ? (int) $log["max_day"] : false;
|
||||
|
||||
if(!$maxDay && isset($logger["handlers"]['rotate']["max_day"]))
|
||||
{
|
||||
$maxDay = (int) $logger["handlers"]['rotate']["max_day"];
|
||||
}
|
||||
else
|
||||
{
|
||||
$maxDay = 10;
|
||||
}
|
||||
$handlerInstance = new $handlerClassName($file, $maxDay);
|
||||
}
|
||||
else
|
||||
{
|
||||
$handlerInstance = new $handlerClassName($file);
|
||||
}
|
||||
|
||||
$monologLogger = new \Monolog\Logger('query-logger');
|
||||
$monologLogger->pushHandler($handlerInstance);
|
||||
|
||||
if (isset($log["output"]))
|
||||
{
|
||||
$output = $log["output"];
|
||||
}
|
||||
elseif (isset($logger["output"]))
|
||||
{
|
||||
$output = $logger["output"];
|
||||
}
|
||||
else
|
||||
{
|
||||
$output = null;
|
||||
}
|
||||
|
||||
if (null === $output)
|
||||
{
|
||||
$sqlLogger = new \Doctrine\Logger\MonologSQLLogger($monologLogger);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sqlLogger = new \Doctrine\Logger\MonologSQLLogger($monologLogger, $output);
|
||||
}
|
||||
|
||||
$config->setSQLLogger($sqlLogger);
|
||||
$logService = Core\ServiceBuilder::build(
|
||||
$serviceName
|
||||
, Core\ServiceBuilder::LOG
|
||||
, $logType
|
||||
, $serviceConf['options']
|
||||
, 'doctrine'
|
||||
);
|
||||
break;
|
||||
case 'echo':
|
||||
default:
|
||||
$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
|
||||
$logService = Core\ServiceBuilder::build(
|
||||
$serviceName
|
||||
, Core\ServiceBuilder::LOG
|
||||
, 'normal'
|
||||
, array()
|
||||
, 'doctrine'
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($logService instanceof Alchemy\Phrasea\Core\Service\ServiceAbstract)
|
||||
{
|
||||
$config->setSQLLogger($logService->getService());
|
||||
}
|
||||
}
|
||||
|
||||
public function getService()
|
||||
{
|
||||
return $this->entityManager;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return 'doctrine';
|
||||
}
|
||||
|
||||
public function getScope()
|
||||
{
|
||||
return 'orm';
|
||||
}
|
||||
|
||||
}
|
58
lib/Alchemy/Phrasea/Core/Service/ServiceAbstract.php
Normal file
58
lib/Alchemy/Phrasea/Core/Service/ServiceAbstract.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Service;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
|
||||
class ServiceAbstract
|
||||
{
|
||||
protected $name;
|
||||
protected $options;
|
||||
|
||||
public function __construct($name, Array $options)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
return 'Unknow';
|
||||
}
|
||||
}
|
32
lib/Alchemy/Phrasea/Core/Service/ServiceInterface.php
Normal file
32
lib/Alchemy/Phrasea/Core/Service/ServiceInterface.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Service;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
|
||||
interface ServiceInterface
|
||||
{
|
||||
public function getName();
|
||||
|
||||
public function getType();
|
||||
|
||||
public function getService();
|
||||
|
||||
public function getOptions();
|
||||
|
||||
public function getScope();
|
||||
}
|
@@ -9,11 +9,14 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Service;
|
||||
namespace Alchemy\Phrasea\Core\Service\TemplateEngine;
|
||||
|
||||
use Alchemy\Phrasea\Core;
|
||||
use Alchemy\Phrasea\Core,
|
||||
Alchemy\Phrasea\Core\Service,
|
||||
Alchemy\Phrasea\Core\Service\ServiceAbstract,
|
||||
Alchemy\Phrasea\Core\Service\ServiceInterface;
|
||||
|
||||
class Twig
|
||||
class Twig extends ServiceAbstract implements ServiceInterface
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -22,11 +25,11 @@ class Twig
|
||||
*/
|
||||
protected $twig;
|
||||
protected $templatesPath = array();
|
||||
protected $options;
|
||||
|
||||
public function __construct(Array $configuration)
|
||||
public function __construct($name, Array $options)
|
||||
{
|
||||
$this->options = $this->resolveOptions($configuration);
|
||||
parent::__construct($name, $options);
|
||||
$this->options = $this->resolveOptions($options);
|
||||
$this->templatesPath = $this->resolvePaths();
|
||||
|
||||
try
|
||||
@@ -194,41 +197,34 @@ class Twig
|
||||
*/
|
||||
private function resolveOptions(Array $configuration)
|
||||
{
|
||||
if (isset($configuration['options']))
|
||||
{
|
||||
$options = $configuration['options'];
|
||||
$registry = \registry::get_instance();
|
||||
$options = $configuration;
|
||||
|
||||
$options["optimizer"] = !!$options["optimizer"] ? -1 : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$options = array(
|
||||
'cache' => $registry->get('GV_RootPath') . 'tmp/cache_twig',
|
||||
'debug' => false,
|
||||
'strict_variables' => false,
|
||||
'trim_blocks' => true,
|
||||
'charset' => 'utf-8'
|
||||
);
|
||||
}
|
||||
$options['cache'] = $registry->get('GV_RootPath') . 'tmp/cache_twig';
|
||||
$options['charset'] = 'utf-8';
|
||||
|
||||
$confApp = new Core\Configuration\Application();
|
||||
$confParser = new Core\Configuration\Parser\Yaml();
|
||||
$handler = new Core\Configuration\Handler($confApp, $confParser);
|
||||
$configuration = new Core\Configuration($handler);
|
||||
|
||||
if ($configuration->isDebug())
|
||||
if (!!$options["debug"])
|
||||
{
|
||||
$options["debug"] = true;
|
||||
unset($options["cache"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$options["debug"] = false;
|
||||
$options["cache"] = $registry->get('GV_RootPath') . 'tmp/cache_twig';
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getService()
|
||||
{
|
||||
return $this->twig;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return 'twig';
|
||||
}
|
||||
|
||||
public function getScope()
|
||||
{
|
||||
return 'template_engine';
|
||||
}
|
||||
|
||||
}
|
75
lib/Alchemy/Phrasea/Core/ServiceBuilder.php
Normal file
75
lib/Alchemy/Phrasea/Core/ServiceBuilder.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class ServiceBuilder
|
||||
{
|
||||
const LOG = 'log';
|
||||
const TEMPLATE_ENGINE = 'template_engine';
|
||||
const ORM = 'orm';
|
||||
|
||||
protected static $scopes = array(
|
||||
self::ORM, self::TEMPLATE_ENGINE, self::LOG
|
||||
);
|
||||
|
||||
public static function build($serviceName, $serviceScope, $serviceType, Array $options, $namespace = null)
|
||||
{
|
||||
if (!in_array($serviceScope, self::$scopes))
|
||||
{
|
||||
throw new \Exception(sprintf("Unknow service scope of type %s", $serviceScope));
|
||||
}
|
||||
|
||||
$composedScope = explode("_", $serviceScope);
|
||||
|
||||
if (count($composedScope) > 1)
|
||||
{
|
||||
$scope = "";
|
||||
foreach ($composedScope as $word)
|
||||
{
|
||||
$scope .= ucfirst($word);
|
||||
}
|
||||
$serviceScope = $scope;
|
||||
}
|
||||
|
||||
if (is_string($namespace))
|
||||
{
|
||||
$scope = sprintf("%s\%s", ucfirst($namespace), ucfirst($serviceScope));
|
||||
}
|
||||
|
||||
$className = sprintf(
|
||||
"\Alchemy\Phrasea\Core\Service\%s\%s"
|
||||
, ucfirst($serviceScope)
|
||||
, ucfirst($serviceType)
|
||||
);
|
||||
|
||||
if (class_exists($className))
|
||||
{
|
||||
return new $className($serviceName, $options);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \Exception(sprintf(
|
||||
'Unknow service %s for %s scopes looked for classname %s'
|
||||
, str_replace('/', '_', $serviceType)
|
||||
, $serviceScope
|
||||
, $className)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -81,7 +81,9 @@ class appbox extends base
|
||||
);
|
||||
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
|
||||
|
||||
$connexion = $configuration->getConnexion();
|
||||
$choosenConnexion = $configuration->getPhraseanet()->get('database');
|
||||
|
||||
$connexion = $configuration->getConnexion($choosenConnexion);
|
||||
|
||||
$this->host = $connexion->get('host');
|
||||
$this->port = $connexion->get('port');
|
||||
@@ -415,34 +417,99 @@ class appbox extends base
|
||||
$credentials['dbname'] = $dbname;
|
||||
}
|
||||
|
||||
$file = __DIR__ . "/../../config/config.sample.yml";
|
||||
$file1 = __DIR__ . "/../../config/config.yml";
|
||||
|
||||
if (!copy($file, $file1))
|
||||
{
|
||||
throw new \Exception(sprintf("Unable to copy %s", $file1));
|
||||
}
|
||||
|
||||
$handler = new \Alchemy\Phrasea\Core\Configuration\Handler(
|
||||
new \Alchemy\Phrasea\Core\Configuration\Application(),
|
||||
new \Alchemy\Phrasea\Core\Configuration\Parser\Yaml()
|
||||
);
|
||||
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
|
||||
|
||||
$connexionINI = array();
|
||||
|
||||
foreach ($credentials as $key => $value)
|
||||
{
|
||||
$key = $key == 'hostname' ? 'host' : $key;
|
||||
$connexionINI[$key] = (string) $value;
|
||||
}
|
||||
$connexionINI['driver'] = 'pdo_mysql';
|
||||
$connexionINI['charset'] = 'UTF8';
|
||||
|
||||
$serverName = $registry->get('GV_ServerName');
|
||||
$configuration->setServerName($serverName);
|
||||
$configuration->setAllDatabaseConnexion($connexionINI);
|
||||
|
||||
$root = __DIR__ . '/../../';
|
||||
|
||||
//copy config sample
|
||||
$configSampleFile = $root . "config/config.sample.yml";
|
||||
$configFile = $root . "config/config.yml";
|
||||
|
||||
if (!copy($configSampleFile, $configFile))
|
||||
{
|
||||
throw new \Exception(sprintf("Unable to copy %s", $configSampleFile));
|
||||
}
|
||||
|
||||
//copy service sample
|
||||
$serviceSampleFile = $root . "config/services.sample.yml";
|
||||
$serviceFile = $root . "config/services.yml";
|
||||
|
||||
if (!copy($serviceSampleFile, $serviceFile))
|
||||
{
|
||||
throw new \Exception(sprintf("Unable to copy %s", $serviceSampleFile));
|
||||
}
|
||||
|
||||
//copy connexion sample
|
||||
$connexionSampleFile = $root . "config/connexions.sample.yml";
|
||||
$connexionFile = $root . "config/connexions.yml";
|
||||
|
||||
if (!copy($connexionSampleFile, $connexionFile))
|
||||
{
|
||||
throw new \Exception(sprintf("Unable to copy %s", $serviceSampleFile));
|
||||
}
|
||||
|
||||
//get configuration object
|
||||
$appConf = new \Alchemy\Phrasea\Core\Configuration\Application();
|
||||
$parser = new \Alchemy\Phrasea\Core\Configuration\Parser\Yaml();
|
||||
$handler = new \Alchemy\Phrasea\Core\Configuration\Handler($appConf, $parser);
|
||||
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
|
||||
|
||||
//write credentials to config file
|
||||
$connexionFile = $appConf->getConnexionFile();
|
||||
|
||||
$connexion = array(
|
||||
'main_connexion' => $connexionINI,
|
||||
'test_connexion' => array(
|
||||
'driver' => 'pdo_sqlite',
|
||||
'path' => $root . 'lib/unitTest/tests.sqlite',
|
||||
'charset' => 'UTF8'
|
||||
));
|
||||
|
||||
$yaml = $configuration->getConfigurationHandler()->getParser()->dump($connexion, 2);
|
||||
|
||||
if (!file_put_contents($connexionFile->getPathname(), $yaml) !== false)
|
||||
{
|
||||
throw new \Exception(sprintf(_('Impossible d\'ecrire dans le fichier %s'), $connexionFile->getPathname()));
|
||||
}
|
||||
|
||||
//rewrite service file
|
||||
$serviceFile = $appConf->getServiceFile();
|
||||
$service = $configuration->getConfigurationHandler()->getParser()->parse($serviceFile);
|
||||
$yaml = $configuration->getConfigurationHandler()->getParser()->dump($service, 5);
|
||||
|
||||
if (!file_put_contents($serviceFile->getPathname(), $yaml) !== false)
|
||||
{
|
||||
throw new \Exception(sprintf(_('Impossible d\'ecrire dans le fichier %s'), $serviceFile->getPathname()));
|
||||
}
|
||||
|
||||
//rewrite servername in main config file
|
||||
$arrayConf = $configuration->all();
|
||||
|
||||
foreach ($arrayConf as $key => $value)
|
||||
{
|
||||
if (is_array($value) && array_key_exists('phraseanet', $value))
|
||||
{
|
||||
$arrayConf[$key]["phraseanet"]["servername"] = $serverName;
|
||||
}
|
||||
}
|
||||
|
||||
$configuration->write($arrayConf);
|
||||
|
||||
|
||||
|
||||
if (function_exists('chmod'))
|
||||
{
|
||||
chmod($configuration->getFile()->getPathname(), 0700);
|
||||
chmod($serviceFile->getPathname(), 0700);
|
||||
chmod($connexionFile->getPathname(), 0700);
|
||||
}
|
||||
}
|
||||
try
|
||||
|
@@ -93,13 +93,19 @@ class binaryAdapter_image_resize_gd extends binaryAdapter_processorAbstract
|
||||
|
||||
$size = $this->options['size'];
|
||||
|
||||
if (!is_null($size) && !$origine->is_raw_image()
|
||||
&& $tech_datas[system_file::TC_DATAS_WIDTH] < $size && $tech_datas[system_file::TC_DATAS_HEIGHT] < $size)
|
||||
if (
|
||||
!is_null($size)
|
||||
&& isset($tech_datas[system_file::TC_DATAS_WIDTH])
|
||||
&& isset($tech_datas[system_file::TC_DATAS_HEIGHT])
|
||||
&& !$origine->is_raw_image()
|
||||
&& $tech_datas[system_file::TC_DATAS_WIDTH] < $size
|
||||
&& $tech_datas[system_file::TC_DATAS_HEIGHT] < $size
|
||||
)
|
||||
{
|
||||
$size = max($tech_datas[system_file::TC_DATAS_WIDTH], $tech_datas[system_file::TC_DATAS_HEIGHT]);
|
||||
}
|
||||
|
||||
switch($origine->get_mime())
|
||||
switch ($origine->get_mime())
|
||||
{
|
||||
case "image/jpeg" :
|
||||
$imag_original = imagecreatefromjpeg($origine->getPathname());
|
||||
@@ -134,8 +140,7 @@ class binaryAdapter_image_resize_gd extends binaryAdapter_processorAbstract
|
||||
$w_sub = (int) (($w_doc / $h_doc) * ($h_sub = $size));
|
||||
$img_mini = imagecreatetruecolor($w_sub, $h_sub);
|
||||
|
||||
imagecopyresampled($img_mini, $imag_original, 0, 0, 0, 0,
|
||||
$w_sub, $h_sub, $w_doc, $h_doc);
|
||||
imagecopyresampled($img_mini, $imag_original, 0, 0, 0, 0, $w_sub, $h_sub, $w_doc, $h_doc);
|
||||
}
|
||||
|
||||
if ($this->options['autorotate'])
|
||||
|
@@ -142,7 +142,9 @@ class connection
|
||||
);
|
||||
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
|
||||
|
||||
$connexion = $configuration->getConnexion();
|
||||
$choosenConnexion = $configuration->getPhraseanet()->get('database');
|
||||
|
||||
$connexion = $configuration->getConnexion($choosenConnexion);
|
||||
|
||||
$hostname = $connexion->get('host');
|
||||
$port = $connexion->get('port');
|
||||
|
@@ -111,7 +111,9 @@ class phrasea
|
||||
);
|
||||
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
|
||||
|
||||
$connexion = $configuration->getConnexion();
|
||||
$choosenConnexion = $configuration->getPhraseanet()->get('database');
|
||||
|
||||
$connexion = $configuration->getConnexion($choosenConnexion);
|
||||
|
||||
$hostname = $connexion->get('host');
|
||||
$port = $connexion->get('port');
|
||||
|
@@ -63,12 +63,14 @@ class registry implements registryInterface
|
||||
new \Alchemy\Phrasea\Core\Configuration\Parser\Yaml()
|
||||
);
|
||||
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
|
||||
$phraseanet = $configuration->getPhraseanet();
|
||||
|
||||
$this->cache->set('GV_RootPath', dirname(dirname(__DIR__)) . '/');
|
||||
$this->cache->set('GV_ServerName', $phraseanet->get('servername'));
|
||||
if ($configuration->isInstalled())
|
||||
{
|
||||
$this->cache->set('GV_ServerName', $configuration->getPhraseanet()->get('servername'));
|
||||
$this->cache->set('GV_debug', $configuration->isDebug());
|
||||
$this->cache->set('GV_maintenance', $configuration->isMaintained());
|
||||
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@@ -69,14 +69,24 @@ class setup
|
||||
public static function is_installed()
|
||||
{
|
||||
$appConf = new \Alchemy\Phrasea\Core\Configuration\Application();
|
||||
|
||||
return is_file($appConf->getConfigurationPathName());
|
||||
$installed = false;
|
||||
try
|
||||
{
|
||||
$appConf->getConfigurationFile();
|
||||
$appConf->getConnexionFile();
|
||||
$appConf->getServiceFile();
|
||||
$installed = true;
|
||||
}
|
||||
catch(\Exception $e)
|
||||
{
|
||||
}
|
||||
return $installed;
|
||||
}
|
||||
|
||||
public static function needUpgradeConfigurationFile()
|
||||
{
|
||||
return (is_file(__DIR__ . "/../../conf/connexion.inc")
|
||||
&& is_file(__DIR__ . "/../../config.inc"));
|
||||
return (is_file(__DIR__ . "/../../config/connexion.inc")
|
||||
&& is_file(__DIR__ . "/../../config/config.inc"));
|
||||
}
|
||||
|
||||
function create_global_values(registryInterface &$registry, $datas=array())
|
||||
|
@@ -51,7 +51,9 @@ class task_Scheduler
|
||||
);
|
||||
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
|
||||
|
||||
$connexion = $configuration->getConnexion();
|
||||
$choosenConnexion = $configuration->getPhraseanet()->get('database');
|
||||
|
||||
$connexion = $configuration->getConnexion($choosenConnexion);
|
||||
|
||||
$hostname = $connexion->get('host');
|
||||
$port = $connexion->get('port');
|
||||
|
@@ -58,14 +58,13 @@ class ConfigurationTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
$this->assertEquals('prod', $configuration->getEnvironnement());
|
||||
$this->assertTrue($configuration->isInstalled());
|
||||
$this->assertInstanceOf(
|
||||
'Alchemy\Phrasea\Core\Configuration\Parameter'
|
||||
'\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag'
|
||||
, $configuration->getConfiguration()
|
||||
);
|
||||
$this->assertFalse($configuration->isDebug());
|
||||
$this->assertFalse($configuration->displayErrors());
|
||||
$this->assertFalse($configuration->isDisplayingErrors());
|
||||
$this->assertFalse($configuration->isMaintained());
|
||||
$this->assertTrue(is_array($configuration->getPhraseanet()->all()));
|
||||
$this->assertTrue(is_array($configuration->getDoctrine()->all()));
|
||||
}
|
||||
|
||||
public function testInstalled()
|
||||
@@ -85,8 +84,15 @@ class ConfigurationTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
$configuration->setEnvironnement('prod');
|
||||
|
||||
$this->assertFalse($configuration->isInstalled());
|
||||
$this->assertTrue(is_array($configuration->getPhraseanet()->all()));
|
||||
$this->assertTrue(is_array($configuration->getDoctrine()->all()));
|
||||
try
|
||||
{
|
||||
$configuration->getPhraseanet();
|
||||
$this->fail("should raise an exception because application is not yet installed");
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetAvailableLogger()
|
||||
@@ -140,36 +146,36 @@ class ConfigurationTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
$this->assertEquals('test', $configuration->getConfigurationHandler()->getSpecification()->getConfigurationFile());
|
||||
}
|
||||
|
||||
public function testBadDoctrineLogger()
|
||||
{
|
||||
$spec = $this->getMock(
|
||||
'\Alchemy\Phrasea\Core\Configuration\Application'
|
||||
, array('getConfigurationFile')
|
||||
);
|
||||
|
||||
$fileName = __DIR__ . '/confTestFiles/bad_doctrine_logger.yml';
|
||||
|
||||
$spec->expects($this->any())
|
||||
->method('getConfigurationFile')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
new \SplFileObject($fileName)
|
||||
)
|
||||
);
|
||||
|
||||
$handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml());
|
||||
|
||||
$configuration = new PhraseaCore\Configuration($handler);
|
||||
$configuration->setEnvironnement('prod');
|
||||
|
||||
try
|
||||
{
|
||||
$configuration->getDoctrine();
|
||||
$this->fail('An exception should be raised');
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
// public function testBadDoctrineLogger()
|
||||
// {
|
||||
// $spec = $this->getMock(
|
||||
// '\Alchemy\Phrasea\Core\Configuration\Application'
|
||||
// , array('getConfigurationFile')
|
||||
// );
|
||||
//
|
||||
// $fileName = __DIR__ . '/confTestFiles/bad_doctrine_logger.yml';
|
||||
//
|
||||
// $spec->expects($this->any())
|
||||
// ->method('getConfigurationFile')
|
||||
// ->will(
|
||||
// $this->returnValue(
|
||||
// new \SplFileObject($fileName)
|
||||
// )
|
||||
// );
|
||||
//
|
||||
// $handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml());
|
||||
//
|
||||
// $configuration = new PhraseaCore\Configuration($handler);
|
||||
// $configuration->setEnvironnement('prod');
|
||||
//
|
||||
// try
|
||||
// {
|
||||
// $configuration->getDoctrine();
|
||||
// $this->fail('An exception should be raised');
|
||||
// }
|
||||
// catch(Exception $e)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
}
|
@@ -1,139 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
|
||||
|
||||
use Alchemy\Phrasea\Core\Service\Doctrine;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Alchemy\Phrasea\Core as PhraseaCore;
|
||||
use Alchemy\Phrasea\Core\Configuration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class DoctrineTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \Alchemy\Phrasea\Core\Configuration\Application
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testInitialize()
|
||||
{
|
||||
try
|
||||
{
|
||||
$spec = $this->getMock(
|
||||
'\Alchemy\Phrasea\Core\Configuration\Application'
|
||||
, array('getConfigurationFile')
|
||||
);
|
||||
|
||||
$fileName = __DIR__ . '/../Configuration/confTestFiles/good.yml';
|
||||
|
||||
$spec->expects($this->any())
|
||||
->method('getConfigurationFile')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
new SplFileObject($fileName)
|
||||
)
|
||||
);
|
||||
|
||||
$handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml());
|
||||
|
||||
$configuration = new PhraseaCore\Configuration($handler);
|
||||
$configuration->setEnvironnement('prod');
|
||||
|
||||
$doctrineService = new Doctrine($configuration->getDoctrine()->all());
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testNoDbalConf()
|
||||
{
|
||||
try
|
||||
{
|
||||
$doctrineService = new Doctrine();
|
||||
$this->fail("should raised an exception");
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetVersion()
|
||||
{
|
||||
$spec = $this->getMock(
|
||||
'\Alchemy\Phrasea\Core\Configuration\Application'
|
||||
, array('getConfigurationFile')
|
||||
);
|
||||
|
||||
$fileName = __DIR__ . '/../Configuration/confTestFiles/good.yml';
|
||||
|
||||
$spec->expects($this->any())
|
||||
->method('getConfigurationFile')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
new SplFileObject($fileName)
|
||||
)
|
||||
);
|
||||
|
||||
$handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml());
|
||||
|
||||
$configuration = new PhraseaCore\Configuration($handler);
|
||||
$configuration->setEnvironnement('prod');
|
||||
|
||||
$doctrineService = new Doctrine($configuration->getDoctrine()->all());
|
||||
$this->assertTrue(is_string($doctrineService->getVersion()));
|
||||
}
|
||||
|
||||
public function testGetEntityManager()
|
||||
{
|
||||
$spec = $this->getMock(
|
||||
'\Alchemy\Phrasea\Core\Configuration\Application'
|
||||
, array('getConfigurationFile')
|
||||
);
|
||||
|
||||
$fileName = __DIR__ . '/../Configuration/confTestFiles/good.yml';
|
||||
|
||||
$spec->expects($this->any())
|
||||
->method('getConfigurationFile')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
new SplFileObject($fileName)
|
||||
)
|
||||
);
|
||||
|
||||
$handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml());
|
||||
|
||||
$configuration = new PhraseaCore\Configuration($handler);
|
||||
$configuration->setEnvironnement('prod');
|
||||
|
||||
$doctrineService = new Doctrine($configuration->getDoctrine()->all());
|
||||
$this->assertInstanceOf('\Doctrine\ORM\EntityManager', $doctrineService->getEntityManager());
|
||||
}
|
||||
|
||||
}
|
@@ -2,6 +2,11 @@
|
||||
|
||||
require_once __DIR__ . '/../../bootstrap.php';
|
||||
|
||||
$new_include_path = __DIR__ . "/../../vendor/" . PATH_SEPARATOR . get_include_path();
|
||||
set_include_path($new_include_path);
|
||||
|
||||
require_once __DIR__ . "/../../vendor/Phlickr/Api.php";
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
|
@@ -11,19 +11,21 @@
|
||||
|
||||
require_once __DIR__ . "/../../lib/classes/bootstrap.class.php";
|
||||
|
||||
use Silex\WebTestCase;
|
||||
use Symfony\Component\HttpKernel\Client;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Doctrine\Common\DataFixtures\Loader;
|
||||
use PhraseaFixture\Basket as MyFixture;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
|
||||
bootstrap::execute('test');
|
||||
|
||||
use Silex\WebTestCase;
|
||||
use Symfony\Component\HttpKernel\Client;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Doctrine\Common\DataFixtures\Loader;
|
||||
use PhraseaFixture\Basket as MyFixture;
|
||||
|
||||
abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
{
|
||||
@@ -730,8 +732,22 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
*/
|
||||
protected function resetTwig()
|
||||
{
|
||||
$serviceTwig = new \Alchemy\Phrasea\Core\Service\Twig(array());
|
||||
$this->app['Core']["Twig"] = $serviceTwig->getTwig();
|
||||
$handler = new \Alchemy\Phrasea\Core\Configuration\Handler(
|
||||
new \Alchemy\Phrasea\Core\Configuration\Application(),
|
||||
new \Alchemy\Phrasea\Core\Configuration\Parser\Yaml()
|
||||
);
|
||||
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
|
||||
|
||||
$serviceName = $configuration->getTemplating();
|
||||
$confService = $configuration->getService($serviceName);
|
||||
|
||||
$templateService = \Alchemy\Phrasea\Core\ServiceBuilder::build(
|
||||
$serviceName
|
||||
, \Alchemy\Phrasea\Core\ServiceBuilder::TEMPLATE_ENGINE
|
||||
, $confService->get("type")
|
||||
, $confService->get("options")
|
||||
);
|
||||
$this->app['Core']["Twig"] = $templateService->getService();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/PhraseanetPHPUnitAbstract.class.inc';
|
||||
|
||||
/**
|
||||
* Test class for supertwig.
|
||||
* Generated by PHPUnit on 2011-07-06 at 18:30:03.
|
||||
*/
|
||||
class supertwigTest extends PhraseanetPHPUnitAbstract
|
||||
{
|
||||
|
||||
protected $object;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->object = new supertwig();
|
||||
}
|
||||
|
||||
public function testAddFilter()
|
||||
{
|
||||
$this->object->addFilter(array('nl2br'=>'nl2br'));
|
||||
try
|
||||
{
|
||||
$this->object->addFilter(array('prout'=>'prout'));
|
||||
$this->fail();
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function testRender()
|
||||
{
|
||||
$this->object->addFilter(array('nl2br'=>'nl2br'));
|
||||
$this->assertEquals('mon beau camion', $this->object->render('test.html', array('test_string'=>'mon beau camion')));
|
||||
$string = "mon\nBEAU CAMION\n";
|
||||
$this->assertEquals("mon<br />\nBEAU CAMION<br />\n", $this->object->render('test.html', array('test_string'=>"mon\nBEAU CAMION\n")));
|
||||
}
|
||||
|
||||
public function testDisplay()
|
||||
{
|
||||
ob_start();
|
||||
|
||||
$this->object->addFilter(array('nl2br'=>'nl2br'));
|
||||
$this->object->display('test.html', array('test_string'=>'mon beau camion'));
|
||||
|
||||
$out = ob_get_clean();
|
||||
$this->assertEquals('mon beau camion', $out);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@
|
||||
{% trans 'Vous etes maintenant deconnecte. A bientot.' %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{{errorWarning}}{{confirmWarning}}
|
||||
{{errorWarning|raw}}{{confirmWarning|raw}}
|
||||
</div>
|
||||
<div style="margin-top:10px;">
|
||||
<div style="margin-top:3px;">{% trans 'admin::compte-utilisateur identifiant' %}</div>
|
||||
|
@@ -25,7 +25,7 @@
|
||||
{% trans 'Vous etes maintenant deconnecte. A bientot.' %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{{errorWarning}}{{confirmWarning}}
|
||||
{{errorWarning|raw}}{{confirmWarning|raw}}
|
||||
</div>
|
||||
<div style="margin-top:10px;">
|
||||
<div style="margin-top:3px;">{% trans 'admin::compte-utilisateur identifiant' %}</div>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
{% trans 'Vous etes maintenant deconnecte. A bientot.' %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{{errorWarning}}{{confirmWarning}}
|
||||
{{errorWarning|raw}}{{confirmWarning|raw}}
|
||||
</div>
|
||||
<div style="margin-top:20px;">
|
||||
<div style="margin-top:3px;">{% trans 'admin::compte-utilisateur identifiant' %}</div>
|
||||
|
@@ -105,7 +105,9 @@ phrasea::headers();
|
||||
);
|
||||
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
|
||||
|
||||
$connexion = $configuration->getConnexion();
|
||||
$choosenConnexion = $configuration->getPhraseanet()->get('database');
|
||||
|
||||
$connexion = $configuration->getConnexion($choosenConnexion);
|
||||
|
||||
$hostname = $connexion->get('host');
|
||||
$port = $connexion->get('port');
|
||||
|
Reference in New Issue
Block a user