Merge branch '3.6' of github.com:alchemy-fr/Phraseanet into 3.6

This commit is contained in:
Romain Neutron
2012-01-20 13:00:17 +01:00
37 changed files with 871 additions and 466 deletions

View File

@@ -65,7 +65,7 @@ return call_user_func(function()
{
throw new \Exception(sprintf("Unable to copy %s", $serviceSampleFile));
}
//copy connexion sample
$connexionSampleFile = __DIR__ . "/../../../../config/connexions.sample.yml";
$connexionFile = __DIR__ . "/../../../../config/connexions.yml";
@@ -105,7 +105,7 @@ return call_user_func(function()
'main_connexion' => $connexionINI,
'test_connexion' => array(
'driver' => 'pdo_sqlite',
'path' => $registry->get("GV_RootPath") . 'lib/unitTest/tests.sqlite',
'path' => realpath($registry->get("GV_RootPath") . 'lib/unitTest/tests.sqlite'),
'charset' => 'UTF8'
));
@@ -116,10 +116,34 @@ return call_user_func(function()
throw new \Exception(sprintf(_('Impossible d\'ecrire dans le fichier %s'), $connexionFile->getPathname()));
}
$cacheService = "array_cache";
if (extension_loaded('apc'))
{
$cacheService = "apc_cache";
}
elseif (extension_loaded('xcache'))
{
$cacheService = "xcache_cache";
}
//rewrite service file
$serviceFile = $appConf->getServiceFile();
$service = $configuration->getConfigurationHandler()->getParser()->parse($serviceFile);
$yaml = $configuration->getConfigurationHandler()->getParser()->dump($service, 5);
$services = $configuration->getConfigurationHandler()->getParser()->parse($serviceFile);
foreach ($services as $serviceName => $service)
{
if ($serviceName === "doctrine_prod")
{
$services["doctrine_prod"]["options"]["orm"]["cache"] = array(
"query" => $cacheService,
"result" => $cacheService,
"metadata" => $cacheService
);
}
}
$yaml = $configuration->getConfigurationHandler()->getParser()->dump($services, 5);
if (!file_put_contents($serviceFile->getPathname(), $yaml) !== false)
{
@@ -134,11 +158,17 @@ return call_user_func(function()
{
$arrayConf[$key]["phraseanet"]["servername"] = $serverName;
}
if (is_array($value) && $key === 'prod')
{
$arrayConf[$key]["cache"] = $cacheService;
}
}
$configuration->write($arrayConf);
$app->redirect("/setup/installer/");
$app['install'] = true;
// $app->redirect("/setup/installer/");
}
else
{

View File

@@ -344,14 +344,15 @@ class UsrLists implements ControllerProviderInterface
$controllers->post('/list/{list_id}/add/{usr_id}/', function(Application $app, $list_id, $usr_id)
{
$em = $app['Core']->getEntityManager();
$user = $app['Core']->getAuthenticatedUser();
try
{
$repository = $em->getRepository('\Entities\UsrList');
$list = $repository->findUserListByUserAndId($user, $list_id);
/* @var $list \Entities\UsrList */
$user_entry = \User_Adapter::getInstance($usr_id, appbox::get_instance());
$user_entry = \User_Adapter::getInstance($usr_id, \appbox::get_instance());
$entry = new \Entities\UsrListEntry();
$entry->setUser($user_entry);
@@ -399,12 +400,12 @@ class UsrLists implements ControllerProviderInterface
$list = $repository->findUserListByUserAndId($user, $list_id);
/* @var $list \Entities\UsrList */
if($list->getOwner($user)->getList() < \Entities\UsrListOwner::ROLE_EDITOR)
if($list->getOwner($user)->getRole() < \Entities\UsrListOwner::ROLE_EDITOR)
{
throw new \Exception('You are not authorized to do this');
}
$new_owner = \User_Adapter::getInstance($usr_id, appbox::get_instance());
$new_owner = \User_Adapter::getInstance($usr_id, \appbox::get_instance());
if($list->hasAccess($new_owner))
{
@@ -436,7 +437,7 @@ class UsrLists implements ControllerProviderInterface
}
catch (\Exception $e)
{
$datas = array(
'success' => false
, 'message' => _('Unable to share the list with the usr')

View File

@@ -133,6 +133,8 @@ class Installer implements ControllerProviderInterface
\phrasea::use_i18n(\Session_Handler::get_locale());
$request = $app['request'];
$servername = $request->getScheme() . '://' . $request->getHttpHost() . '/';
$setupRegistry = new \Setup_Registry();
$setupRegistry->set('GV_ServerName', $servername);
@@ -171,7 +173,8 @@ class Installer implements ControllerProviderInterface
try
{
$servername = $request->getScheme() . '://' . $request->getHttpHost() . '/';
$setupRegistry = new \Setup_Registry();
$setupRegistry->set('GV_ServerName', $servername);
$appbox = \appbox::create($setupRegistry, $conn, $appbox_name, true);
@@ -186,12 +189,14 @@ class Installer implements ControllerProviderInterface
$serviceName = $configuration->getOrm();
$confService = $configuration->getService($serviceName);
$ormService = \Alchemy\Phrasea\Core\ServiceBuilder::build(
$ormServiceBuilder = new \Alchemy\Phrasea\Core\ServiceBuilder\Orm(
$serviceName
, \Alchemy\Phrasea\Core\ServiceBuilder::ORM
, $confService
, array('registry' => $setupRegistry)
);
$ormService = $ormServiceBuilder->buildService();
if ($ormService->getType() === 'doctrine')
{
/* @var $em \Doctrine\ORM\EntityManager */
@@ -325,4 +330,4 @@ class Installer implements ControllerProviderInterface
return $controllers;
}
}
}

View File

@@ -40,7 +40,6 @@ class Upgrader implements ControllerProviderInterface
/* @var $twig \Twig_Environment */
$twig = $app['Core']->getTwig();
ini_set('display_errors', 'on');
$html = $twig->render(
'/setup/upgrader.html.twig'
, array(
@@ -60,7 +59,6 @@ class Upgrader implements ControllerProviderInterface
$controllers->get('/status/', function() use ($app)
{
require_once __DIR__ . '/../../../../bootstrap.php';
ini_set('display_errors', 'on');
$datas = \Setup_Upgrade::get_status();
@@ -70,7 +68,6 @@ class Upgrader implements ControllerProviderInterface
$controllers->post('/execute/', function() use ($app)
{
require_once __DIR__ . '/../../../../bootstrap.php';
ini_set('display_errors', 'on');
set_time_limit(0);
session_write_close();
ignore_user_abort(true);

View File

@@ -56,6 +56,8 @@ class Core extends \Pimple
);
$this->configuration = new Core\Configuration($handler, $environement);
$this->init();
/**
* Set version
*/
@@ -64,37 +66,6 @@ class Core extends \Pimple
return new Core\Version();
});
$core = $this;
/**
* Set Entity Manager using configuration
*/
$this['EM'] = $this->share(function() use ($core)
{
$serviceName = $core->getConfiguration()->getOrm();
$service = $core->getService(
$serviceName
, Core\ServiceBuilder::ORM
);
return $service->getService();
});
$this["Twig"] = $this->share(function() use ($core)
{
$serviceName = $core->getConfiguration()->getTemplating();
$service = $core->getService(
$serviceName
, Core\ServiceBuilder::TEMPLATE_ENGINE
);
return $service->getService();
});
if (\setup::is_installed())
{
$this['Registry'] = $this->share(function()
@@ -102,8 +73,6 @@ class Core extends \Pimple
return \registry::get_instance();
});
\phrasea::start();
$appbox = \appbox::get_instance();
$session = $appbox->get_session();
$this->enableEvents();
}
else
@@ -115,6 +84,54 @@ class Core extends \Pimple
});
}
$core = $this;
/**
* Set Entity Manager using configuration
*/
$this['EM'] = $this->share(function() use ($core)
{
$serviceName = $core->getConfiguration()->getOrm();
$configuration = $core->getConfiguration()->getService($serviceName);
$serviceBuilder = new Core\ServiceBuilder\Orm(
$serviceName
, $configuration
, array("registry" => $core["Registry"])
);
return $serviceBuilder->buildService()->getService();
});
$this["Twig"] = $this->share(function() use ($core)
{
$serviceName = $core->getConfiguration()->getTemplating();
$configuration = $core->getConfiguration()->getService($serviceName);
$serviceBuilder = new Core\ServiceBuilder\TemplateEngine(
$serviceName, $configuration
);
return $serviceBuilder->buildService()->getService();
});
$this["Cache"] = $this->share(function() use ($core)
{
$serviceName = $core->getConfiguration()->getCache();
$configuration = $core->getConfiguration()->getService($serviceName);
$serviceBuilder = new Core\ServiceBuilder\Cache(
$serviceName
, $configuration
, array("registry" => $core["Registry"])
);
return $serviceBuilder->buildService()->getService();
});
$this['Serializer'] = $this->share(function()
{
$encoders = array(
@@ -149,7 +166,7 @@ class Core extends \Pimple
}
return;
}
/**
* Load Configuration
*
@@ -157,15 +174,18 @@ class Core extends \Pimple
*/
private function init()
{
if ($this->getConfiguration()->isDisplayingErrors())
if ($this->getConfiguration()->isInstalled())
{
ini_set('display_errors', 1);
error_reporting(E_ALL);
if ($this->getConfiguration()->isDisplayingErrors())
{
ini_set('display_errors', 'on');
error_reporting(E_ALL);
// \Symfony\Component\HttpKernel\Debug\ErrorHandler::register();
}
else
{
ini_set('display_errors', 0);
}
else
{
ini_set('display_errors', 'off');
}
}
}
@@ -179,6 +199,16 @@ class Core extends \Pimple
return $this['Registry'];
}
/**
* Getter
*
* @return \Registry
*/
public function getCache()
{
return $this['Cache'];
}
/**
* Getter
*
@@ -294,17 +324,6 @@ class Core extends \Pimple
ini_set('error_log', $php_log);
if ($this->getRegistry()->get('GV_debug'))
{
ini_set('display_errors', 'on');
ini_set('display_startup_errors', 'on');
}
else
{
ini_set('display_errors', 'off');
ini_set('display_startup_errors', 'off');
}
if ($this->getRegistry()->get('GV_log_errors'))
{
ini_set('log_errors', 'on');
@@ -441,15 +460,4 @@ 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
);
}
}

View File

@@ -353,6 +353,15 @@ class Configuration
{
return $this->getConfiguration()->get('template_engine');
}
/**
* Return cache service
* @return string
*/
public function getCache()
{
return $this->getConfiguration()->get('cache');
}
/**
* Return configuration service for orm

View File

@@ -15,8 +15,7 @@ use Alchemy\Phrasea\Core,
Alchemy\Phrasea\Core\Service,
Alchemy\Phrasea\Core\Service\ServiceAbstract,
Alchemy\Phrasea\Core\Service\ServiceInterface;
use Doctrine\Common\Cache\ApcCache;
use Doctrine\Common\Cache as CacheService;
/**
*
@@ -24,7 +23,7 @@ use Doctrine\Common\Cache\ApcCache;
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Apc extends ServiceAbstract implements ServiceInterface
class ApcCache extends ServiceAbstract implements ServiceInterface
{
public function getScope()
@@ -43,7 +42,12 @@ class Apc extends ServiceAbstract implements ServiceInterface
throw new \Exception('The APC cache requires the APC extension.');
}
return new ApcCache();
$registry = $this->getRegistry();
$service = new CacheService\ApcCache();
$service->setNamespace($registry->get("GV_sit", ""));
return $service;
}
public function getType()
@@ -51,5 +55,17 @@ class Apc extends ServiceAbstract implements ServiceInterface
return 'apc';
}
private function getRegistry()
{
$registry = $this->getDependency("registry");
if (!$registry instanceof \registryInterface)
{
throw new \Exception(sprintf('Registry dependency does not implement registryInterface for %s service', $this->name));
}
return $registry;
}
}

View File

@@ -15,18 +15,18 @@ use Alchemy\Phrasea\Core,
Alchemy\Phrasea\Core\Service,
Alchemy\Phrasea\Core\Service\ServiceAbstract,
Alchemy\Phrasea\Core\Service\ServiceInterface;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Cache as CacheService;
/**
* it's just like array cache
* Array cache
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Tab extends ServiceAbstract implements ServiceInterface
class ArrayCache extends ServiceAbstract implements ServiceInterface
{
public function getScope()
{
return 'cache';
@@ -38,7 +38,12 @@ class Tab extends ServiceAbstract implements ServiceInterface
*/
public function getService()
{
return new ArrayCache();
$registry = $this->getRegistry();
$service = new CacheService\ArrayCache();
$service->setNamespace($registry->get("GV_sit", ""));
return $service;
}
public function getType()
@@ -46,5 +51,17 @@ class Tab extends ServiceAbstract implements ServiceInterface
return 'array';
}
private function getRegistry()
{
$registry = $this->getDependency("registry");
if (!$registry instanceof \registryInterface)
{
throw new \Exception(sprintf('Registry dependency does not implement registryInterface for %s service', $this->name));
}
return $registry;
}
}

View File

@@ -15,7 +15,7 @@ use Alchemy\Phrasea\Core,
Alchemy\Phrasea\Core\Service,
Alchemy\Phrasea\Core\Service\ServiceAbstract,
Alchemy\Phrasea\Core\Service\ServiceInterface;
use Doctrine\Common\Cache\MemcacheCache;
use Doctrine\Common\Cache as CacheService;
/**
*
@@ -54,7 +54,12 @@ class Memcache extends ServiceAbstract implements ServiceInterface
$memchache = new \Memcache();
$memchache->connect($this->host, $this->port);
return new MemcacheCache($memchache);
$registry = $this->getRegistry();
$service = new CacheService\MemcacheCache($memchache);
$service->setNamespace($registry->get("GV_sit", ""));
return $service;
}
public function getType()
@@ -72,5 +77,16 @@ class Memcache extends ServiceAbstract implements ServiceInterface
return $this->port;
}
private function getRegistry()
{
$registry = $this->getDependency("registry");
if (!$registry instanceof \registryInterface)
{
throw new \Exception(sprintf('Registry dependency does not implement registryInterface for %s service', $this->name));
}
return $registry;
}
}

View File

@@ -15,7 +15,7 @@ use Alchemy\Phrasea\Core,
Alchemy\Phrasea\Core\Service,
Alchemy\Phrasea\Core\Service\ServiceAbstract,
Alchemy\Phrasea\Core\Service\ServiceInterface;
use Doctrine\Common\Cache\XcacheCache;
use Doctrine\Common\Cache as CacheService;
/**
* it's just like array cache
@@ -23,7 +23,7 @@ use Doctrine\Common\Cache\XcacheCache;
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Tab extends ServiceAbstract implements ServiceInterface
class XcacheCache extends ServiceAbstract implements ServiceInterface
{
public function getScope()
@@ -41,7 +41,13 @@ class Tab extends ServiceAbstract implements ServiceInterface
{
throw new \Exception('The XCache cache requires the XCache extension.');
}
return new XcacheCache();
$registry = $this->getRegistry();
$service = new CacheService\XcacheCache();
$service->setNamespace($registry->get("GV_sit", ""));
return $service;
}
public function getType()
@@ -49,4 +55,16 @@ class Tab extends ServiceAbstract implements ServiceInterface
return 'xcache';
}
private function getRegistry()
{
$registry = $this->getDependency("registry");
if (!$registry instanceof \registryInterface)
{
throw new \Exception(sprintf('Registry dependency does not implement registryInterface for %s service', $this->name));
}
return $registry;
}
}

View File

@@ -37,9 +37,9 @@ class Monolog extends ServiceAbstract implements ServiceInterface
*/
protected $monolog;
public function __construct($name, Array $options)
public function __construct($name, Array $options,Array $dependencies)
{
parent::__construct($name, $options);
parent::__construct($name, $options, $dependencies);
if (empty($options))
{

View File

@@ -27,6 +27,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
*/
class Doctrine extends ServiceAbstract implements ServiceInterface
{
const ARRAYCACHE = 'array';
const MEMCACHED = 'memcached';
const XCACHE = 'xcache';
@@ -45,9 +46,9 @@ class Doctrine extends ServiceAbstract implements ServiceInterface
protected $cacheServices = array();
protected $debug;
public function __construct($name, Array $options = array())
public function __construct($name, Array $options, Array $dependencies)
{
parent::__construct($name, $options);
parent::__construct($name, $options, $dependencies);
static::loadClasses();
@@ -373,12 +374,16 @@ class Doctrine extends ServiceAbstract implements ServiceInterface
}
}
$service = $this->findService(
$serviceName
, Core\ServiceBuilder::CACHE
, $configuration
$registry = $this->getDependency("registry");
$serviceBuilder = new Core\ServiceBuilder\Cache(
$serviceName,
$configuration,
array("registry" => $registry)
);
$service = $serviceBuilder->buildService();
$this->cacheServices[$cacheDoctrine] = $service;
return $service->getService();
@@ -416,14 +421,14 @@ class Doctrine extends ServiceAbstract implements ServiceInterface
);
}
$service = $this->findService(
$serviceName
, Core\ServiceBuilder::LOG
, $configuration
, 'doctrine' //look for Log\Doctrine services
$serviceBuilder = new Core\ServiceBuilder\Log(
$serviceName,
$configuration,
array(),
"Doctrine"
);
return $service->getService();
return $serviceBuilder->buildService()->getService();
}
public function getService()

View File

@@ -20,18 +20,21 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class ServiceAbstract
abstract class ServiceAbstract
{
protected $name;
protected $options;
protected $configuration;
private $dependencies;
public function __construct($name, Array $options)
public function __construct($name, Array $options, Array $dependencies)
{
$this->name = $name;
$this->options = $options;
$this->dependencies = $dependencies;
$spec = new Core\Configuration\Application();
$parser = new Core\Configuration\Parser\Yaml();
$handler = new Core\Configuration\Handler($spec, $parser);
@@ -39,15 +42,36 @@ class ServiceAbstract
$this->configuration = new Core\Configuration($handler);
}
protected function getDependency($name)
{
if(!array_key_exists($name, $this->dependencies))
{
throw new \Exception(sprintf("Unknow dependency %s for %s service ", $name, $this->name));
}
return $this->dependencies[$name];
}
/**
*
* @return Core\Configuration
* @return Array
*/
protected function getConfiguration()
{
return $this->configuration;
}
/**
*
* @return Array
*/
public function getDependencies()
{
return $this->dependencies;
}
/**
*
* @return string
@@ -75,20 +99,4 @@ class ServiceAbstract
return '';
}
/**
*
* @param type $serviceName
* @param type $serviceScope
* @return ServiceInterface
*/
protected function findService($serviceName, $serviceScope, ParameterBag $configuration, $namespace = null)
{
return Core\ServiceBuilder::build(
$serviceName
, $serviceScope
, $configuration
, $namespace
);
}
}

View File

@@ -26,10 +26,9 @@ class Twig extends ServiceAbstract implements ServiceInterface
protected $twig;
protected $templatesPath = array();
public function __construct($name, Array $options)
public function __construct($name, Array $options, Array $dependencies)
{
parent::__construct($name, $options);
parent::__construct($name, $options, $dependencies);
$this->templatesPath = $this->resolvePaths();

View File

@@ -1,109 +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.
*/
namespace Alchemy\Phrasea\Core;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
/**
*
* @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';
const CACHE = 'cache';
protected static $scopes = array(
self::ORM, self::TEMPLATE_ENGINE, self::LOG, self::CACHE
);
protected static $typeToService = array(
'echo' => 'normal', 'array' => 'tab'
);
protected static $optionsNotMandatory = array(
'twig', 'apc', 'xcache', 'memcache', 'array', 'echo'
);
public static function build($serviceName, $serviceScope, ParameterBag $configuration, $namespace = null)
{
$serviceType = $configuration->get("type");
if(!in_array($serviceType, self::$optionsNotMandatory))
{
$options = $configuration->get("options");
}
else
{
try
{
$options = $configuration->get("options");
}
catch(\Exception $e)
{
$options = array();
}
}
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))
{
$serviceScope = sprintf("%s\%s", ucfirst($serviceScope), ucfirst($namespace));
}
if(array_key_exists($serviceType, self::$typeToService))
{
$serviceType = self::$typeToService[$serviceType];
}
$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)
);
}
}
}

View File

@@ -0,0 +1,73 @@
<?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\ServiceBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
abstract class AbstractBuilder
{
protected static $optionsNotMandatory = array();
private $service;
public function __construct($name, ParameterBag $configuration, Array $dependencies = array(), $namespace = null)
{
if (!is_string($name) && empty($name))
{
throw new \Exception(sprintf("Service name must be a string %s given", var_export($name, true)));
}
$this->service = static::create($name, $configuration, $dependencies, $namespace);
}
/**
*
* @return ServiceAbstract
*/
public function buildService()
{
return $this->service;
}
public static function create($name, ParameterBag $configuration, Array $dependencies = array(), $namespace = null)
{
throw new \Exception("Abstract factory does not create any concrete Service");
}
protected static function getServiceOptions($type, ParameterBag $configuration)
{
if(!in_array($type, static::$optionsNotMandatory))
{
$options = $configuration->get("options");
}
else
{
try
{
$options = $configuration->get("options");
}
catch(\Exception $e)
{
$options = array();
}
}
return $options;
}
}

View File

@@ -0,0 +1,49 @@
<?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\ServiceBuilder;
use Alchemy\Phrasea\Core\Service;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Cache extends AbstractBuilder
{
protected static $optionsNotMandatory = array('apc', 'xcache', 'memcache', 'array');
public static function create($name, ParameterBag $configuration, Array $dependencies = array(), $namespace = null)
{
$type = $configuration->get("type");
$options = parent::getServiceOptions($type, $configuration);
$className = sprintf("\Alchemy\Phrasea\Core\Service\Cache\%sCache", ucfirst($type));
if (class_exists($className))
{
return new $className($name, $options, $dependencies);
}
else
{
throw new \Exception(sprintf(
'Unknow service %s for cache scopes looked for classname %s'
, str_replace('/', '_', $type)
, $className)
);
}
}
}

View File

@@ -0,0 +1,57 @@
<?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\ServiceBuilder;
use Alchemy\Phrasea\Core\Service;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Log extends AbstractBuilder
{
protected static $optionsNotMandatory = array('echo');
public static function create($name, ParameterBag $configuration, Array $dependencies = array(), $namespace = null)
{
$type = $configuration->get("type");
$options = parent::getServiceOptions($type, $configuration);
if (is_string($namespace))
{
$className = sprintf("\Alchemy\Phrasea\Core\Service\Log\%s\%s", $namespace, ucfirst($type));
}
else
{
$className = sprintf("\Alchemy\Phrasea\Core\Service\Log\%s", ucfirst($type));
}
if (class_exists($className))
{
return new $className($name, $options, $dependencies);
}
else
{
throw new \Exception(sprintf(
'Unknow service %s for log looked for classname %s'
, str_replace('/', '_', $type)
, $className)
);
}
}
}

View 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\ServiceBuilder;
use Alchemy\Phrasea\Core\Service;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Orm extends AbstractBuilder
{
public static function create($name, ParameterBag $configuration, Array $dependencies = array(), $namespace = null)
{
$type = $configuration->get("type");
$options = parent::getServiceOptions($type, $configuration);
$className = sprintf("\Alchemy\Phrasea\Core\Service\Orm\%s", ucfirst($type));
if (class_exists($className))
{
return new $className($name, $options, $dependencies);
}
else
{
throw new \Exception(sprintf(
'Unknow service %s for orm looked for classname %s'
, str_replace('/', '_', $type)
, $className)
);
}
}
}

View 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\ServiceBuilder;
use Alchemy\Phrasea\Core\Service;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class TemplateEngine extends AbstractBuilder
{
public static function create($name, ParameterBag $configuration, Array $dependencies = array(), $namespace = null)
{
$type = $configuration->get("type");
$options = parent::getServiceOptions($type, $configuration);
$className = sprintf("\Alchemy\Phrasea\Core\Service\TemplateEngine\%s", ucfirst($type));
if (class_exists($className))
{
return new $className($name, $options, $dependencies);
}
else
{
throw new \Exception(sprintf(
'Unknow service %s for template engine looked for classname %s'
, str_replace('/', '_', ucfirst($type))
, $className)
);
}
}
}

View File

@@ -50,7 +50,6 @@ class PDF
case self::LAYOUT_PREVIEWCAPTIONTDM:
try
{
// exit('prout');
$subdef = $record->get_subdef('preview');
if (!$subdef->is_physically_present())
{