Initial commit
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\ViewHelpers\Condition\Context;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
|
||||
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
|
||||
|
||||
/**
|
||||
* ### Condition: Is context Backend?
|
||||
*
|
||||
* A condition ViewHelper which renders the `then` child if
|
||||
* current context being rendered is BE.
|
||||
*
|
||||
* ### Examples
|
||||
*
|
||||
* <!-- simple usage, content becomes then-child -->
|
||||
* <v:condition.context.isBackend>
|
||||
* Hooray for BE contexts!
|
||||
* </v:condition.context.isBackend>
|
||||
* <!-- extended use combined with f:then and f:else -->
|
||||
* <v:condition.context.isBackend>
|
||||
* <f:then>
|
||||
* Hooray for BE contexts!
|
||||
* </f:then>
|
||||
* <f:else>
|
||||
* Maybe FE, maybe CLI.
|
||||
* </f:else>
|
||||
* </v:condition.context.isBackend>
|
||||
*
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
* @subpackage ViewHelpers\If\Context
|
||||
*/
|
||||
class IsBackendViewHelper extends AbstractConditionViewHelper {
|
||||
|
||||
use ConditionViewHelperTrait;
|
||||
|
||||
/**
|
||||
* This method decides if the condition is TRUE or FALSE. It can be overriden in extending viewhelpers to adjust functionality.
|
||||
*
|
||||
* @param array $arguments ViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexiblity in overriding this method.
|
||||
* @return bool
|
||||
*/
|
||||
static protected function evaluateCondition($arguments = NULL) {
|
||||
return ('BE' === TYPO3_MODE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\ViewHelpers\Condition\Context;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
|
||||
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
|
||||
|
||||
/**
|
||||
* ### Condition: Is context CLI?
|
||||
*
|
||||
* A condition ViewHelper which renders the `then` child if
|
||||
* current context being rendered is CLI.
|
||||
*
|
||||
* ### Examples
|
||||
*
|
||||
* <!-- simple usage, content becomes then-child -->
|
||||
* <v:condition.context.isCli>
|
||||
* Hooray for CLI contexts!
|
||||
* </v:condition.context.isCli>
|
||||
* <!-- extended use combined with f:then and f:else -->
|
||||
* <v:condition.context.isCli>
|
||||
* <f:then>
|
||||
* Hooray for CLI contexts!
|
||||
* </f:then>
|
||||
* <f:else>
|
||||
* Maybe BE, maybe FE.
|
||||
* </f:else>
|
||||
* </v:condition.context.isCli>
|
||||
*
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
* @subpackage ViewHelpers\Condition\Context
|
||||
*/
|
||||
class IsCliViewHelper extends AbstractConditionViewHelper {
|
||||
|
||||
use ConditionViewHelperTrait;
|
||||
|
||||
/**
|
||||
* This method decides if the condition is TRUE or FALSE. It can be overriden in extending viewhelpers to adjust functionality.
|
||||
*
|
||||
* @param array $arguments ViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexiblity in overriding this method.
|
||||
* @return bool
|
||||
*/
|
||||
static protected function evaluateCondition($arguments = NULL) {
|
||||
return defined('TYPO3_climode');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\ViewHelpers\Condition\Context;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
|
||||
|
||||
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
|
||||
|
||||
/**
|
||||
* ### Context: IsDevelopment
|
||||
*
|
||||
* Returns true if current root application context is development otherwise false.
|
||||
* If no application context has been set, then the default context is production.
|
||||
*
|
||||
* #### Note about how to set the application context
|
||||
*
|
||||
* The context TYPO3 CMS runs in is specified through the environment variable TYPO3_CONTEXT.
|
||||
* It can be set by .htaccess or in the server configuration
|
||||
*
|
||||
* See: http://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Bootstrapping/Index.html#bootstrapping-context
|
||||
*
|
||||
* @author Benjamin Beck <beck@beckdigitalemedien.de>
|
||||
* @package Vhs
|
||||
* @subpackage ViewHelpers\Condition\Context
|
||||
*/
|
||||
class IsDevelopmentViewHelper extends AbstractConditionViewHelper {
|
||||
|
||||
use ConditionViewHelperTrait;
|
||||
|
||||
/**
|
||||
* This method decides if the condition is TRUE or FALSE. It can be overriden in extending viewhelpers to adjust functionality.
|
||||
*
|
||||
* @param array $arguments ViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexiblity in overriding this method.
|
||||
* @return bool
|
||||
*/
|
||||
static protected function evaluateCondition($arguments = NULL) {
|
||||
return GeneralUtility::getApplicationContext()->isDevelopment();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\ViewHelpers\Condition\Context;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
|
||||
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
|
||||
|
||||
/**
|
||||
* ### Condition: Is context Frontend?
|
||||
*
|
||||
* A condition ViewHelper which renders the `then` child if
|
||||
* current context being rendered is FE.
|
||||
*
|
||||
* ### Examples
|
||||
*
|
||||
* <!-- simple usage, content becomes then-child -->
|
||||
* <v:condition.context.isFrontend>
|
||||
* Hooray for BE contexts!
|
||||
* </v:condition.context.isFrontend>
|
||||
* <!-- extended use combined with f:then and f:else -->
|
||||
* <v:condition.context.isFrontend>
|
||||
* <f:then>
|
||||
* Hooray for BE contexts!
|
||||
* </f:then>
|
||||
* <f:else>
|
||||
* Maybe BE, maybe CLI.
|
||||
* </f:else>
|
||||
* </v:condition.context.isFrontend>
|
||||
*
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
* @subpackage ViewHelpers\If\Context
|
||||
*/
|
||||
class IsFrontendViewHelper extends AbstractConditionViewHelper {
|
||||
|
||||
use ConditionViewHelperTrait;
|
||||
|
||||
/**
|
||||
* This method decides if the condition is TRUE or FALSE. It can be overriden in extending viewhelpers to adjust functionality.
|
||||
*
|
||||
* @param array $arguments ViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexiblity in overriding this method.
|
||||
* @return bool
|
||||
*/
|
||||
static protected function evaluateCondition($arguments = NULL) {
|
||||
return ('FE' === TYPO3_MODE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\ViewHelpers\Condition\Context;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
|
||||
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
|
||||
|
||||
/**
|
||||
* ### Context: IsProduction
|
||||
*
|
||||
* Returns true if current root application context is production otherwise false.
|
||||
* If no application context has been set, then this is the default context.
|
||||
*
|
||||
* #### Note about how to set the application context
|
||||
*
|
||||
* The context TYPO3 CMS runs in is specified through the environment variable TYPO3_CONTEXT.
|
||||
* It can be set by .htaccess or in the server configuration
|
||||
*
|
||||
* See: http://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Bootstrapping/Index.html#bootstrapping-context
|
||||
*
|
||||
* @author Benjamin Beck <beck@beckdigitalemedien.de>
|
||||
* @package Vhs
|
||||
* @subpackage ViewHelpers\Condition\Context
|
||||
*/
|
||||
class IsProductionViewHelper extends AbstractConditionViewHelper {
|
||||
|
||||
use ConditionViewHelperTrait;
|
||||
|
||||
/**
|
||||
* This method decides if the condition is TRUE or FALSE. It can be overriden in extending viewhelpers to adjust functionality.
|
||||
*
|
||||
* @param array $arguments ViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexiblity in overriding this method.
|
||||
* @return bool
|
||||
*/
|
||||
static protected function evaluateCondition($arguments = NULL) {
|
||||
return GeneralUtility::getApplicationContext()->isProduction();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\ViewHelpers\Condition\Context;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
|
||||
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
|
||||
|
||||
/**
|
||||
* ### Context: IsProduction
|
||||
*
|
||||
* Returns true if current root application context is testing otherwise false.
|
||||
* If no application context has been set, then the default context is production.
|
||||
*
|
||||
* #### Note about how to set the application context
|
||||
*
|
||||
* The context TYPO3 CMS runs in is specified through the environment variable TYPO3_CONTEXT.
|
||||
* It can be set by .htaccess or in the server configuration
|
||||
*
|
||||
* See: http://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Bootstrapping/Index.html#bootstrapping-context
|
||||
*
|
||||
* @author Benjamin Beck <beck@beckdigitalemedien.de>
|
||||
* @package Vhs
|
||||
* @subpackage ViewHelpers\Condition\Context
|
||||
*/
|
||||
class IsTestingViewHelper extends AbstractConditionViewHelper {
|
||||
|
||||
use ConditionViewHelperTrait;
|
||||
|
||||
/**
|
||||
* This method decides if the condition is TRUE or FALSE. It can be overriden in extending viewhelpers to adjust functionality.
|
||||
*
|
||||
* @param array $arguments ViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexiblity in overriding this method.
|
||||
* @return bool
|
||||
*/
|
||||
static protected function evaluateCondition($arguments = NULL) {
|
||||
return GeneralUtility::getApplicationContext()->isTesting();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user