Feature #49988
Backport ApplicationContext from Flow
Status: | Resolved | Start date: | 2013-07-17 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | - | % Done: | 100% |
|
Category: | - | Spent time: | - | |
Target version: | - | |||
PHP Version: | Sprint Focus: | |||
Complexity: |
Description
Flow has the notion of ApplicationContext which provides a unique API for handling contexts.
Having this API in TYPO3 CMS would allow us to provide default configuration sets for particular contexts. For example having decent logging in production context vs. full reports in development context.
Extension developers would also benefit from streamlining their custom solutions to a single API.
The context is set using the TYPO3_CONTEXT environment variable.
Here's an example of how to set this variable in apache htaccess:
RewriteCond %{HTTP_HOST} ^dev\.example\.com$ RewriteRule (.*) $1 [E=TYPO3_CONTEXT:Development] RewriteCond %{HTTP_HOST} ^www\.example\.com$ RewriteRule (.*) $1 [E=TYPO3_CONTEXT:Production]
The particular context can be obtained in the following way:
\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->getContext() # shorthand to predefined contexts: \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->getContext()->isDevelopment(); \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->getContext()->isProduction(); ...
Subtasks
Related issues
Associated revisions
[FEATURE] Backport ApplicationContext from Flow
Flow has the notion of ApplicationContext which provides a unique
API for handling contexts.
This API allow us to provide default configuration sets for
particular contexts. For example having decent logging in
production context vs. full reports in development context.
The context is set using the TYPO3_CONTEXT environment variable.
If not set the context defaults to "Production".
The context can be queried using:
\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->getContext();
Resolves: #49988
Releases: 6.2
Change-Id: Id953052f2846c740f27a83931adfb64b0d8d9169
Reviewed-on: https://review.typo3.org/22269
Reviewed-by: Thomas Maroschik
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
History
#1 Updated by Gerrit Code Review about 2 years ago
- Status changed from New to Under Review
Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/22269
#2 Updated by Steffen Müller about 2 years ago
Find this blog article by Matthias Witte about TYPO3 FLOW contexts.
#3 Updated by Fabien Udriot about 2 years ago
Quoting Christian Kuhn from http://forge.typo3.org/issues/39441#note-2
Imho FLOW has a way better concept at this point: It has an object for context and subcontexts, they can be extended and new subcontexts can be added. This is the way to go for us, too. I think, Thomas is working on a similar thing in his sandbox and has something at hand already.
I don't really know the "subcontexts" of Flow... It looks it is mentioned in the Flow documentation. Wondering if we are able of such things...
#4 Updated by Steffen Müller about 2 years ago
Yes, subcontexts are part of Flow and also part of the backport. See line 79 of ApplicationContext.php
We'd have static contexts "Production", "Development" and "Testing" and custom subcontexts, like Production/Staging, "Development/Debug", "Testing/Unit" etc.
So the root context is not extendable, but the subcontexts are.
The whole backport is 1:1 from Flow, so the Flow documentation would also be valid for us.
#5 Updated by Gerrit Code Review about 2 years ago
Patch set 2 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/22269
#6 Updated by Gerrit Code Review about 2 years ago
Patch set 3 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/22269
#7 Updated by Gerrit Code Review about 2 years ago
Patch set 4 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/22269
#8 Updated by Gerrit Code Review about 2 years ago
Patch set 5 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/22269
#9 Updated by Gerrit Code Review about 2 years ago
Patch set 6 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/22269
#10 Updated by Steffen Müller about 2 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 8fdab46dbd167b1969dcb30b823f3f3e591d03a2.
#11 Updated by Mathias Brodala about 2 years ago
Why was this marked as resolved already? The configuration part is still missing and needs work in the core ConfigurationManager AFAIS since that's what Flow does.
#12 Updated by Stefan Neufeind about 2 years ago
It was set Resolved by gerrit since the patch was merged.
Imho this was about the "core" of it (ApplicationContext). What other changes we'll have now depending on the current context are imho follow-ups to this. Maybe file separate issues and link them here.
Thanks for caring.
#13 Updated by Mathias Brodala about 2 years ago
Stefan Neufeind wrote:
It was set Resolved by gerrit since the patch was merged.
Imho this was about the "core" of it (ApplicationContext). What other changes we'll have now depending on the current context are imho follow-ups to this. Maybe file separate issues and link them here.
OK, got it. Thanks for clarifying. :-)
#14 Updated by Ingo Renner about 2 years ago
just extracted two issues from #39441 - see the linked sub tasks