jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/375799 )

Change subject: BS3: New Task base class
......................................................................


BS3: New Task base class

This is not the final implementation but a start to build upon.

A reference implementation and refinement will follow.

Change-Id: I53755cf6ae96595c3a0e094b6ccc0309083a7a84
---
A src/ITask.php
A src/StandardTask.php
2 files changed, 128 insertions(+), 0 deletions(-)

Approvals:
  Pwirth: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/ITask.php b/src/ITask.php
new file mode 100644
index 0000000..5936daa
--- /dev/null
+++ b/src/ITask.php
@@ -0,0 +1,11 @@
+<?php
+
+namespace BlueSpice;
+
+interface ITask {
+
+       /**
+        * @return \Status
+        */
+       public function execute();
+}
\ No newline at end of file
diff --git a/src/StandardTask.php b/src/StandardTask.php
new file mode 100644
index 0000000..60e5c7d
--- /dev/null
+++ b/src/StandardTask.php
@@ -0,0 +1,117 @@
+<?php
+
+namespace BlueSpice;
+
+abstract class StandardTask implements ITask {
+
+
+       /**
+        *
+        * @var Data\IStore
+        */
+       protected $dataStore = null;
+
+       /**
+        *
+        * @var \IContextSource
+        */
+       protected $context = null;
+
+       /**
+        *
+        * @var \LogPage
+        */
+       protected $actionLogger = null;
+
+       /**
+        *
+        * @var \Psr\Log\LoggerInterface
+        */
+       protected $logger = null;
+
+       /**
+        *
+        * @var \BlueSpice\Notifier
+        */
+       protected $notifier = null;
+
+       /**
+        *
+        * @var \stdClass
+        */
+       protected $taskData = null;
+
+       /**
+        *
+        * @param stdClass $taskData
+        * @param \IContextSource $context
+        * @param Data\IStore $dataStore
+        * @param ActionLogger $actionLogger
+        * @param Notifier $notifier
+        * @param \Psr\Log\LoggerInterface $logger
+        */
+       public function __construct( $taskData, $context, $dataStore, 
$actionLogger = null, $notifier = null, $logger = null ) {
+               $this->taskData = $taskData;
+
+               $this->context = $context instanceof \IContextSource
+                       ? $context
+                       : \RequestContext::getMain();
+
+               $this->dataStore = $dataStore;
+
+               $this->actionLogger = $actionLogger instanceof ActionLogger
+                       ? $actionLogger
+                       : $this->makeActionLogger();
+
+               $this->notifier = $notifier instanceof INotifier
+                       ? $notifier
+                       : NotifierFactory::newNotifier();
+
+               $this->logger = $logger instanceof \Psr\Log\LoggerInterface
+                       ? $logger
+                       : LoggerFactory::getInstance( self::class );
+       }
+
+       /**
+        *
+        * @return \Status;
+        */
+       public function execute() {
+               try {
+                       //TODO: Permission checking, Param processing and other 
stuff
+               } catch( \Exception $ex ) {
+                       return \Status::newFatal( $ex->getMessage() );
+               }
+               return $this->doExecute();
+       }
+
+       /**
+        *
+        * @return \BlueSpice\ActionLogger
+        */
+       protected function makeActionLogger() {
+               $type = $this->getActionLogType();
+               if( empty( $type ) ) {
+                       return new NullLogger();
+               }
+
+               return new ActionLogger(
+                       $type,
+                       $this->context->getUser(),
+                       $this->context->getTitle()
+               );
+       }
+
+       /**
+        * Allows for auto-creation of a proper ActionLogger to write to 
Special:Log
+        * @return string
+        */
+       protected function getActionLogType() {
+               return '';
+       }
+
+       /**
+        * @return \Status
+        */
+       abstract protected function doExecute();
+}
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/375799
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I53755cf6ae96595c3a0e094b6ccc0309083a7a84
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: master
Gerrit-Owner: Robert Vogel <[email protected]>
Gerrit-Reviewer: Ljonka <[email protected]>
Gerrit-Reviewer: Mglaser <[email protected]>
Gerrit-Reviewer: Pwirth <[email protected]>
Gerrit-Reviewer: Robert Vogel <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to