Skip to content

Commit

Permalink
Merge pull request #4 from ElementareTeilchen/task/upgrade
Browse files Browse the repository at this point in the history
!!! TASK: Change in Neos vendor namespace
  • Loading branch information
dlubitz authored Feb 6, 2017
2 parents 3b6faf3 + 7ff1684 commit 5f07d2a
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 82 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?php

namespace VIVOMEDIA\Fusion\CacheVisualisation\Aspects;

namespace VIVOMEDIA\TypoScript\CacheVisualisation\Aspects;


use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Object\Configuration\Configuration;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Aop\JoinPointInterface;
use Neos\Flow\ObjectManagement\Configuration\Configuration;

/**
* @Flow\Aspect()
*
* @package VIVOMEDIA\TypoScript\CacheVisualisation\Aspects
* @package VIVOMEDIA\Fusion\CacheVisualisation\Aspects
*/
class ContentCacheVisualisationAspect
{
Expand All @@ -26,62 +25,68 @@ class ContentCacheVisualisationAspect

/**
*
* @param \TYPO3\Flow\AOP\JoinPointInterface $joinPoint The current join point
* @param JoinPointInterface $joinPoint The current join point
*
* @return mixed Result of the target method
* @Flow\Before("method(TYPO3\TypoScript\Core\Cache\ContentCache->createCacheSegment()) && setting(VIVOMEDIA.TypoScript.CacheVisualisation.enabled)")
* @Flow\Before("method(Neos\Fusion\Core\Cache\ContentCache->createCacheSegment()) && setting(VIVOMEDIA.Fusion.CacheVisualisation.enabled)")
*/
public function wrapContentCacheCachedSegment(\TYPO3\Flow\AOP\JoinPointInterface $joinPoint)
public function wrapContentCacheCachedSegment(JoinPointInterface $joinPoint)
{
$content = $joinPoint->getMethodArgument('content');
$path = $joinPoint->getMethodArgument('typoScriptPath');
$lifetime = $joinPoint->getMethodArgument('lifetime') ? (new \DateTime)->setTimestamp($joinPoint->getMethodArgument('lifetime'))->format('U = c') : 'null';
$lifetime = $joinPoint->getMethodArgument('lifetime') ? (new \DateTime)->setTimestamp($joinPoint->getMethodArgument('lifetime'))
->format('U = c') : 'null';

if (!$this->_checkBlacklistedPath($path)) {
$parameter = [
'path' => $path,
'tags' => implode(',', $joinPoint->getMethodArgument('tags')),
'lifetime' => $lifetime
'lifetime' => $lifetime,
];
$content = $this->_wrapContent(self::TYPE_CACHED, $content, $parameter);

$joinPoint->setMethodArgument('content', $content);
}
}

private function _checkBlacklistedPath($path)
{
$blacklist = $this->_configuration['pathBlacklist'];

return in_array($path, $blacklist);
}

private function _wrapContent($type, $content, $parameter)
{
$wrapperClasses = [
'default' => $this->_configuration['output']['wrapperClassName'],
'item' => $this->_configuration['output']['itemClassName'][$type],
];
$content = '<div class="' . implode(' ', $wrapperClasses) . '" data-vivomedia-cache-visualisation=\'' . json_encode($parameter) . '\'>' . $content . '</div>';

return $content;
}

/**
*
* @param \TYPO3\Flow\AOP\JoinPointInterface $joinPoint The current join point
* @param JoinPointInterface $joinPoint The current join point
*
* @return mixed Result of the target method
* @Flow\Around("method(TYPO3\TypoScript\Core\Cache\ContentCache->createUncachedSegment()) && setting(VIVOMEDIA.TypoScript.CacheVisualisation.enabled)")
* @Flow\Around("method(Neos\Fusion\Core\Cache\ContentCache->createUncachedSegment()) && setting(VIVOMEDIA.Fusion.CacheVisualisation.enabled)")
*/
public function wrapContentCacheUncachedSegment(\TYPO3\Flow\AOP\JoinPointInterface $joinPoint)
public function wrapContentCacheUncachedSegment(JoinPointInterface $joinPoint)
{
$content = $joinPoint->getAdviceChain()->proceed($joinPoint);
$path = $joinPoint->getMethodArgument('typoScriptPath');

if (!$this->_checkBlacklistedPath($path)) {
$parameter = [
'path' => $path,
'context' => array_keys($joinPoint->getMethodArgument('contextVariables'))
'context' => array_keys($joinPoint->getMethodArgument('contextVariables')),
];
$content = $this->_wrapContent(self::TYPE_UNCACHED, $content, $parameter);
}
return $content;
}

private function _wrapContent($type, $content, $parameter)
{
$wrapperClasses = [
'default' => $this->_configuration['output']['wrapperClassName'],
'item' => $this->_configuration['output']['itemClassName'][$type]
];
$content = '<div class="' . implode(' ', $wrapperClasses) . '" data-vivomedia-cache-visualisation=\'' . json_encode($parameter) . '\'>' . $content . '</div>';
return $content;
}

private function _checkBlacklistedPath($path)
{
$blacklist = $this->_configuration['pathBlacklist'];
return in_array($path, $blacklist);
}
}
4 changes: 2 additions & 2 deletions Configuration/Development/Settings.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VIVOMEDIA:
TypoScript:
Fusion:
CacheVisualisation:
enabled: TRUE
enabled: true
18 changes: 9 additions & 9 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
TYPO3:
Neos:
Neos:
typoScript:
fusion:
autoInclude:
'VIVOMEDIA.TypoScript.CacheVisualisation': TRUE
'VIVOMEDIA.Fusion.CacheVisualisation': true

VIVOMEDIA:
TypoScript:
Fusion:
CacheVisualisation:
enabled: FALSE
enabled: false
output:
wrapperClassName: 'vivomedia-cachevisualisation'
itemClassName:
cached: 'vivomedia-cachevisualisation-cached'
uncached: 'vivomedia-cachevisualisation-uncached'
pathBlacklist:
- 'root'
- 'root<TYPO3.TypoScript:Case>/default'
- 'root<TYPO3.TypoScript:Case>/default<TYPO3.TypoScript:Matcher>/element<TYPO3.Neos.NodeTypes:Page.Document>'
- 'root<TYPO3.TypoScript:Case>/default<TYPO3.TypoScript:Matcher>/element<TYPO3.Neos.NodeTypes:Page.Document>/head<TYPO3.TypoScript:Array>/neosBackendEndpoints'
- 'root<TYPO3.TypoScript:Case>/default<TYPO3.TypoScript:Matcher>/element<TYPO3.Neos.NodeTypes:Page.Document>/head<TYPO3.TypoScript:Array>/neosBackendHeader'
- 'root<Neos.Fusion:Case>/default'
- 'root<Neos.Fusion:Case>/default<Neos.Fusion:Matcher>/element<Neos.NodeTypes:Page.Document>'
- 'root<Neos.Fusion:Case>/default<Neos.Fusion:Matcher>/element<Neos.NodeTypes:Page.Document>/head<Neos.Fusion:Array>/neosBackendEndpoints'
- 'root<Neos.Fusion:Case>/default<Neos.Fusion:Matcher>/element<Neos.NodeTypes:Page.Document>/head<Neos.Fusion:Array>/neosBackendHeader'
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# TypoScript Cache Visualisation
Helps to debug cache configurations in [Neos TypoScript](https://github.com/neos/typoscript/).
# Fusion Cache Visualisation
Helps to debug cache configurations in [Neos Fusion](https://github.com/neos/typoscript/).

This is just a debugging tool and highly recommended just to use in development context.
This is just a debugging tool and highly recommended to use in development context only.

## What it provides
This plugin add a wrapper around all cached and uncached segments to visualise them. Also it provides additional informations for each segement:
This plugin adds a wrapper around all cached and uncached segments to visualise them. Also it provides additional information for each segement:

Cached Segments
* TypoScript path
* Fusion path
* Cache tags
* Lifetime

Uncached Segments
* TypoScript path
* Fusion path
* Context variable names

# Install
## Composer
Install via composer as a dev package
```bash
php composer.phar require --dev "vivomedia/typoscript-cachevisualisation" "~0.3"
php composer.phar require --dev "vivomedia/fusion-cachevisualisation" "^1.0"
```

## Flow
Expand All @@ -36,12 +36,12 @@ You can enable and disable the plugin within your `Settings.yaml`

```yaml
VIVOMEDIA:
TypoScript:
Fusion:
CacheVisualisation:
enabled: TRUE # Or false
enabled: true # Or false
```
Is is enabled by default for the development context.
It is enabled by default for the development context.
Please keep in mind to clear the cache after enabling/disabling the plugin.
Expand Down
25 changes: 25 additions & 0 deletions Resources/Private/Fusion/Root.fusion
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
prototype(Page){
head {
cacheVisualisationCss = Neos.Fusion:Tag {
tagName = 'link'
attributes {
rel = ${'stylesheet'}
href = Neos.Fusion:ResourceUri {
path = 'resource://VIVOMEDIA.Fusion.CacheVisualisation/Public/css/cachevisualisation.css'
}
}
@if.onlyRenderNotInBackend = ${!node.context.inBackend}
}
}

cacheVisualisationJs = Neos.Fusion:Tag {
@position = 'before closingBodyTag'
tagName = 'script'
attributes {
src = Neos.Fusion:ResourceUri {
path = 'resource://VIVOMEDIA.Fusion.CacheVisualisation/Public/js/cachevisualisation.js'
}
}
@if.onlyRenderNotInBackend = ${!node.context.inBackend}
}
}
25 changes: 0 additions & 25 deletions Resources/Private/TypoScript/Root.ts2

This file was deleted.

16 changes: 10 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
{
"name": "vivomedia/typoscript-cachevisualisation",
"type": "typo3-flow-package",
"description": "Tool to debug cache configurations in Neos TypoScript",
"name": "vivomedia/fusion-cachevisualisation",
"type": "neos-plugin",
"description": "Tool to debug cache configurations in Neos Fusion",
"license": "MIT",
"authors": [
{
"name": "Denny Lubitz"
}
],
"require": {
"typo3/typoscript": "*"
"neos/flow": "^4.0.0",
"neos/fusion": "^3.0.0"
},
"replace": {
"vivomedia/typoscript-cachevisualisation": "self.version"
},
"autoload": {
"psr-0": {
"VIVOMEDIA\\TypoScript\\CacheVisualisation": "Classes"
"psr-4": {
"VIVOMEDIA\\Fusion\\CacheVisualisation\\": "Classes"
}
}
}

0 comments on commit 5f07d2a

Please sign in to comment.