mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 04:23:19 +00:00
Merge branch '3.6' of github.com:alchemy-fr/Phraseanet into 3.6
This commit is contained in:
@@ -43,12 +43,13 @@ try
|
||||
exit(sprintf("Doctrine is not declared as your ORM but %s is", $confService->get("type")));
|
||||
}
|
||||
|
||||
$ormService = \Alchemy\Phrasea\Core\ServiceBuilder::build(
|
||||
$ormServiceBuilder = new \Alchemy\Phrasea\Core\ServiceBuilder\Orm(
|
||||
$serviceName
|
||||
, \Alchemy\Phrasea\Core\ServiceBuilder::ORM
|
||||
, $confService
|
||||
, array('registry' => \registry::get_instance())
|
||||
);
|
||||
|
||||
$ormService = $ormServiceBuilder->buildService();
|
||||
$em = $ormService->getService();
|
||||
/* @var $em \Doctrine\ORM\EntityManager */
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
#Declare which environment will be used by the application
|
||||
|
||||
environment : dev
|
||||
environment : prod
|
||||
|
||||
#Declare all your environment configurations
|
||||
|
||||
@@ -25,6 +25,7 @@ dev:
|
||||
#Services are defined in service.yml configuration file
|
||||
template_engine: twig_debug
|
||||
orm: doctrine_dev
|
||||
cache: array_cache
|
||||
|
||||
##############
|
||||
# PRODUCTION #
|
||||
@@ -39,6 +40,7 @@ prod:
|
||||
|
||||
template_engine: twig
|
||||
orm: doctrine_prod
|
||||
cache: apc_cache
|
||||
|
||||
##############
|
||||
# TEST #
|
||||
@@ -53,5 +55,6 @@ test:
|
||||
|
||||
template_engine: twig_debug
|
||||
orm: doctrine_test
|
||||
cache: array_cache
|
||||
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -344,6 +344,7 @@ 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
|
||||
{
|
||||
@@ -351,7 +352,7 @@ class UsrLists implements ControllerProviderInterface
|
||||
|
||||
$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))
|
||||
{
|
||||
|
@@ -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 */
|
||||
|
@@ -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);
|
||||
|
@@ -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(
|
||||
@@ -156,16 +173,19 @@ class Core extends \Pimple
|
||||
* @param type $environnement
|
||||
*/
|
||||
private function init()
|
||||
{
|
||||
if ($this->getConfiguration()->isInstalled())
|
||||
{
|
||||
if ($this->getConfiguration()->isDisplayingErrors())
|
||||
{
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_errors', 'on');
|
||||
error_reporting(E_ALL);
|
||||
// \Symfony\Component\HttpKernel\Debug\ErrorHandler::register();
|
||||
}
|
||||
else
|
||||
{
|
||||
ini_set('display_errors', 0);
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -354,6 +354,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
|
||||
* @return string
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -15,16 +15,16 @@ 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()
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
@@ -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))
|
||||
{
|
||||
|
@@ -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()
|
||||
|
@@ -20,17 +20,20 @@ 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;
|
||||
|
||||
public function __construct($name, Array $options)
|
||||
private $dependencies;
|
||||
|
||||
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();
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
@@ -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();
|
||||
|
||||
|
@@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
73
lib/Alchemy/Phrasea/Core/ServiceBuilder/AbstractBuilder.php
Normal file
73
lib/Alchemy/Phrasea/Core/ServiceBuilder/AbstractBuilder.php
Normal 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;
|
||||
}
|
||||
|
||||
}
|
49
lib/Alchemy/Phrasea/Core/ServiceBuilder/Cache.php
Normal file
49
lib/Alchemy/Phrasea/Core/ServiceBuilder/Cache.php
Normal 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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
57
lib/Alchemy/Phrasea/Core/ServiceBuilder/Log.php
Normal file
57
lib/Alchemy/Phrasea/Core/ServiceBuilder/Log.php
Normal 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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
48
lib/Alchemy/Phrasea/Core/ServiceBuilder/Orm.php
Normal file
48
lib/Alchemy/Phrasea/Core/ServiceBuilder/Orm.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\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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
48
lib/Alchemy/Phrasea/Core/ServiceBuilder/TemplateEngine.php
Normal file
48
lib/Alchemy/Phrasea/Core/ServiceBuilder/TemplateEngine.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\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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -50,7 +50,6 @@ class PDF
|
||||
case self::LAYOUT_PREVIEWCAPTIONTDM:
|
||||
try
|
||||
{
|
||||
// exit('prout');
|
||||
$subdef = $record->get_subdef('preview');
|
||||
if (!$subdef->is_physically_present())
|
||||
{
|
||||
|
@@ -1080,9 +1080,9 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
$ret = array();
|
||||
foreach ($caption->get_fields() as $field)
|
||||
{
|
||||
foreach($field->get_values as $value)
|
||||
foreach ($field->get_values() as $value)
|
||||
{
|
||||
$ret[$value->getId()] = $this->list_record_caption_field($value);
|
||||
$ret[$value->getId()] = $this->list_record_caption_field($value, $field);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -34,6 +34,7 @@ class appbox extends base
|
||||
*
|
||||
* constant defining the app type
|
||||
*/
|
||||
|
||||
const BASE_TYPE = self::APPLICATION_BOX;
|
||||
|
||||
/**
|
||||
@@ -44,6 +45,7 @@ class appbox extends base
|
||||
protected $cache;
|
||||
protected $connection;
|
||||
protected $registry;
|
||||
|
||||
const CACHE_LIST_BASES = 'list_bases';
|
||||
const CACHE_SBAS_IDS = 'sbas_ids';
|
||||
|
||||
@@ -486,10 +488,21 @@ class appbox extends base
|
||||
'main_connexion' => $connexionINI,
|
||||
'test_connexion' => array(
|
||||
'driver' => 'pdo_sqlite',
|
||||
'path' => $root . 'lib/unitTest/tests.sqlite',
|
||||
'path' => realpath($root . 'lib/unitTest/tests.sqlite'),
|
||||
'charset' => 'UTF8'
|
||||
));
|
||||
|
||||
$cacheService = "array_cache";
|
||||
|
||||
if (extension_loaded('apc'))
|
||||
{
|
||||
$cacheService = "apc_cache";
|
||||
}
|
||||
elseif (extension_loaded('xcache'))
|
||||
{
|
||||
$cacheService = "xcache_cache";
|
||||
}
|
||||
|
||||
$yaml = $configuration->getConfigurationHandler()->getParser()->dump($connexion, 2);
|
||||
|
||||
if (!file_put_contents($connexionFile->getPathname(), $yaml) !== false)
|
||||
@@ -499,8 +512,22 @@ class appbox extends base
|
||||
|
||||
//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)
|
||||
{
|
||||
@@ -516,6 +543,11 @@ class appbox extends base
|
||||
{
|
||||
$arrayConf[$key]["phraseanet"]["servername"] = $serverName;
|
||||
}
|
||||
|
||||
if (is_array($value) && $key === 'prod')
|
||||
{
|
||||
$arrayConf[$key]["cache"] = $cacheService;
|
||||
}
|
||||
}
|
||||
|
||||
$configuration->write($arrayConf);
|
||||
|
@@ -324,12 +324,12 @@ class module_console_fileConfigCheck extends Command
|
||||
}
|
||||
|
||||
|
||||
$service = Core\ServiceBuilder::build(
|
||||
$serviceBuilder = new Core\ServiceBuilder\TemplateEngine(
|
||||
$templateEngineName
|
||||
, Core\ServiceBuilder::TEMPLATE_ENGINE
|
||||
, $configuration
|
||||
);
|
||||
|
||||
$service = $serviceBuilder->buildService();
|
||||
|
||||
if ($service->getType() === 'twig')
|
||||
{
|
||||
@@ -415,12 +415,16 @@ class module_console_fileConfigCheck extends Command
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$service = Core\ServiceBuilder::build(
|
||||
$registry = \registry::get_instance();
|
||||
|
||||
$serviceBuilder = new Core\ServiceBuilder\Orm(
|
||||
$ormName
|
||||
, Core\ServiceBuilder::ORM
|
||||
, $configuration
|
||||
, array('registry'=> $registry)
|
||||
);
|
||||
|
||||
$service = $serviceBuilder->buildService();
|
||||
|
||||
if ($service->getType() === 'doctrine')
|
||||
{
|
||||
$caches = $service->getCacheServices();
|
||||
|
@@ -509,6 +509,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return $this->get_subdef('thumbnailGIF');
|
||||
@@ -598,14 +599,21 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
||||
public function get_subdef($name)
|
||||
{
|
||||
$name = strtolower($name);
|
||||
|
||||
if (!in_array($name, $this->get_available_subdefs()))
|
||||
{
|
||||
throw new Exception_Media_SubdefNotFound ();
|
||||
}
|
||||
|
||||
if (isset($this->subdefs[$name]))
|
||||
{
|
||||
return $this->subdefs[$name];
|
||||
}
|
||||
|
||||
if (!$this->subdefs)
|
||||
{
|
||||
$this->subdefs = array();
|
||||
}
|
||||
|
||||
$substitute = ($name !== 'document');
|
||||
|
||||
@@ -1268,7 +1276,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
||||
}
|
||||
|
||||
if (!is_scalar($params['value']))
|
||||
{
|
||||
throw new Exception('Metadata value should be scalar');
|
||||
}
|
||||
|
||||
$databox_field = databox_field::get_instance($databox, $params['meta_struct_id']);
|
||||
|
||||
|
@@ -451,7 +451,17 @@ class searchEngine_options implements Serializable
|
||||
$value = new DateTime($value);
|
||||
}
|
||||
elseif ($value instanceof stdClass)
|
||||
$value = (array) $value;
|
||||
{
|
||||
$tmpvalue = (array) $value;
|
||||
$value = array();
|
||||
|
||||
foreach($tmpvalue as $k=>$data)
|
||||
{
|
||||
$k = ctype_digit($k) ? (int) $k : $k;
|
||||
$value[$k] = $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
@@ -93,7 +93,7 @@ class ControllerTooltipTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
foreach ($routes as $route)
|
||||
{
|
||||
$option = new \searchEngine_options();
|
||||
$crawler = $this->client->request('POST', $route, array('options_serial' => $option->serialize()));
|
||||
$crawler = $this->client->request('POST', $route, array('options_serial' => serialize($option)));
|
||||
|
||||
$this->assertTrue($this->client->getResponse()->isOk());
|
||||
}
|
||||
|
@@ -818,12 +818,12 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
$serviceName = $configuration->getTemplating();
|
||||
$confService = $configuration->getService($serviceName);
|
||||
|
||||
$templateService = \Alchemy\Phrasea\Core\ServiceBuilder::build(
|
||||
$templateServiceBuilder = new \Alchemy\Phrasea\Core\ServiceBuilder\TemplateEngine(
|
||||
$serviceName
|
||||
, \Alchemy\Phrasea\Core\ServiceBuilder::TEMPLATE_ENGINE
|
||||
, $confService
|
||||
);
|
||||
$this->app['Core']["Twig"] = $templateService->getService();
|
||||
|
||||
$this->app['Core']["Twig"] = $templateServiceBuilder->buildService()->getService();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1021,13 +1021,13 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
{
|
||||
if (static::$need_story && !self::$story_1 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 1\n";
|
||||
self::$story_1 = \record_adapter::create(
|
||||
self::$collection
|
||||
, new system_file(__DIR__ . '/testfiles/test001.CR2')
|
||||
, false
|
||||
, true
|
||||
);
|
||||
// echo "generate story 1\n";
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -1044,116 +1044,139 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
{
|
||||
if (self::$record_1 instanceof record_adapter && !isset(self::$generated_subdefs['a1']))
|
||||
{
|
||||
echo "Generate subdefs 1 \n";
|
||||
self::$record_1->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a1'] = true;
|
||||
}
|
||||
if (self::$record_2 instanceof record_adapter && !isset(self::$generated_subdefs['a2']))
|
||||
{
|
||||
echo "Generate subdefs 2 \n";
|
||||
self::$record_2->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a2'] = true;
|
||||
}
|
||||
if (self::$record_3 instanceof record_adapter && !isset(self::$generated_subdefs['a3']))
|
||||
{
|
||||
echo "Generate subdefs 3 \n";
|
||||
self::$record_3->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a3'] = true;
|
||||
}
|
||||
if (self::$record_4 instanceof record_adapter && !isset(self::$generated_subdefs['a4']))
|
||||
{
|
||||
echo "Generate subdefs 4 \n";
|
||||
self::$record_4->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a4'] = true;
|
||||
}
|
||||
if (self::$record_5 instanceof record_adapter && !isset(self::$generated_subdefs['a5']))
|
||||
{
|
||||
echo "Generate subdefs 5 \n";
|
||||
self::$record_5->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a5'] = true;
|
||||
}
|
||||
if (self::$record_6 instanceof record_adapter && !isset(self::$generated_subdefs['a6']))
|
||||
{
|
||||
echo "Generate subdefs 6 \n";
|
||||
self::$record_6->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a6'] = true;
|
||||
}
|
||||
if (self::$record_7 instanceof record_adapter && !isset(self::$generated_subdefs['a7']))
|
||||
{
|
||||
echo "Generate subdefs 7 \n";
|
||||
self::$record_7->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a7'] = true;
|
||||
}
|
||||
if (self::$record_8 instanceof record_adapter && !isset(self::$generated_subdefs['a8']))
|
||||
{
|
||||
echo "Generate subdefs 8 \n";
|
||||
self::$record_8->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a8'] = true;
|
||||
}
|
||||
if (self::$record_9 instanceof record_adapter && !isset(self::$generated_subdefs['a9']))
|
||||
{
|
||||
echo "Generate subdefs 9 \n";
|
||||
self::$record_9->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a9'] = true;
|
||||
}
|
||||
if (self::$record_10 instanceof record_adapter && !isset(self::$generated_subdefs['a10']))
|
||||
{
|
||||
echo "Generate subdefs 10 \n";
|
||||
self::$record_10->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a10'] = true;
|
||||
}
|
||||
if (self::$record_11 instanceof record_adapter && !isset(self::$generated_subdefs['a11']))
|
||||
{
|
||||
echo "Generate subdefs 11 \n";
|
||||
self::$record_11->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a11'] = true;
|
||||
}
|
||||
if (self::$record_12 instanceof record_adapter && !isset(self::$generated_subdefs['a12']))
|
||||
{
|
||||
echo "Generate subdefs 12 \n";
|
||||
self::$record_12->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a12'] = true;
|
||||
}
|
||||
if (self::$record_13 instanceof record_adapter && !isset(self::$generated_subdefs['a13']))
|
||||
{
|
||||
echo "Generate subdefs 13 \n";
|
||||
self::$record_13->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a13'] = true;
|
||||
}
|
||||
if (self::$record_14 instanceof record_adapter && !isset(self::$generated_subdefs['a14']))
|
||||
{
|
||||
echo "Generate subdefs 14 \n";
|
||||
self::$record_14->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a14'] = true;
|
||||
}
|
||||
if (self::$record_15 instanceof record_adapter && !isset(self::$generated_subdefs['a15']))
|
||||
{
|
||||
echo "Generate subdefs 15 \n";
|
||||
self::$record_15->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a15'] = true;
|
||||
}
|
||||
if (self::$record_16 instanceof record_adapter && !isset(self::$generated_subdefs['a16']))
|
||||
{
|
||||
echo "Generate subdefs 16 \n";
|
||||
self::$record_16->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a16'] = true;
|
||||
}
|
||||
if (self::$record_17 instanceof record_adapter && !isset(self::$generated_subdefs['a17']))
|
||||
{
|
||||
echo "Generate subdefs 17 \n";
|
||||
self::$record_17->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a17'] = true;
|
||||
}
|
||||
if (self::$record_18 instanceof record_adapter && !isset(self::$generated_subdefs['a18']))
|
||||
{
|
||||
echo "Generate subdefs 18 \n";
|
||||
self::$record_18->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a18'] = true;
|
||||
}
|
||||
if (self::$record_19 instanceof record_adapter && !isset(self::$generated_subdefs['a19']))
|
||||
{
|
||||
echo "Generate subdefs 19 \n";
|
||||
self::$record_19->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a19'] = true;
|
||||
}
|
||||
if (self::$record_20 instanceof record_adapter && !isset(self::$generated_subdefs['a20']))
|
||||
{
|
||||
echo "Generate subdefs 20 \n";
|
||||
self::$record_20->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a20'] = true;
|
||||
}
|
||||
if (self::$record_21 instanceof record_adapter && !isset(self::$generated_subdefs['a21']))
|
||||
{
|
||||
echo "Generate subdefs 21 \n";
|
||||
self::$record_21->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a21'] = true;
|
||||
}
|
||||
if (self::$record_22 instanceof record_adapter && !isset(self::$generated_subdefs['a22']))
|
||||
{
|
||||
echo "Generate subdefs 22 \n";
|
||||
self::$record_22->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a22'] = true;
|
||||
}
|
||||
if (self::$record_23 instanceof record_adapter && !isset(self::$generated_subdefs['a23']))
|
||||
{
|
||||
echo "Generate subdefs 23 \n";
|
||||
self::$record_23->generate_subdefs(self::$collection->get_databox());
|
||||
self::$generated_subdefs['a23'] = true;
|
||||
}
|
||||
@@ -1171,121 +1194,145 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
{
|
||||
if ((static::$need_records === true || static::$need_records >= 1) && !self::$record_1 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 1\n";
|
||||
self::$record_sf_1 = new system_file(__DIR__ . '/testfiles/test001.CR2');
|
||||
self::$record_1 = record_adapter::create(self::$collection, self::$record_sf_1);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 1) && !self::$record_no_access instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 1\n";
|
||||
$file = new system_file(__DIR__ . '/testfiles/test001.CR2');
|
||||
self::$record_no_access = record_adapter::create(self::$collection_no_access, $file);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 2) && !self::$record_2 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 2\n";
|
||||
self::$record_sf_2 = new system_file(__DIR__ . '/testfiles/test002.CR2');
|
||||
self::$record_2 = record_adapter::create(self::$collection, self::$record_sf_2);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 3) && !self::$record_3 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 3\n";
|
||||
self::$record_sf_3 = new system_file(__DIR__ . '/testfiles/test003.CR2');
|
||||
self::$record_3 = record_adapter::create(self::$collection, self::$record_sf_3);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 4) && !self::$record_4 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 4\n";
|
||||
self::$record_sf_4 = new system_file(__DIR__ . '/testfiles/test004.CR2');
|
||||
self::$record_4 = record_adapter::create(self::$collection, self::$record_sf_4);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 5) && !self::$record_5 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 5\n";
|
||||
self::$record_sf_5 = new system_file(__DIR__ . '/testfiles/test005.CR2');
|
||||
self::$record_5 = record_adapter::create(self::$collection, self::$record_sf_5);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 6) && !self::$record_6 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 6\n";
|
||||
self::$record_sf_6 = new system_file(__DIR__ . '/testfiles/test006.wav');
|
||||
self::$record_6 = record_adapter::create(self::$collection, self::$record_sf_6);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 7) && !self::$record_7 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 7\n";
|
||||
self::$record_sf_7 = new system_file(__DIR__ . '/testfiles/test007.ppt');
|
||||
self::$record_7 = record_adapter::create(self::$collection, self::$record_sf_7);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 8) && !self::$record_8 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 8\n";
|
||||
self::$record_sf_8 = new system_file(__DIR__ . '/testfiles/test008.ai');
|
||||
self::$record_8 = record_adapter::create(self::$collection, self::$record_sf_8);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 9) && !self::$record_9 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 9\n";
|
||||
self::$record_sf_9 = new system_file(__DIR__ . '/testfiles/test009.TIFF');
|
||||
self::$record_9 = record_adapter::create(self::$collection, self::$record_sf_9);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 10) && !self::$record_10 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 10\n";
|
||||
self::$record_sf_10 = new system_file(__DIR__ . '/testfiles/test010.fla');
|
||||
self::$record_10 = record_adapter::create(self::$collection, self::$record_sf_10);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 11) && !self::$record_11 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 11\n";
|
||||
self::$record_sf_11 = new system_file(__DIR__ . '/testfiles/test011.swf');
|
||||
self::$record_11 = record_adapter::create(self::$collection, self::$record_sf_11);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 12) && !self::$record_12 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 12\n";
|
||||
self::$record_sf_12 = new system_file(__DIR__ . '/testfiles/test012.wav');
|
||||
self::$record_12 = record_adapter::create(self::$collection, self::$record_sf_12);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 13) && !self::$record_13 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 13\n";
|
||||
self::$record_sf_13 = new system_file(__DIR__ . '/testfiles/test013.ai');
|
||||
self::$record_13 = record_adapter::create(self::$collection, self::$record_sf_13);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 14) && !self::$record_14 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 14\n";
|
||||
self::$record_sf_14 = new system_file(__DIR__ . '/testfiles/test014.swf');
|
||||
self::$record_14 = record_adapter::create(self::$collection, self::$record_sf_14);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 15) && !self::$record_15 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 15\n";
|
||||
self::$record_sf_15 = new system_file(__DIR__ . '/testfiles/test015.eps');
|
||||
self::$record_15 = record_adapter::create(self::$collection, self::$record_sf_15);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 16) && !self::$record_16 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 16\n";
|
||||
self::$record_sf_16 = new system_file(__DIR__ . '/testfiles/test016.ai');
|
||||
self::$record_16 = record_adapter::create(self::$collection, self::$record_sf_16);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 17) && !self::$record_17 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 17\n";
|
||||
self::$record_sf_17 = new system_file(__DIR__ . '/testfiles/test017.wav');
|
||||
self::$record_17 = record_adapter::create(self::$collection, self::$record_sf_17);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 18) && !self::$record_18 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 18\n";
|
||||
self::$record_sf_18 = new system_file(__DIR__ . '/testfiles/test018.TIFF');
|
||||
self::$record_18 = record_adapter::create(self::$collection, self::$record_sf_18);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 19) && !self::$record_19 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 19\n";
|
||||
self::$record_sf_19 = new system_file(__DIR__ . '/testfiles/test019.mp3');
|
||||
self::$record_19 = record_adapter::create(self::$collection, self::$record_sf_19);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 20) && !self::$record_20 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 20\n";
|
||||
self::$record_sf_20 = new system_file(__DIR__ . '/testfiles/test020.mp3');
|
||||
self::$record_20 = record_adapter::create(self::$collection, self::$record_sf_20);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 21) && !self::$record_21 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 21\n";
|
||||
self::$record_sf_21 = new system_file(__DIR__ . '/testfiles/test021.fla');
|
||||
self::$record_21 = record_adapter::create(self::$collection, self::$record_sf_21);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 22) && !self::$record_22 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 22\n";
|
||||
self::$record_sf_22 = new system_file(__DIR__ . '/testfiles/test022.swf');
|
||||
self::$record_22 = record_adapter::create(self::$collection, self::$record_sf_22);
|
||||
}
|
||||
if ((static::$need_records === true || static::$need_records >= 23) && !self::$record_23 instanceof record_adapter)
|
||||
{
|
||||
echo "generate story 23\n";
|
||||
self::$record_sf_23 = new system_file(__DIR__ . '/testfiles/test023.mp4');
|
||||
self::$record_23 = record_adapter::create(self::$collection, self::$record_sf_23);
|
||||
}
|
||||
|
@@ -261,10 +261,13 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
}
|
||||
|
||||
$metadatas = array_shift($metadatas);
|
||||
$metadatas["value"] = array("new_value");
|
||||
$metadatas["value"] = "new_value";
|
||||
|
||||
|
||||
$request = new Request(array("metadatas" => array($metadatas)), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
||||
|
||||
$result = $this->object->set_record_metadatas($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
|
||||
|
||||
$this->checkResponseField($result, "metadatas", PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT);
|
||||
}
|
||||
|
||||
|
@@ -257,7 +257,7 @@ class system_fileTest extends PhraseanetPHPUnitAbstract
|
||||
$this->assertArrayHasKey('meta_struct_id', $metadata);
|
||||
$this->assertArrayHasKey('meta_id', $metadata);
|
||||
$this->assertArrayHasKey('value', $metadata);
|
||||
$this->assertTrue(is_array($metadata['value']));
|
||||
$this->assertTrue(is_scalar($metadata['value']));
|
||||
$this->assertNull($metadata['meta_id']);
|
||||
$this->assertTrue(is_int($metadata['meta_struct_id']));
|
||||
$this->assertTrue($metadata['meta_struct_id'] > 0);
|
||||
|
@@ -19,9 +19,10 @@ class unitTestsTest extends PhraseanetPHPUnitAbstract
|
||||
continue;
|
||||
if (substr($file->getFilename(), -4) !== '.php')
|
||||
continue;
|
||||
if($file->getFilename() === "BoilerPlate.php")
|
||||
continue;
|
||||
|
||||
|
||||
$this->assertRegExp('/[a-zA-Z0-9-_\.]+Test.php/', $file->getFilename(), 'Verify that all tests files names');
|
||||
$this->assertRegExp('/[a-zA-Z0-9-_\.]+Test.php/', $file->getPathname(), 'Verify that all tests files names');
|
||||
}
|
||||
}
|
||||
|
||||
|
2
lib/vendor/Silex
vendored
2
lib/vendor/Silex
vendored
Submodule lib/vendor/Silex updated: 90c2c4209a...95541210d0
2
lib/vendor/Twig
vendored
2
lib/vendor/Twig
vendored
Submodule lib/vendor/Twig updated: 3fbe8d8c46...396435ecd0
2
lib/vendor/Twig-extensions
vendored
2
lib/vendor/Twig-extensions
vendored
Submodule lib/vendor/Twig-extensions updated: a05ab5ed18...3076c97197
Reference in New Issue
Block a user