Commit Graph

1766 Commits

Author SHA1 Message Date
Ryan Weaver
99a509708b [HttpFoundation] Correcting the PHPDoc for the public $headers property on Response. 2011-01-09 20:00:14 +01:00
Justin Hileman
cfd4e2186f Fix UniversalClassLoader matching collisions.
The current `loadClass()` implementation tries to load a class from the first matching prefix then stops, producing false-negative results. This is especially evident in groups of related libraries, such as Doctrine:

    Doctrine
    Doctrine\Common
    Doctrine\Common\DataFixtures
    Doctrine\DBAL
    Doctrine\DBAL\Migrations

Each of these libraries is submoduled into a different vendor directory. Depending on what order these libraries are added to a UniversalClassLoader instance, classes may or may not actually be loaded. This fix continues searching registered namespaces and prefixes if the first partial match is negative.
2011-01-06 18:05:57 +01:00
Jordi Boggiano
584769dd16 [HttpFoundation] Added removeFlash & clearFlashes methods to the Session 2011-01-05 22:50:03 +01:00
Bernhard Schussek
48af2fc86e [Form][FrameworkBundle][HttpFoundation] The session is now automatically started when a form is CSRF protected 2011-01-03 22:07:04 +01:00
Bernhard Schussek
8513082007 [Form][HttpFoundation] Improved File and UploadedFile class 2011-01-03 22:06:56 +01:00
Fabien Potencier
49a3e52fa8 [HttpFoundation] changed the default name of the session to _SESS as using _SESSION does not seem to work with PHP 5.3.3 (the session starts for each request) 2010-12-31 10:53:18 +01:00
Bulat Shakirzyanov
f8a88e822f [HttpFoundation] added ArraySessionStorage for usage in tests 2010-12-23 08:30:44 +01:00
Jordi Boggiano
3d9b13f240 CS: Unified non-strict equality comparisons, put var on the right side 2010-12-21 08:51:27 +01:00
Jordi Boggiano
4f46235ab0 [HttpFoundation] Send proper charset along with the default text/html header 2010-12-16 10:23:53 +01:00
Jordi Boggiano
583340db7b [HttpFoundation] Added a way to grab the request body as a resource 2010-12-13 07:55:40 +01:00
Jordi Boggiano
9fef10f67d [HttpFoundation] Fixed indenting 2010-12-13 07:53:09 +01:00
jeff
e6d0385778 [HttpFoundation] fixed Request::create() when using HTTPS and getUri()/getPathForUri() when script name should be removed.
Original explanation from pull request:

I'm Using symfony2 with URL Rewriting to 'hide' index.php.
On form authentication, symfony2 redirect to http://host:port/index.php/login_path instead of http://host:port/login_path. I do understand that, in my case, redirect is set into one of :
FormAuthenticationEntryPoint with getUriForPath()
FormAuthenticationListener with getUriForPath()
Security/Firewal/ExceptionListener with getUri()

This path modify getUri and getUriForPath to :
remove default port from URI
remove script name if not initially present
2010-12-12 14:08:35 +01:00
Fabien Potencier
a7c81577c7 [HttpFoundation] added a way to retrieve raw body from a request 2010-12-12 09:05:03 +01:00
Jordi Boggiano
fb41389999 [HttpFoundation] Fixed Request::create handling of full URIs 2010-12-08 07:52:33 +01:00
Jordi Boggiano
f6bc712028 [HttpFoundation] Always force the request method to full caps 2010-12-08 07:28:18 +01:00
Fabien Potencier
e8672740c7 [HttpFoundation] allowed any HTTP method for a Request 2010-12-08 07:24:37 +01:00
Jordi Boggiano
a832885960 [HttpFoundation] Fixed default netmask to be restricted to one IP 2010-12-06 18:32:39 +01:00
Justin Hileman
112fb5ad99 Fix Request::overrideGlobals $_COOKIE global var reference. 2010-12-06 08:12:40 +01:00
Jordi Boggiano
cc05b09a29 [HttpFoundation] Standardize flash messages api 2010-11-26 14:44:39 +01:00
Fabien Potencier
944d91c1df made some method name changes to have a better coherence throughout the framework
When an object has a "main" many relation with related "things" (objects,
parameters, ...), the method names are normalized:

 * get()
 * set()
 * all()
 * replace()
 * remove()
 * clear()
 * isEmpty()
 * add()
 * register()
 * count()
 * keys()

The classes below follow this method naming convention:

 * BrowserKit\CookieJar -> Cookie
 * BrowserKit\History -> Request
 * Console\Application -> Command
 * Console\Application\Helper\HelperSet -> HelperInterface
 * DependencyInjection\Container -> services
 * DependencyInjection\ContainerBuilder -> services
 * DependencyInjection\ParameterBag\ParameterBag -> parameters
 * DependencyInjection\ParameterBag\FrozenParameterBag -> parameters
 * DomCrawler\Form -> FormField
 * EventDispatcher\Event -> parameters
 * Form\FieldGroup -> Field
 * HttpFoundation\HeaderBag -> headers
 * HttpFoundation\ParameterBag -> parameters
 * HttpFoundation\Session -> attributes
 * HttpKernel\Profiler\Profiler -> DataCollectorInterface
 * Routing\RouteCollection -> Route
 * Security\Authentication\AuthenticationProviderManager -> AuthenticationProviderInterface
 * Templating\Engine -> HelperInterface
 * Translation\MessageCatalogue -> messages

The usage of these methods are only allowed when it is clear that there is a
main relation:

 * a CookieJar has many Cookies;

 * a Container has many services and many parameters (as services is the main
   relation, we use the naming convention for this relation);

 * a Console Input has many arguments and many options. There is no "main"
   relation, and so the naming convention does not apply.

For many relations where the convention does not apply, the following methods
must be used instead (where XXX is the name of the related thing):

 * get()      -> getXXX()
 * set()      -> setXXX()
 * all()      -> getXXXs()
 * replace()  -> setXXXs()
 * remove()   -> removeXXX()
 * clear()    -> clearXXX()
 * isEmpty()  -> isEmptyXXX()
 * add()      -> addXXX()
 * register() -> registerXXX()
 * count()    -> countXXX()
 * keys()
2010-11-25 17:30:06 +01:00
Bernhard Schussek
d95d33666d [HttpFoundation] Fixed class Request to convert empty files to NULL 2010-11-23 06:51:17 +01:00
Dominique Bongiraud
73daccd6c3 [HttpFoundation] Fixed coding style, fixed wrong parameter method, added omitted split ip and added upper limit to the netmask ip 2010-11-22 22:28:21 +01:00
ornicar
faf0182be0 [HttpFoundation] Rename HeaderBag::validateCookieName to HeaderBag::validateCookie 2010-11-21 15:24:52 +01:00
Fabien Potencier
b6923dd7b9 changed Cache-Control default value behavior
The PHP native cache limiter feature has been disabled as this is now managed
by the HeaderBag class directly instead (see below.)

The HeaderBag class uses the following rules to define a sensible and
convervative default value for the Response 'Cache-Control' header:

 * If no cache header is defined ('Cache-Control', 'ETag', 'Last-Modified',
   and 'Expires'), 'Cache-Control' is set to 'no-cache';

 * If 'Cache-Control' is empty, its value is set to "private, max-age=0,
   must-revalidate";

 * But if at least one 'Cache-Control' directive is set, and no 'public' or
   'private' directives have been explicitely added, Symfony2 adds the
   'private' directive automatically (except when 's-maxage' is set.)

So, remember to explicitly add the 'public' directive to 'Cache-Control' when
you want shared caches to store your application resources:

    // The Response is private by default
    $response->setEtag($etag);
    $response->setLastModified($date);
    $response->setMaxAge(10);

    // Change the Response to be public
    $response->setPublic();

    // Set cache settings in one call
    $response->setCache(array(
        'etag'          => $etag,
        'last_modified' => $date,
        'max_age'       => 10,
        'public'        => true,
    ));
2010-11-18 17:05:05 +01:00
Jordi Boggiano
e69c5ae860 Coding style fixes 2010-11-18 07:00:03 +01:00
Fabien Potencier
a45baed812 [HttpFoundation] removed optimization for setLocale() as it breaks when locale is not the default and the user wants to switch back to the default locale 2010-11-15 09:50:01 +01:00
Ryan Weaver
58a240baba [HttpFoundation] Allow the SERVER_PORT key of the server ParameterBag in Request to be a string value without confusing Request::getHttpHost().
The idea of a string port is probably semantically wrong, but it actually follows the convention of at least some web servers ($_SERVER['SERVER_PORT'] is actually a string). And since the $port variable is used as a string in getHttpHost(), it's correct to allow the types not to match.
2010-11-15 09:45:59 +01:00
Ryan Weaver
81272b22fa [HttpFoundation] Adding PHPDoc to the Request class and removing two unused variables. 2010-11-13 16:03:57 +01:00
Fabien Potencier
98f3ac65f4 fixed configuration bugs 2010-11-12 20:11:22 +01:00
Fabien Potencier
7257571be4 [HttpFoundation] added missing code for last commit 2010-11-12 19:49:01 +01:00
Fabien Potencier
942104a5ff [HttpFoundation] added a setCache() method to ease setting the HTTP cache headers in one simple call 2010-11-12 19:46:39 +01:00
Fabien Potencier
f669674293 [HttpFoundation] added a missing phpdoc 2010-11-12 19:46:22 +01:00
Fabien Potencier
f6ddeeb36b [HttpFoundation] added Response::setPublic() and changed setPrivate() to not take any argument 2010-11-12 19:45:28 +01:00
Fabien Potencier
51a3d0ba6a refactored session configuration
The configuration names have been changed to avoid confusion (user was
ambiguous)

    Before:
          <app:user default_locale="fr">
              <app:session name="SYMFONY" type="Native" lifetime="3600" />
          </app:user>

    After:
          <app:session default_locale="fr" name="SYMFONY" storage_id="native" lifetime="3600" />
2010-11-10 10:47:03 +01:00
Fabien Potencier
7b02766373 fixed session management
Some explanations on how it works now:

 * The Session is an optional dependency of the Request. If you create the
   Request yourself (which is mandatory now in the front controller) and if
   you don't inject a Session yourself (which is recommended if you want the
   session to be configured via dependency injection), the Symfony2 Kernel
   will associate the Session configured in the Container with the Request
   automatically.

 * When duplicating a request, the session is shared between the parent and
   the child (that's because duplicated requests are sub-requests of the main
   one most of the time.) Notice that when you use ::create(), the behavior is
   the same as for the constructor; no session is attached to the Request.

 * Symfony2 tries hard to not create a session cookie when it is not needed
   but a Session object is always available (the cookie is only created when
   "something" is stored in the session.)

 * Symfony2 only starts a session when:

   * A session already exists in the request ($_COOKIE[session_name()] is
     defined -- this is done by RequestListener);

   * There is something written in the session object (the cookie will be sent
     to the Client).

 * Notice that reading from the session does not start the session anymore (as
   we don't need to start a new session to get the default values, and because
   if a session exists, it has already been started by RequestListener.)
2010-11-09 22:34:48 +01:00
Johannes Schmitt
6aacfa3216 fixes a bug where in most cases cookies with path / were not set properly 2010-11-03 18:33:50 +01:00
Fabien Potencier
dd9b77ed96 [HttpFoundation] added Response::setVary() 2010-10-30 21:02:05 +02:00
jeff
ae888b80f6 [HttpFoundation] removed port number from HOST header
To be consistent with backup values (SERVER_NAME, SERVER_ADDR).
fix a problem with getUriForPath($path) where port number may be present twice.
2010-10-28 15:14:48 +02:00
jeff
a5d4acc54d [HttpFoundation] updated get() signature to get($key, $default = null, $first = true)
This is more consistent with the get() method of ParameterBag
2010-10-28 15:12:48 +02:00
Fabien Potencier
c448429e62 [HttpFoundation] fixed date format for HTTP headers (format must be RFC1123, not RFC2822 -- the difference is that RFC1123 dates always use GMT for the timezone) 2010-10-27 10:56:56 +02:00
Bernhard Schussek
e9fcacdad7 [HttpFoundation] Fixed: File/UploadedFile did not adjust path when moved 2010-10-22 08:30:14 +02:00
Justin Hileman
0ccc9805f5 Fix UniversalClassLoader issues with leading slashes.
This fixes a bug in UniversalClassLoader when attempting to autoload class names with leading slashes:

    $namespacedClass = "\\Foo\\Bar";
    $pearlikeClass   = "\\Foo_Bar";

    $namespaced = new $namespacedClass();
    $pearlike   = new $pearlikeClass();

`UniversalClassLoader::loadClass()` was unable to load PEAR-like classes with leading slashes because it found the slash and assumed that the requested class was namespaced. It was unable to load namespaced classes with leading slashes because it would look them up in the autoloader's registered namespaces, and was unable to match '\Foo' to 'Foo'. One (ugly) workaround for the namespaced classes was to register all namespaces twice:

    $loader->registerNamespaces(array(
        'Foo'  => __DIR__ . '/lib',
        '\Foo' => __DIR__ . '/lib',
    ));

But that's not very pretty, nor does it solve the bug with PEAR-like classes. Stripping the leading slash before trying to autoload allows UniversalClassLoader to load both namespaced and PEAR-like classes.
2010-10-20 14:20:12 +02:00
Fabien Potencier
0fc6b15c17 [HttpFoundation] added a way to clear the session attributes 2010-10-19 13:13:20 +02:00
Fabien Potencier
94347f73c5 [HttpFoundation] added a way to generate a URI based on the current one and a path 2010-10-19 13:13:14 +02:00
Kris Wallsmith
f79e23ffb5 Removed all those spaces after @author that were bothering me so… 2010-10-18 16:55:41 +02:00
Kris Wallsmith
0b1f3145ae Removed unnecessary "public" from interface method signatures. 2010-10-18 16:55:09 +02:00
pborreli
86cc6a11d9 [Component] Fixed some spelling typos 2010-10-17 07:51:50 +02:00
Fabien Potencier
2a9ddee162 [HttpFoundation] added Session::invalidate() 2010-10-12 08:58:12 +02:00
Fabien Potencier
fafcd02684 [HttpFoundation] changed RequestMatcher pattern syntax 2010-10-07 19:12:53 +02:00
Fabien Potencier
caa9d82746 [HttpFoundation] added support for attributes in RequestMatcher 2010-10-05 20:20:28 +02:00
Jordi Boggiano
d28b9ddcda [HttpFoundation] Fix session::remove() not initializing the session 2010-09-30 07:17:44 +02:00
Fabien Potencier
d657adbfa2 removed Symfony\Framework
Things have been moved to Symfony\Component\HttpKernel
and Symfony\Bundle\FrameworkBundle

The kernel configuration namespace was removed and merged
with the main web configuration namespace (kernel:config => web:config,
kernel:test => web:test, and kernel:session => web:session):

Before:
<kernel:config charset="UTF-8" error_handler="null" />

<web:config csrf-secret="xxxxxxxxxx">
    <web:router resource="%kernel.root_dir%/config/routing.xml" />
    <web:validation enabled="true" annotations="true" />
</web:config>

After:
<web:config csrf-secret="xxxxxxxxxx" charset="UTF-8" error-handler="null">
    <web:router resource="%kernel.root_dir%/config/routing.xml" />
    <web:validation enabled="true" annotations="true" />
</web:config>

Renamed classes:

Symfony\{Framework => Bundle\FrameworkBundle}\Cache\Cache
Symfony\{Framework => Bundle\FrameworkBundle}\Client
Symfony\{Framework => Bundle\FrameworkBundle}\Debug\EventDispatcher
Symfony\{Framework => Bundle\FrameworkBundle}\Debug\EventDispatcherTraceableInterface
Symfony\{Framework => Bundle\FrameworkBundle}\EventDispatcher
Symfony\{Framework => Component\HttpFoundation}\UniversalClassLoader
Symfony\{Framework => Component\HttpKernel}\Bundle\Bundle
Symfony\{Framework => Component\HttpKernel}\Bundle\BundleInterface
Symfony\{Framework => Component\HttpKernel}\ClassCollectionLoader
Symfony\{Framework => Component\HttpKernel}\Debug\ErrorException
Symfony\{Framework => Component\HttpKernel}\Debug\ErrorHandler
Symfony\{Bundle\FrameworkBundle => Component\HttpKernel}\Debug\ExceptionListener
Symfony\{Framework => Component\HttpKernel}\Kernel
2010-09-17 12:58:24 +02:00
Antoine Hérault
7bd76610ca [HttpFoundation] fixed request files handling 2010-09-10 12:34:28 +02:00
Fabien Potencier
a141c98917 [HttpFoundation] moved File Component into the HttpFoundation one 2010-09-09 17:01:48 +02:00
Kris Wallsmith
1443d4a0ba [HttpFoundation] updated getQueryString() to work in more scenarios 2010-09-06 08:48:11 +02:00
Fabien Potencier
4f337615e3 [HttpFoundation] added request matcher 2010-09-02 13:39:49 +02:00
Fabien Potencier
15cd2643c0 [HttpFoundation] added Request::getClientIp() 2010-09-01 13:56:20 +02:00
Fabien Potencier
3e24cef256 [HttpFoundation] fixed Request::hasSession() 2010-09-01 11:18:07 +02:00
ornicar
9588860716 [HttpFoundation] fixed locale accessors in Session class 2010-08-30 07:12:05 +02:00
Fabien Potencier
ed33ce4d5f [HttpFoundation] fixed typo 2010-08-29 20:28:33 +02:00
Fabien Potencier
92f4b92cbb [HttpFoundation] fixed Session serialization 2010-08-27 09:07:47 +02:00
Fabien Potencier
086708003a [HttpFoundation] added a keys() method to *Bag classes 2010-08-26 10:56:46 +02:00
Fabien Potencier
ec8500bd64 [FrameworkBundle] added support for previous exceptions in the exception pages 2010-08-24 14:01:57 +02:00
Fabien Potencier
1277568997 [HttpFoundation] fixed Session 2010-08-22 15:31:51 +02:00
Fabien Potencier
2746bcc84c [HttpFoundation] added automatic session start() when changing something in the session, renamed accessor methods, added remove()/has() methods 2010-08-20 23:21:39 +02:00
Fabien Potencier
bf82cf42dd renamed Symfony\Components to Symfony\Component 2010-08-20 23:09:55 +02:00