Skip to content

Commit

Permalink
Docs and minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian Mooyman committed Jun 20, 2017
1 parent 12bd31f commit f7946ae
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 11 deletions.
33 changes: 33 additions & 0 deletions docs/en/04_Changelogs/4.0.0.md
Expand Up @@ -245,6 +245,30 @@ Extensions
$has = DataObject::has_extension(File::class, Versioned::class); // alternate
$extensions = DataObject::get_extensions(File::class);

#### Upgrade references to Session object

Session object is no longer statically accessible via `Session::inst()`. Instead, Session
is a member of the current request.

Before:

:::php
public function httpSubmission($data, $form, $request) {
Session::set('loggedIn', null);
}


After:

:::php
public function httpSubmission($data, $form, $request) {
$requset->getSession()->set('loggedIn', null);
}


In some places it may still be necessary to access the session object where no request is available.
In rare cases it is still possible to access the request of the current controller via
`Controller::curr()->getRequest()` to gain access to the current session.

#### Compatibility with the new front-end building tools

Expand Down Expand Up @@ -1340,6 +1364,15 @@ After (`mysite/_config/config.yml`):

#### <a name="overview-general-removed"></a>General and Core Removed API

* `Session` object has had significant refactoring. This object no longer is accessed via
Session::inst(), but instead should be queried from the current request via `$request->getSession()`.
All static methods have been removed, and the `inst_` prefix removed from all instance members.
Please see the upgrading section on Session object for more details.
* Request handling has changed slightly. `Director.rules` confing no longer support
`redirect:<url>` directly via config.
* `Director::get_environment_type()` and `Director::set_environment_type()` are removed.
Get the `Kernel` instance via injector and query `getEnvironment()` instead.
E.g. `$type = Injector::inst()->get(Kernel::class)->getEnvironment();`.
* Many global methods have been refactored into `Environment` or `Convert` class.
* `increase_xdebug_nesting_level_to` removed (functionality has been inlined into `AppKernel`)
* `set_increase_time_limit_max` moved to `Environment::setTimeLimitMax()`
Expand Down
4 changes: 3 additions & 1 deletion src/Core/Environment.php
Expand Up @@ -3,7 +3,9 @@
namespace SilverStripe\Core;

/**
* Look wrapper around global environment variables
* Consolidates access and modification of PHP global variables and settings.
* This class should be used sparingly, and only if information cannot be obtained
* from a current {@link HTTPRequest} object.
*/
class Environment
{
Expand Down
20 changes: 10 additions & 10 deletions src/Core/HTTPApplication.php
Expand Up @@ -16,6 +16,16 @@ class HTTPApplication implements Application
*/
protected $middlewares = [];

/**
* @var Kernel
*/
protected $kernel;

public function __construct(Kernel $kernel)
{
$this->kernel = $kernel;
}

/**
* @return HTTPMiddleware[]
*/
Expand Down Expand Up @@ -64,16 +74,6 @@ protected function callMiddleware(HTTPRequest $request, $last)
return call_user_func($next, $request);
}

/**
* @var Kernel
*/
protected $kernel;

public function __construct(Kernel $kernel)
{
$this->kernel = $kernel;
}

/**
* Get the kernel for this application
*
Expand Down

0 comments on commit f7946ae

Please sign in to comment.