Skip to content

Commit

Permalink
Merge branch 'development' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessCoder committed Oct 26, 2017
2 parents 50f7bf3 + 523a42a commit bc1da05
Showing 53 changed files with 139 additions and 329 deletions.
5 changes: 4 additions & 1 deletion Classes/Asset.php
Original file line number Diff line number Diff line change
@@ -254,7 +254,10 @@ public function finalize()
{
$name = $this->getName();
if (true === empty($name)) {
$name = md5(spl_object_hash($this));
$name = md5($this->standalone . '//' . $this->type . '//' . $this->path . '//' . $this->content);
if ($this->fluid) {
$name .= '_' . md5(serialize($this->variables));
}
}
if (false === isset($GLOBALS['VhsAssets']) || false === is_array($GLOBALS['VhsAssets'])) {
$GLOBALS['VhsAssets'] = [];
5 changes: 4 additions & 1 deletion Classes/Service/AssetService.php
Original file line number Diff line number Diff line change
@@ -228,7 +228,10 @@ protected function insertAssetsAtMarker($markerName, $assets)
$tag = true === $inFooter ? '</body>' : '</head>';
$content = $GLOBALS['TSFE']->content;
$position = strrpos($content, $tag);
$GLOBALS['TSFE']->content = substr_replace($content, $assetMarker . LF, $position, 0);

if ($position) {
$GLOBALS['TSFE']->content = substr_replace($content, $assetMarker . LF, $position, 0);
}
}
if (true === is_array($assets)) {
$chunk = $this->buildAssetsChunk($assets);
130 changes: 1 addition & 129 deletions Classes/Traits/ConditionViewHelperTrait.php
Original file line number Diff line number Diff line change
@@ -8,137 +8,9 @@
* LICENSE.md file that was distributed with this source code.
*/

use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;

/**
* This trait can be used by viewhelpers that generate image tags
* to add srcsets based to the imagetag for better responsiveness
* @deprecated no longer required since TYPO3 7.6
*/
trait ConditionViewHelperTrait
{

/**
* renders <f:then> child if $condition is true, otherwise renders <f:else> child.
*
* @return string the rendered string
* @api
*/
public function render()
{
if (static::evaluateCondition($this->arguments)) {
return $this->renderThenChild();
} else {
return $this->renderElseChild();
}
}

/**
* Default implementation for use in compiled templates
*
* TODO: remove at some point, because this is only here for legacy reasons.
* the AbstractConditionViewHelper in 6.2.* doesn't have a default render
* method. 7.2+ on the other hand provides basically exactly this method here
* luckily it's backwards compatible out of the box.
* tl;dr -> remove after expiration of support for anything below 7.2
*
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
static public function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
) {
$hasEvaluated = true;
if (static::evaluateCondition($arguments)) {
$result = static::renderStaticThenChild($arguments, $hasEvaluated);
if ($hasEvaluated) {
return $result;
}

return $renderChildrenClosure();
} else {
$result = static::renderStaticElseChild($arguments, $hasEvaluated);
if ($hasEvaluated) {
return $result;
}
}

return '';
}

/**
* Statically evalute "then" children.
* The "$hasEvaluated" argument is there to distinguish the case that "then" returned NULL or was not evaluated.
*
* TODO: remove at some point, because this is only here for legacy reasons.
* the AbstractConditionViewHelper in 6.2.* doesn't have a default render
* method. 7.2+ on the other hand provides basically exactly this method here
* luckily it's backwards compatible out of the box.
* tl;dr -> remove after expiration of support for anything below 7.2
*
* @param array $arguments ViewHelper arguments
* @param bool $hasEvaluated Can be used to check if the "then" child was actually evaluated by this method.
* @return string
*/
static protected function renderStaticThenChild($arguments, &$hasEvaluated)
{
if (isset($arguments['then'])) {
return $arguments['then'];
}
if (isset($arguments['__thenClosure'])) {
$thenClosure = $arguments['__thenClosure'];
return $thenClosure();
} elseif (isset($arguments['__elseClosure'])) {
return '';
}

$hasEvaluated = false;
}

/**
* Statically evalute "else" children.
* The "$hasEvaluated" argument is there to distinguish the case that "else" returned NULL or was not evaluated.
*
* TODO: remove at some point, because this is only here for legacy reasons.
* the AbstractConditionViewHelper in 6.2.* doesn't have a default render
* method. 7.2+ on the other hand provides basically exactly this method here
* luckily it's backwards compatible out of the box.
* tl;dr -> remove after expiration of support for anything below 7.2
*
* @param array $arguments ViewHelper arguments
* @param bool $hasEvaluated Can be used to check if the "else" child was actually evaluated by this method.
* @return string
*/
static protected function renderStaticElseChild($arguments, &$hasEvaluated)
{
if (isset($arguments['else'])) {
return $arguments['else'];
}
if (isset($arguments['__elseClosure'])) {
$elseClosure = $arguments['__elseClosure'];
return $elseClosure();
}

$hasEvaluated = false;
}

/**
* This method decides if the condition is TRUE or FALSE.
*
* TODO: remove at some point, because this is only here for legacy reasons.
* the AbstractConditionViewHelper in 6.2.* doesn't have a default render
* method. 7.2+ on the other hand provides basically exactly this method here
* luckily it's backwards compatible out of the box.
* tl;dr -> remove after expiration of support for anything below 7.2
*
* @param array $arguments
* @return bool
*/
static protected function evaluateCondition($arguments = null)
{
return (isset($arguments['condition']) && $arguments['condition']);
}
}
1 change: 1 addition & 0 deletions Classes/View/UncacheTemplateView.php
Original file line number Diff line number Diff line change
@@ -84,6 +84,7 @@ public function callUserFunction($postUserFunc, $conf, $content)
/** @var RenderingContext $renderingContext */
$renderingContext = $this->objectManager->get(RenderingContext::class);
$this->prepareContextsForUncachedRendering($renderingContext, $controllerContext);
$this->setControllerContext($controllerContext);
return $this->renderPartialUncached($renderingContext, $partial, $section, $arguments);
}

4 changes: 0 additions & 4 deletions Classes/ViewHelpers/Condition/Context/IsBackendViewHelper.php
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
*/

use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;

/**
* ### Condition: Is context Backend?
@@ -35,9 +34,6 @@
*/
class IsBackendViewHelper extends AbstractConditionViewHelper
{

use ConditionViewHelperTrait;

/**
* @param array $arguments
* @return bool
4 changes: 0 additions & 4 deletions Classes/ViewHelpers/Condition/Context/IsCliViewHelper.php
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
*/

use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;

/**
* ### Condition: Is context CLI?
@@ -35,9 +34,6 @@
*/
class IsCliViewHelper extends AbstractConditionViewHelper
{

use ConditionViewHelperTrait;

/**
* @param array $arguments
* @return bool
Original file line number Diff line number Diff line change
@@ -11,8 +11,6 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;

use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;

/**
* ### Context: IsDevelopment
*
@@ -28,9 +26,6 @@
*/
class IsDevelopmentViewHelper extends AbstractConditionViewHelper
{

use ConditionViewHelperTrait;

/**
* @param array $arguments
* @return bool
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
*/

use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;

/**
* ### Condition: Is context Frontend?
@@ -35,9 +34,6 @@
*/
class IsFrontendViewHelper extends AbstractConditionViewHelper
{

use ConditionViewHelperTrait;

/**
* @param array $arguments
* @return bool
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;

/**
* ### Context: IsProduction
@@ -27,9 +26,6 @@
*/
class IsProductionViewHelper extends AbstractConditionViewHelper
{

use ConditionViewHelperTrait;

/**
* @param array $arguments
* @return bool
4 changes: 0 additions & 4 deletions Classes/ViewHelpers/Condition/Context/IsTestingViewHelper.php
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;

/**
* ### Context: IsProduction
@@ -27,9 +26,6 @@
*/
class IsTestingViewHelper extends AbstractConditionViewHelper
{

use ConditionViewHelperTrait;

/**
* @param array $arguments
* @return bool
4 changes: 0 additions & 4 deletions Classes/ViewHelpers/Condition/Form/HasValidatorViewHelper.php
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@
use TYPO3\CMS\Extbase\Reflection\ReflectionService;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
use TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperVariableContainer;
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
use TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper;

/**
@@ -26,9 +25,6 @@
*/
class HasValidatorViewHelper extends AbstractConditionViewHelper
{

use ConditionViewHelperTrait;

/**
* @var string
*/
4 changes: 0 additions & 4 deletions Classes/ViewHelpers/Condition/Iterator/ContainsViewHelper.php
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@
use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;

/**
* Condition ViewHelper. Renders the then-child if Iterator/array
@@ -26,9 +25,6 @@
*/
class ContainsViewHelper extends AbstractConditionViewHelper
{

use ConditionViewHelperTrait;

/**
* Initialize arguments
*/
4 changes: 0 additions & 4 deletions Classes/ViewHelpers/Condition/Page/HasSubpagesViewHelper.php
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;

/**
* ### Condition: Page has subpages
@@ -25,9 +24,6 @@
*/
class HasSubpagesViewHelper extends AbstractConditionViewHelper
{

use ConditionViewHelperTrait;

/**
* @var PageService
*/
4 changes: 0 additions & 4 deletions Classes/ViewHelpers/Condition/Page/IsChildPageViewHelper.php
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@

use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
use TYPO3\CMS\Frontend\Page\PageRepository;
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;

/**
* ### Condition: Page is child page
@@ -22,9 +21,6 @@
*/
class IsChildPageViewHelper extends AbstractConditionViewHelper
{

use ConditionViewHelperTrait;

/**
* Initialize arguments
*/
4 changes: 0 additions & 4 deletions Classes/ViewHelpers/Condition/Page/IsLanguageViewHelper.php
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
*/

use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;

/**
* ### Condition: Is current language
@@ -22,9 +21,6 @@
*/
class IsLanguageViewHelper extends AbstractConditionViewHelper
{

use ConditionViewHelperTrait;

/**
* Initialize arguments
*/
4 changes: 0 additions & 4 deletions Classes/ViewHelpers/Condition/String/ContainsViewHelper.php
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
*/

use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;

/**
* ### Condition: String contains substring
@@ -19,9 +18,6 @@
*/
class ContainsViewHelper extends AbstractConditionViewHelper
{

use ConditionViewHelperTrait;

/**
* Initialize arguments
*/
Loading
Oops, something went wrong.

0 comments on commit bc1da05

Please sign in to comment.