Commit 458bb244 authored by Dries's avatar Dries

- Patch #1497182 by Crell, BTMash: Update to latest Symfony 2.1 code. This is...

- Patch #1497182 by Crell, BTMash: Update to latest Symfony 2.1 code. This is commit c4dfe931f1ce8827f8c02975bc0ab405bdc8d27c out of Symfony.
parent c16a978c
......@@ -55,7 +55,7 @@ static public function load($classes, $cacheDir, $name, $autoReload, $adaptive =
$reload = false;
if ($autoReload) {
$metadata = $cacheDir.'/'.$name.$extension.'.meta';
if (!file_exists($metadata) || !file_exists($cache)) {
if (!is_file($metadata) || !is_file($cache)) {
$reload = true;
} else {
$time = filemtime($cache);
......@@ -65,7 +65,7 @@ static public function load($classes, $cacheDir, $name, $autoReload, $adaptive =
$reload = true;
} else {
foreach ($meta[0] as $resource) {
if (!file_exists($resource) || filemtime($resource) > $time) {
if (!is_file($resource) || filemtime($resource) > $time) {
$reload = true;
break;
......@@ -75,7 +75,7 @@ static public function load($classes, $cacheDir, $name, $autoReload, $adaptive =
}
}
if (!$reload && file_exists($cache)) {
if (!$reload && is_file($cache)) {
require_once $cache;
return;
......
......@@ -38,6 +38,7 @@ static public function enable()
$loader->registerPrefixFallbacks($function[0]->getPrefixFallbacks());
$loader->registerNamespaces($function[0]->getNamespaces());
$loader->registerPrefixes($function[0]->getPrefixes());
$loader->useIncludePath($function[0]->getUseIncludePath());
$function[0] = $loader;
}
......
Copyright (c) 2004-2011 Fabien Potencier
Copyright (c) 2004-2012 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
......@@ -41,6 +41,10 @@
* 'Swift_' => __DIR__.'/Swift',
* ));
*
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->useIncludePath(true);
*
* // activate the autoloader
* $loader->register();
*
......@@ -60,6 +64,29 @@ class UniversalClassLoader
private $prefixes = array();
private $namespaceFallbacks = array();
private $prefixFallbacks = array();
private $useIncludePath = false;
/**
* Turns on searching the include for class files. Allows easy loading
* of installed PEAR packages
*
* @param Boolean $useIncludePath
*/
public function useIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return Boolean
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Gets the configured namespaces.
......@@ -114,7 +141,17 @@ public function registerNamespaceFallbacks(array $dirs)
}
/**
* Registers the directory to use as a fallback for class prefixes.
* Registers a directory to use as a fallback for namespaces.
*
* @param string $dir A directory
*/
public function registerNamespaceFallback($dir)
{
$this->namespaceFallbacks[] = $dir;
}
/**
* Registers directories to use as a fallback for class prefixes.
*
* @param array $dirs An array of directories
*
......@@ -125,6 +162,16 @@ public function registerPrefixFallbacks(array $dirs)
$this->prefixFallbacks = $dirs;
}
/**
* Registers a directory to use as a fallback for class prefixes.
*
* @param string $dir A directory
*/
public function registerPrefixFallback($dir)
{
$this->prefixFallbacks[] = $dir;
}
/**
* Registers an array of namespaces
*
......@@ -219,47 +266,54 @@ public function findFile($class)
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$namespace = substr($class, 0, $pos);
$className = substr($class, $pos + 1);
$normalizedClass = str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $className).'.php';
foreach ($this->namespaces as $ns => $dirs) {
if (0 !== strpos($namespace, $ns)) {
continue;
}
foreach ($dirs as $dir) {
$className = substr($class, $pos + 1);
$file = $dir.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $className).'.php';
if (file_exists($file)) {
$file = $dir.DIRECTORY_SEPARATOR.$normalizedClass;
if (is_file($file)) {
return $file;
}
}
}
foreach ($this->namespaceFallbacks as $dir) {
$file = $dir.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php';
if (file_exists($file)) {
$file = $dir.DIRECTORY_SEPARATOR.$normalizedClass;
if (is_file($file)) {
return $file;
}
}
} else {
// PEAR-like class name
$normalizedClass = str_replace('_', DIRECTORY_SEPARATOR, $class).'.php';
foreach ($this->prefixes as $prefix => $dirs) {
if (0 !== strpos($class, $prefix)) {
continue;
}
foreach ($dirs as $dir) {
$file = $dir.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $class).'.php';
if (file_exists($file)) {
$file = $dir.DIRECTORY_SEPARATOR.$normalizedClass;
if (is_file($file)) {
return $file;
}
}
}
foreach ($this->prefixFallbacks as $dir) {
$file = $dir.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $class).'.php';
if (file_exists($file)) {
$file = $dir.DIRECTORY_SEPARATOR.$normalizedClass;
if (is_file($file)) {
return $file;
}
}
}
if ($this->useIncludePath && $file = stream_resolve_include_path($normalizedClass)) {
return $file;
}
}
}
......@@ -21,5 +21,10 @@
"autoload": {
"psr-0": { "Symfony\\Component\\ClassLoader": "" }
},
"target-dir": "Symfony/Component/ClassLoader"
"target-dir": "Symfony/Component/ClassLoader",
"extra": {
"branch-alias": {
"dev-master": "2.1-dev"
}
}
}
......@@ -39,10 +39,6 @@ class EventDispatcher implements EventDispatcherInterface
*/
public function dispatch($eventName, Event $event = null)
{
if (!isset($this->listeners[$eventName])) {
return;
}
if (null === $event) {
$event = new Event();
}
......@@ -50,7 +46,13 @@ public function dispatch($eventName, Event $event = null)
$event->setDispatcher($this);
$event->setName($eventName);
if (!isset($this->listeners[$eventName])) {
return $event;
}
$this->doDispatch($this->getListeners($eventName), $eventName, $event);
return $event;
}
/**
......
......@@ -28,8 +28,10 @@ interface EventDispatcherInterface
* @param string $eventName The name of the event to dispatch. The name of
* the event is the name of the method that is
* invoked on listeners.
* @param Event $event The event to pass to the event handlers/listeners.
* If not supplied, an empty Event instance is created.
* @param Event $event The event to pass to the event handlers/listeners.
* If not supplied, an empty Event instance is created.
*
* @return Event
*
* @api
*/
......@@ -48,7 +50,9 @@ function dispatch($eventName, Event $event = null);
function addListener($eventName, $listener, $priority = 0);
/**
* Adds an event subscriber. The subscriber is asked for all the events he is
* Adds an event subscriber.
*
* The subscriber is asked for all the events he is
* interested in and added as a listener for these events.
*
* @param EventSubscriberInterface $subscriber The subscriber.
......@@ -60,35 +64,33 @@ function addSubscriber(EventSubscriberInterface $subscriber);
/**
* Removes an event listener from the specified events.
*
* @param string|array $eventName The event(s) to remove a listener from.
* @param object $listener The listener object to remove.
* @param string|array $eventName The event(s) to remove a listener from
* @param callable $listener The listener to remove
*/
function removeListener($eventName, $listener);
/**
* Removes an event subscriber.
*
* @param EventSubscriberInterface $subscriber The subscriber.
* @param EventSubscriberInterface $subscriber The subscriber
*/
function removeSubscriber(EventSubscriberInterface $subscriber);
/**
* Gets the listeners of a specific event or all listeners.
*
* @param string $eventName The name of the event.
* @param string $eventName The name of the event
*
* @return array The event listeners for the specified event, or all event
* listeners by event name.
* @return array The event listeners for the specified event, or all event listeners by event name
*/
function getListeners($eventName = null);
/**
* Checks whether an event has any registered listeners.
*
* @param string $eventName The name of the event.
* @param string $eventName The name of the event
*
* @return Boolean TRUE if the specified event has any listeners, FALSE
* otherwise.
* @return Boolean true if the specified event has any listeners, false otherwise
*/
function hasListeners($eventName = null);
}
Copyright (c) 2004-2011 Fabien Potencier
Copyright (c) 2004-2012 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
......@@ -4,7 +4,6 @@
"description": "Symfony EventDispatcher Component",
"keywords": [],
"homepage": "http://symfony.com",
"version": "2.1.0",
"license": "MIT",
"authors": [
{
......@@ -22,5 +21,10 @@
"autoload": {
"psr-0": { "Symfony\\Component\\EventDispatcher": "" }
},
"target-dir": "Symfony/Component/EventDispatcher"
"target-dir": "Symfony/Component/EventDispatcher",
"extra": {
"branch-alias": {
"dev-master": "2.1-dev"
}
}
}
......@@ -14,6 +14,7 @@
use Symfony\Component\HttpFoundation\File\Exception\FileException;
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser;
/**
* A file in the file system.
......@@ -24,425 +25,6 @@
*/
class File extends \SplFileInfo
{
/**
* A map of mime types and their default extensions.
*
* @var array
*/
static protected $defaultExtensions = array(
'application/andrew-inset' => 'ez',
'application/appledouble' => 'base64',
'application/applefile' => 'base64',
'application/commonground' => 'dp',
'application/cprplayer' => 'pqi',
'application/dsptype' => 'tsp',
'application/excel' => 'xls',
'application/font-tdpfr' => 'pfr',
'application/futuresplash' => 'spl',
'application/hstu' => 'stk',
'application/hyperstudio' => 'stk',
'application/javascript' => 'js',
'application/mac-binhex40' => 'hqx',
'application/mac-compactpro' => 'cpt',
'application/mbed' => 'mbd',
'application/mirage' => 'mfp',
'application/msword' => 'doc',
'application/ocsp-request' => 'orq',
'application/ocsp-response' => 'ors',
'application/octet-stream' => 'bin',
'application/oda' => 'oda',
'application/ogg' => 'ogg',
'application/pdf' => 'pdf',
'application/x-pdf' => 'pdf',
'application/pgp-encrypted' => '7bit',
'application/pgp-keys' => '7bit',
'application/pgp-signature' => 'sig',
'application/pkcs10' => 'p10',
'application/pkcs7-mime' => 'p7m',
'application/pkcs7-signature' => 'p7s',
'application/pkix-cert' => 'cer',
'application/pkix-crl' => 'crl',
'application/pkix-pkipath' => 'pkipath',
'application/pkixcmp' => 'pki',
'application/postscript' => 'ps',
'application/presentations' => 'shw',
'application/prs.cww' => 'cw',
'application/prs.nprend' => 'rnd',
'application/quest' => 'qrt',
'application/rtf' => 'rtf',
'application/sgml-open-catalog' => 'soc',
'application/sieve' => 'siv',
'application/smil' => 'smi',
'application/toolbook' => 'tbk',
'application/vnd.3gpp.pic-bw-large' => 'plb',
'application/vnd.3gpp.pic-bw-small' => 'psb',
'application/vnd.3gpp.pic-bw-var' => 'pvb',
'application/vnd.3gpp.sms' => 'sms',
'application/vnd.acucorp' => 'atc',
'application/vnd.adobe.xfdf' => 'xfdf',
'application/vnd.amiga.amu' => 'ami',
'application/vnd.blueice.multipass' => 'mpm',
'application/vnd.cinderella' => 'cdy',
'application/vnd.cosmocaller' => 'cmc',
'application/vnd.criticaltools.wbs+xml' => 'wbs',
'application/vnd.curl' => 'curl',
'application/vnd.data-vision.rdz' => 'rdz',
'application/vnd.dreamfactory' => 'dfac',
'application/vnd.fsc.weblaunch' => 'fsc',
'application/vnd.genomatix.tuxedo' => 'txd',
'application/vnd.hbci' => 'hbci',
'application/vnd.hhe.lesson-player' => 'les',
'application/vnd.hp-hpgl' => 'plt',
'application/vnd.ibm.electronic-media' => 'emm',
'application/vnd.ibm.rights-management' => 'irm',
'application/vnd.ibm.secure-container' => 'sc',
'application/vnd.ipunplugged.rcprofile' => 'rcprofile',
'application/vnd.irepository.package+xml' => 'irp',
'application/vnd.jisp' => 'jisp',
'application/vnd.kde.karbon' => 'karbon',
'application/vnd.kde.kchart' => 'chrt',
'application/vnd.kde.kformula' => 'kfo',
'application/vnd.kde.kivio' => 'flw',
'application/vnd.kde.kontour' => 'kon',
'application/vnd.kde.kpresenter' => 'kpr',
'application/vnd.kde.kspread' => 'ksp',
'application/vnd.kde.kword' => 'kwd',
'application/vnd.kenameapp' => 'htke',
'application/vnd.kidspiration' => 'kia',
'application/vnd.kinar' => 'kne',
'application/vnd.llamagraphics.life-balance.desktop' => 'lbd',
'application/vnd.llamagraphics.life-balance.exchange+xml' => 'lbe',
'application/vnd.lotus-1-2-3' => 'wks',
'application/vnd.mcd' => 'mcd',
'application/vnd.mfmp' => 'mfm',
'application/vnd.micrografx.flo' => 'flo',
'application/vnd.micrografx.igx' => 'igx',
'application/vnd.mif' => 'mif',
'application/vnd.mophun.application' => 'mpn',
'application/vnd.mophun.certificate' => 'mpc',
'application/vnd.mozilla.xul+xml' => 'xul',
'application/vnd.ms-artgalry' => 'cil',
'application/vnd.ms-asf' => 'asf',
'application/vnd.ms-excel' => 'xls',
'application/vnd.ms-excel.sheet.macroenabled.12' => 'xlsm',
'application/vnd.ms-lrm' => 'lrm',
'application/vnd.ms-powerpoint' => 'ppt',
'application/vnd.ms-project' => 'mpp',
'application/vnd.ms-tnef' => 'base64',
'application/vnd.ms-works' => 'base64',
'application/vnd.ms-wpl' => 'wpl',
'application/vnd.mseq' => 'mseq',
'application/vnd.nervana' => 'ent',
'application/vnd.nokia.radio-preset' => 'rpst',
'application/vnd.nokia.radio-presets' => 'rpss',
'application/vnd.oasis.opendocument.text' => 'odt',
'application/vnd.oasis.opendocument.text-template' => 'ott',
'application/vnd.oasis.opendocument.text-web' => 'oth',
'application/vnd.oasis.opendocument.text-master' => 'odm',
'application/vnd.oasis.opendocument.graphics' => 'odg',
'application/vnd.oasis.opendocument.graphics-template' => 'otg',
'application/vnd.oasis.opendocument.presentation' => 'odp',
'application/vnd.oasis.opendocument.presentation-template' => 'otp',
'application/vnd.oasis.opendocument.spreadsheet' => 'ods',
'application/vnd.oasis.opendocument.spreadsheet-template' => 'ots',
'application/vnd.oasis.opendocument.chart' => 'odc',
'application/vnd.oasis.opendocument.formula' => 'odf',
'application/vnd.oasis.opendocument.database' => 'odb',
'application/vnd.oasis.opendocument.image' => 'odi',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx',
'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => 'dotx',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'xlsx',
'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'pptx',
'application/vnd.palm' => 'prc',
'application/vnd.picsel' => 'efif',
'application/vnd.pvi.ptid1' => 'pti',
'application/vnd.quark.quarkxpress' => 'qxd',
'application/vnd.sealed.doc' => 'sdoc',
'application/vnd.sealed.eml' => 'seml',
'application/vnd.sealed.mht' => 'smht',
'application/vnd.sealed.ppt' => 'sppt',
'application/vnd.sealed.xls' => 'sxls',
'application/vnd.sealedmedia.softseal.html' => 'stml',
'application/vnd.sealedmedia.softseal.pdf' => 'spdf',
'application/vnd.seemail' => 'see',
'application/vnd.smaf' => 'mmf',
'application/vnd.sun.xml.calc' => 'sxc',
'application/vnd.sun.xml.calc.template' => 'stc',
'application/vnd.sun.xml.draw' => 'sxd',
'application/vnd.sun.xml.draw.template' => 'std',
'application/vnd.sun.xml.impress' => 'sxi',
'application/vnd.sun.xml.impress.template' => 'sti',
'application/vnd.sun.xml.math' => 'sxm',
'application/vnd.sun.xml.writer' => 'sxw',
'application/vnd.sun.xml.writer.global' => 'sxg',
'application/vnd.sun.xml.writer.template' => 'stw',
'application/vnd.sus-calendar' => 'sus',
'application/vnd.vidsoft.vidconference' => 'vsc',
'application/vnd.visio' => 'vsd',
'application/vnd.visionary' => 'vis',
'application/vnd.wap.sic' => 'sic',
'application/vnd.wap.slc' => 'slc',
'application/vnd.wap.wbxml' => 'wbxml',
'application/vnd.wap.wmlc' => 'wmlc',
'application/vnd.wap.wmlscriptc' => 'wmlsc',
'application/vnd.webturbo' => 'wtb',
'application/vnd.wordperfect' => 'wpd',
'application/vnd.wqd' => 'wqd',
'application/vnd.wv.csp+wbxml' => 'wv',
'application/vnd.wv.csp+xml' => '8bit',
'application/vnd.wv.ssp+xml' => '8bit',
'application/vnd.yamaha.hv-dic' => 'hvd',
'application/vnd.yamaha.hv-script' => 'hvs',
'application/vnd.yamaha.hv-voice' => 'hvp',
'application/vnd.yamaha.smaf-audio' => 'saf',
'application/vnd.yamaha.smaf-phrase' => 'spf',
'application/vocaltec-media-desc' => 'vmd',
'application/vocaltec-media-file' => 'vmf',
'application/vocaltec-talker' => 'vtk',
'application/watcherinfo+xml' => 'wif',
'application/wordperfect5.1' => 'wp5',
'application/x-123' => 'wk',
'application/x-7th_level_event' => '7ls',
'application/x-authorware-bin' => 'aab',
'application/x-authorware-map' => 'aam',
'application/x-authorware-seg' => 'aas',
'application/x-bcpio' => 'bcpio',
'application/x-bleeper' => 'bleep',
'application/x-bzip2' => 'bz2',
'application/x-cdlink' => 'vcd',
'application/x-chat' => 'chat',
'application/x-chess-pgn' => 'pgn',
'application/x-compress' => 'z',
'application/x-cpio' => 'cpio',
'application/x-cprplayer' => 'pqf',
'application/x-csh' => 'csh',
'application/x-cu-seeme' => 'csm',
'application/x-cult3d-object' => 'co',
'application/x-debian-package' => 'deb',
'application/x-director' => 'dcr',
'application/x-dvi' => 'dvi',
'application/x-envoy' => 'evy',
'application/x-futuresplash' => 'spl',
'application/x-gtar' => 'gtar',
'application/x-gzip' => 'gz',
'application/x-hdf' => 'hdf',
'application/x-hep' => 'hep',
'application/x-html+ruby' => 'rhtml',
'application/x-httpd-miva' => 'mv',
'application/x-httpd-php' => 'phtml',
'application/x-ica' => 'ica',
'application/x-imagemap' => 'imagemap',
'application/x-ipix' => 'ipx',
'application/x-ipscript' => 'ips',
'application/x-java-archive' => 'jar',
'application/x-java-jnlp-file' => 'jnlp',
'application/x-java-serialized-object' => 'ser',
'application/x-java-vm' => 'class',
'application/x-javascript' => 'js',
'application/x-koan' => 'skp',
'application/x-latex' => 'latex',
'application/x-mac-compactpro' => 'cpt',
'application/x-maker' => 'frm',
'application/x-mathcad' => 'mcd',
'application/x-midi' => 'mid',
'application/x-mif' => 'mif',
'application/x-msaccess' => 'mda',
'application/x-msdos-program' => 'com',
'application/x-msdownload' => 'base64',
'application/x-msexcel' => 'xls',
'application/x-msword' => 'doc',
'application/x-netcdf' => 'nc',
'application/x-ns-proxy-autoconfig' => 'pac',
'application/x-pagemaker' => 'pm5',
'application/x-perl' => 'pl',
'application/x-pn-realmedia' => 'rp',
'application/x-python' => 'py',
'application/x-quicktimeplayer' => 'qtl',
'application/x-rar-compressed' => 'rar',
'application/x-ruby' => 'rb',
'application/x-sh' => 'sh',
'application/x-shar' => 'shar',
'application/x-shockwave-flash' => 'swf',
'application/x-sprite' => 'spr',
'application/x-spss' => 'sav',
'application/x-spt' => 'spt',
'application/x-stuffit' => 'sit',
'application/x-sv4cpio' => 'sv4cpio',
'application/x-sv4crc' => 'sv4crc',
'application/x-tar' => 'tar',
'application/x-tcl' => 'tcl',
'application/x-tex' => 'tex',
'application/x-texinfo' => 'texinfo',
'application/x-troff' => 't',
'application/x-troff-man' => 'man',
'application/x-troff-me' => 'me',
'application/x-troff-ms' => 'ms',
'application/x-twinvq' => 'vqf',
'application/x-twinvq-plugin' => 'vqe',
'application/x-ustar' => 'ustar',
'application/x-vmsbackup' => 'bck',
'application/x-wais-source' => 'src',
'application/x-wingz' => 'wz',
'application/x-word' => 'base64',
'application/x-wordperfect6.1' => 'wp6',
'application/x-x509-ca-cert' => 'crt',
'application/x-zip-compressed' => 'zip',
'application/xhtml+xml' => 'xhtml',
'application/zip' => 'zip',
'audio/3gpp' => '3gpp',
'audio/amr' => 'amr',
'audio/amr-wb' => 'awb',