Skip to content

Instantly share code, notes, and snippets.

@radmiraal
Created September 28, 2012 15:19
Show Gist options
  • Save radmiraal/3800480 to your computer and use it in GitHub Desktop.
Save radmiraal/3800480 to your computer and use it in GitHub Desktop.
<?php
namespace Radmiraal\Iks\Aop;
use TYPO3\FLOW3\Annotations as FLOW3;
/**
* @FLOW3\Aspect
*/
class HomePageProtectionAspect {
/**
* @param \TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint
* @FLOW3\Around("method(TYPO3\TYPO3CR\Domain\Model\Node->set.*())")
* @return void
*/
public function secureHomePagePathRename(\TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint) {
if ($this->isTargetNodeIsProtected($joinPoint)) {
return;
}
$joinPoint->getAdviceChain()->proceed($joinPoint);
}
/**
* @param \TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint
* @return boolean
*/
protected function isTargetNodeIsProtected(\TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint) {
$node = $joinPoint->getProxy();
$nodePathParts = explode('/', $node->getPath());
if (count($nodePathParts) < 5 || (count($nodePathParts) === 5 && $nodePathParts[4] === 'home')) {
return TRUE;
}
return FALSE;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment