Created
October 6, 2012 09:32
-
-
Save christianjul/3844492 to your computer and use it in GitHub Desktop.
Simple commandcontroller and aspect to demo how to use 3rd party components - and AOP on it - in TYPO3 Flow
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 Julle\Demo\Command; | |
/* * | |
* This script belongs to the TYPO3 Flow package "Julle.Demo". * | |
* * | |
* */ | |
use TYPO3\Flow\Annotations as Flow; | |
/** | |
* dostuff command controller for the Julle.Demo package | |
* | |
* @Flow\Scope("singleton") | |
*/ | |
class DostuffCommandController extends \TYPO3\Flow\Cli\CommandController { | |
/** | |
* A demo command | |
* | |
* This is small example of how to utilize 3rd part components in TYPO3 Flow, initializes a Monolog-Logger and reads | |
* it's name to the output. | |
* | |
* @param string $requiredArgument This argument is required | |
* @return void | |
*/ | |
public function exampleCommand($requiredArgument) { | |
$logger = new \Monolog\Logger($requiredArgument); | |
$this->outputLine($logger->getName()); | |
} | |
} | |
?> |
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
These files are just examples, they need to be in context of a full package to be execute. You can easily create these with the TYPO3.Kickstart package. | |
Path of files relative to Packages/Application folder | |
Julle.Demo/Classes/Julle/Demo/Command/DostuffCommandController.php | |
EvilCorp.WorldDomination/Classes/EvilCorp/WorldDomination/Aspect/LoggerAspect.php |
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 EvilCorp\WorldDomination\Aspect; | |
/* * | |
* This script belongs to the TYPO3 Flow package "Julle.Demo". * | |
* * | |
* */ | |
use TYPO3\Flow\Annotations as Flow; | |
/** | |
* Standard controller for the Julle.Demo package | |
* | |
* @Flow\Aspect | |
*/ | |
class LoggerAspect { | |
/** | |
* @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint | |
* @Flow\Before("method(Monolog\Logger->__construct())") | |
* | |
* @return void | |
*/ | |
public function checkLoggerName(\TYPO3\Flow\Aop\JoinPointInterface $joinpoint) { | |
$realname = $joinpoint->getMethodArgument('name'); | |
$joinpoint->setMethodArgument('name','I Rule Everything! Screw your "' . $realname . '"!'); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment