Skip to content

Commit

Permalink
Merge pull request #7 from daniellienert/task/reformat-code-to-psr-2
Browse files Browse the repository at this point in the history
TASK: Reformat code to PSR2
  • Loading branch information
dfeyer authored Aug 1, 2016
2 parents d18ad07 + 48f8902 commit 4a6d66b
Show file tree
Hide file tree
Showing 10 changed files with 799 additions and 736 deletions.
36 changes: 19 additions & 17 deletions Classes/Ttree/Scheduler/Annotations/Schedule.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace Ttree\Scheduler\Annotations;

/* *
* This script belongs to the TYPO3 Flow package "Ttree.Scheduler". *
* *
Expand All @@ -19,22 +20,23 @@
* @Annotation
* @Target("CLASS")
*/
final class Schedule {

/**
* @var string
*/
public $expression;
final class Schedule
{

/**
* @param array $values
*/
public function __construct(array $values) {
if (isset($values['expression'])) {
$this->expression = (string)$values['expression'];
} else {
$this->expression = '* * * * *';
}
}
/**
* @var string
*/
public $expression;

}
/**
* @param array $values
*/
public function __construct(array $values)
{
if (isset($values['expression'])) {
$this->expression = (string)$values['expression'];
} else {
$this->expression = '* * * * *';
}
}
}
98 changes: 52 additions & 46 deletions Classes/Ttree/Scheduler/Aspect/LoggingAspect.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace Ttree\Scheduler\Aspect;

/* *
* This script belongs to the TYPO3 Flow package "Ttree.Scheduler". *
* *
Expand All @@ -21,56 +22,61 @@
* @Flow\Aspect
* @Flow\Scope("singleton")
*/
class LoggingAspect {

/**
* @Flow\Inject
* @var SystemLoggerInterface
*/
protected $systemLogger;
class LoggingAspect
{

/**
* @Flow\Inject
* @var PersistenceManagerInterface
*/
protected $persistenceManager;
/**
* @Flow\Inject
* @var SystemLoggerInterface
*/
protected $systemLogger;

/**
* @Flow\Pointcut("within(Ttree\Scheduler\Task\TaskInterface) && method(.*->execute())")
*/
public function allTasks() {}
/**
* @Flow\Inject
* @var PersistenceManagerInterface
*/
protected $persistenceManager;

/**
* @Flow\Before("Ttree\Scheduler\Aspect\LoggingAspect->allTasks")
* @param JoinPoint $jointPoint
*/
public function logTaskExecutionBegin(JoinPoint $jointPoint) {
/** @var TaskInterface $task */
$task = $jointPoint->getProxy();
$this->systemLogger->log(sprintf('Task "%s" execution started', get_class($task)));
}
/**
* @Flow\Pointcut("within(Ttree\Scheduler\Task\TaskInterface) && method(.*->execute())")
*/
public function allTasks()
{
}

/**
* @Flow\After("Ttree\Scheduler\Aspect\LoggingAspect->allTasks")
* @param JoinPoint $jointPoint
*/
public function logTaskExecutionEnd(JoinPoint $jointPoint) {
/** @var Task $task */
$task = $jointPoint->getProxy();
$this->systemLogger->log(sprintf('Task "%s" execution finished', get_class($task)));
}
/**
* @Flow\Before("Ttree\Scheduler\Aspect\LoggingAspect->allTasks")
* @param JoinPoint $jointPoint
*/
public function logTaskExecutionBegin(JoinPoint $jointPoint)
{
/** @var TaskInterface $task */
$task = $jointPoint->getProxy();
$this->systemLogger->log(sprintf('Task "%s" execution started', get_class($task)));
}

/**
* @Flow\AfterThrowing("Ttree\Scheduler\Aspect\LoggingAspect->allTasks")
* @param JoinPoint $jointPoint
* @throws \Exception
*/
public function logTaskException(JoinPoint $jointPoint) {
/** @var Task $task */
$exception = $jointPoint->getException();
$this->systemLogger->logException($exception, array(
'task' => $jointPoint->getClassName()
));
}
/**
* @Flow\After("Ttree\Scheduler\Aspect\LoggingAspect->allTasks")
* @param JoinPoint $jointPoint
*/
public function logTaskExecutionEnd(JoinPoint $jointPoint)
{
/** @var Task $task */
$task = $jointPoint->getProxy();
$this->systemLogger->log(sprintf('Task "%s" execution finished', get_class($task)));
}

/**
* @Flow\AfterThrowing("Ttree\Scheduler\Aspect\LoggingAspect->allTasks")
* @param JoinPoint $jointPoint
* @throws \Exception
*/
public function logTaskException(JoinPoint $jointPoint)
{
/** @var Task $task */
$exception = $jointPoint->getException();
$this->systemLogger->logException($exception, [
'task' => $jointPoint->getClassName()
]);
}
}
Loading

0 comments on commit 4a6d66b

Please sign in to comment.