mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-08 10:34:34 +00:00
Use composer as application autoloader
This commit is contained in:
@@ -24,7 +24,7 @@ use Alchemy\Phrasea\Command\RecordAdd;
|
||||
use Alchemy\Phrasea\Command\CreateCollection;
|
||||
use Alchemy\Phrasea\CLI;
|
||||
|
||||
require_once dirname(__FILE__) . '/../lib/bootstrap.php';
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
try {
|
||||
$app = new CLI("
|
||||
|
@@ -31,7 +31,7 @@ use Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand;
|
||||
use Doctrine\ORM\Tools\Console\Command\RunDqlCommand;
|
||||
use Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand;
|
||||
|
||||
require_once dirname(__FILE__) . '/../lib/bootstrap.php';
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
try {
|
||||
$cli = new CLI("Phraseanet Doctrine Console");
|
||||
|
@@ -21,7 +21,7 @@ use Alchemy\Phrasea\Command\UpgradeDBDatas;
|
||||
use Alchemy\Phrasea\Command\Setup\Install;
|
||||
use Alchemy\Phrasea\CLI;
|
||||
|
||||
require_once dirname(__FILE__) . '/../lib/bootstrap.php';
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
try {
|
||||
$app = new CLI("
|
||||
|
10
builder.php
10
builder.php
@@ -5,15 +5,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
printf('Retrieve vendors ...' . PHP_EOL);
|
||||
|
||||
system('./vendors.php --no-dev');
|
||||
|
||||
require_once __DIR__ . '/lib/classes/bootstrap.class.php';
|
||||
|
||||
\bootstrap::register_autoloads();
|
||||
|
||||
use Symfony\Component\Finder\Finder;
|
||||
system(__DIR__ . '/composer.phar dump-autoload');
|
||||
|
||||
chdir(__DIR__);
|
||||
|
||||
|
@@ -5,12 +5,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/lib/classes/bootstrap.class.php';
|
||||
|
||||
\bootstrap::register_autoloads();
|
||||
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
chdir(__DIR__);
|
||||
|
||||
set_time_limit(0);
|
||||
|
@@ -55,7 +55,15 @@
|
||||
],
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Alchemy": "lib"
|
||||
}
|
||||
"": "lib/classes",
|
||||
"Alchemy": "lib",
|
||||
"Doctrine": "lib",
|
||||
"Entities": "lib/Doctrine",
|
||||
"Types": "lib/Doctrine",
|
||||
"Repositories": "lib/Doctrine",
|
||||
"Proxies": "lib/Doctrine",
|
||||
"PhraseaFixture": "lib/conf.d"
|
||||
}
|
||||
},
|
||||
"include-path": ["vendor/zend/gdata/library"]
|
||||
}
|
||||
|
@@ -1,17 +1,12 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../lib/classes/bootstrap.class.php';
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
\bootstrap::register_autoloads();
|
||||
$core = \bootstrap::execute('dev');
|
||||
|
||||
$console = new Application('Functionnal tests for dailymotion API');
|
||||
|
||||
$console
|
||||
|
@@ -30,7 +30,6 @@ class ConnectionTest implements ControllerProviderInterface
|
||||
* @todo : check this as it would lead to a security issue
|
||||
*/
|
||||
$controllers->get('/mysql/', function(Application $app) {
|
||||
require_once __DIR__ . '/../../../../classes/connection/pdo.class.php';
|
||||
|
||||
$request = $app['request'];
|
||||
$hostname = $request->query->get('hostname', '127.0.0.1');
|
||||
|
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2012 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Loader;
|
||||
|
||||
require_once __DIR__ . '/LoaderStrategy.php';
|
||||
require_once __DIR__ . '/../../../../vendor/doctrine/common/lib/Doctrine/Common/Cache/Cache.php';
|
||||
require_once __DIR__ . '/../../../../vendor/doctrine/common/lib/Doctrine/Common/Cache/CacheProvider.php';
|
||||
require_once __DIR__ . '/../../../../vendor/doctrine/common/lib/Doctrine/Common/Cache/ApcCache.php';
|
||||
|
||||
use Alchemy\Phrasea\Loader\LoaderStrategy as CacheStrategy;
|
||||
use Doctrine\Common\Cache\ApcCache;
|
||||
|
||||
/**
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
Class ApcAutoloader extends ApcCache implements CacheStrategy
|
||||
{
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isAvailable()
|
||||
{
|
||||
return extension_loaded('apc');
|
||||
}
|
||||
}
|
@@ -1,104 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2012 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Loader;
|
||||
|
||||
require_once __DIR__ . "/../../../../vendor/symfony/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php";
|
||||
|
||||
use Symfony\Component\ClassLoader\UniversalClassLoader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Autoloader extends UniversalClassLoader
|
||||
{
|
||||
/**
|
||||
* An array of path to check
|
||||
* @var type
|
||||
*/
|
||||
private $paths = array();
|
||||
private $classmap = array();
|
||||
|
||||
/**
|
||||
* Construct a new phrasea Autoloader
|
||||
* Because some custom classes from library folder might be
|
||||
* overwritten in config folder
|
||||
* Phraseanet Loader look classes in configuration folders first
|
||||
* then check library folder if no classes where matched
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->paths['config'] = __DIR__ . '/../../../../config/classes/';
|
||||
$this->paths['library'] = __DIR__ . '/../../../classes/';
|
||||
|
||||
$getComposerClassMap = function() {
|
||||
return require realpath(__DIR__ . '/../../../../vendor/composer/autoload_classmap.php');
|
||||
};
|
||||
|
||||
$this->classmap = $getComposerClassMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
if ( ! $file = $this->checkFile($class)) {
|
||||
$file = parent::findFile($class);
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a path to look for autoloading phraseanet classes
|
||||
* @param string $name
|
||||
* @param string $path
|
||||
*/
|
||||
public function addPath($name, $path)
|
||||
{
|
||||
$this->paths[$name] = \p4string::addEndSlash($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a class with $class name exists
|
||||
* foreach declared paths
|
||||
* @param string $class
|
||||
* @return mixed string|null
|
||||
*/
|
||||
private function checkFile($classname)
|
||||
{
|
||||
if (isset($this->classmap[$classname])) {
|
||||
return $this->classmap[$classname];
|
||||
}
|
||||
|
||||
$normalized_classname = str_replace('_', '/', $classname);
|
||||
|
||||
foreach ($this->paths as $path) {
|
||||
$file = $path . $normalized_classname . '.class.php';
|
||||
|
||||
if (file_exists($file)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Paths where classes are checked for autoloading
|
||||
* @return Array
|
||||
*/
|
||||
public function getPaths()
|
||||
{
|
||||
return $this->paths;
|
||||
}
|
||||
}
|
@@ -1,128 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2012 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Loader;
|
||||
|
||||
require_once __DIR__ . '/Autoloader.php';
|
||||
|
||||
/**
|
||||
* Loop throught op cache code adapter to cache autoloading
|
||||
* OpCache code available are apc et xcache
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class CacheAutoloader extends Autoloader
|
||||
{
|
||||
/**
|
||||
* Array of all cache adapters
|
||||
* @var type
|
||||
*/
|
||||
private $cacheAdapters = array(
|
||||
'Apc',
|
||||
'Xcache'
|
||||
);
|
||||
|
||||
/**
|
||||
* The cache adapater
|
||||
* @var type
|
||||
*/
|
||||
private $cacheAdapter;
|
||||
|
||||
/**
|
||||
* The prefix used to store id's in cache
|
||||
* @var string
|
||||
*/
|
||||
private $prefix;
|
||||
|
||||
/**
|
||||
* Take a identifier cache key prefix
|
||||
* @param string $prefix
|
||||
* @throws \Exceptionwhen none of the op cache code are available
|
||||
*/
|
||||
public function __construct($prefix, $namespace = null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->prefix = $prefix;
|
||||
|
||||
foreach ($this->cacheAdapters as $className) {
|
||||
$file = sprintf("%s/%sAutoloader.php", __DIR__, $className);
|
||||
|
||||
if ( ! file_exists($file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
require_once $file;
|
||||
|
||||
$className = sprintf("\Alchemy\Phrasea\Loader\%sAutoloader", $className);
|
||||
|
||||
if ( ! class_exists($className)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$method = new $className();
|
||||
|
||||
if ($namespace) {
|
||||
$method->setNamespace($namespace);
|
||||
}
|
||||
|
||||
if ($method instanceof LoaderStrategy && $method->isAvailable()) {
|
||||
$this->cacheAdapter = $method;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $this->cacheAdapter) {
|
||||
throw new \Exception('No Cache available');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
$file = $this->cacheAdapter->fetch($this->prefix . $class);
|
||||
|
||||
if (false === $file) {
|
||||
$this->cacheAdapter->save($this->prefix . $class, $file = parent::findFile($class));
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current cache Adapter
|
||||
* @return LoaderStrategy
|
||||
*/
|
||||
public function getAdapter()
|
||||
{
|
||||
return $this->cacheAdapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the identifier cache key prefix
|
||||
* @return string
|
||||
*/
|
||||
public function getPrefix()
|
||||
{
|
||||
return $this->prefix;
|
||||
}
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2012 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Loader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
interface LoaderStrategy
|
||||
{
|
||||
|
||||
/**
|
||||
* Check wether the cacheAdapter is available
|
||||
* @Return boolean
|
||||
*/
|
||||
public function isAvailable();
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2012 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Loader;
|
||||
|
||||
require_once __DIR__ . '/LoaderStrategy.php';
|
||||
require_once __DIR__ . '/../../../../vendor/doctrine/common/lib/Doctrine/Common/Cache/Cache.php';
|
||||
require_once __DIR__ . '/../../../../vendor/doctrine/common/lib/Doctrine/Common/Cache/CacheProvider.php';
|
||||
require_once __DIR__ . '/../../../../vendor/doctrine/common/lib/Doctrine/Common/Cache/XcacheCache.php';
|
||||
|
||||
use Alchemy\Phrasea\Loader\LoaderStrategy as CacheStrategy;
|
||||
use Doctrine\Common\Cache\XcacheCache;
|
||||
|
||||
/**
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
Class XcacheAutoloader extends XcacheCache implements CacheStrategy
|
||||
{
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isAvailable()
|
||||
{
|
||||
return extension_loaded('xcache') && PHP_SAPI !== 'cli';
|
||||
}
|
||||
}
|
@@ -13,10 +13,6 @@ namespace Entities;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
|
||||
require_once __DIR__ . '/../../classes/cache/cacheableInterface.class.php';
|
||||
require_once __DIR__ . '/../../classes/User/Interface.class.php';
|
||||
require_once __DIR__ . '/../../classes/User/Adapter.class.php';
|
||||
|
||||
/**
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
|
@@ -13,9 +13,6 @@ namespace Entities;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
|
||||
require_once __DIR__ . '/../../classes/record/Interface.class.php';
|
||||
require_once __DIR__ . '/../../classes/record/adapter.class.php';
|
||||
|
||||
/**
|
||||
* Kernel
|
||||
*
|
||||
|
@@ -13,12 +13,6 @@ namespace Entities;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
|
||||
require_once __DIR__ . '/../../classes/record/Interface.class.php';
|
||||
require_once __DIR__ . '/../../classes/record/adapter.class.php';
|
||||
require_once __DIR__ . '/../../classes/cache/cacheableInterface.class.php';
|
||||
require_once __DIR__ . '/../../classes/User/Interface.class.php';
|
||||
require_once __DIR__ . '/../../classes/User/Adapter.class.php';
|
||||
|
||||
/**
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
|
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2012 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @return \Alchemy\Phrasea\Core
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
require_once __DIR__ . '/classes/bootstrap.class.php';
|
||||
|
||||
bootstrap::register_autoloads();
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user