Created
September 28, 2012 15:19
-
-
Save radmiraal/3800480 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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