Pwirth has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/372143 )

Change subject: BSFoundation: Moved entity classes to the ps4 autoloader dir
......................................................................

BSFoundation: Moved entity classes to the ps4 autoloader dir

Change-Id: Idb7e29f796688dcc6716dca66524c06b3a12a829
---
M extension.json
D includes/content/EntityContent.php
D includes/content/EntityContentHandler.php
A src/Content/Entity.php
A src/Content/EntityHandler.php
R src/Entity.php
R src/EntityConfig.php
R src/EntityRegistry.php
8 files changed, 228 insertions(+), 226 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceFoundation 
refs/changes/43/372143/1

diff --git a/extension.json b/extension.json
index 6b6a86c..8affeca 100644
--- a/extension.json
+++ b/extension.json
@@ -572,11 +572,6 @@
                "BsSTYLEMEDIA": "includes/Common.php",
                "EXTINFO": "includes/Common.php",
                "EXTTYPE": "includes/Common.php",
-               "BSEntity": "includes/Entity.php",
-               "BSEntityRegistry": "includes/EntityRegistry.php",
-               "BSEntityConfig": "includes/entityconfigs/EntityConfig.php",
-               "BSEntityContent": "includes/content/EntityContent.php",
-               "BSEntityContentHandler": 
"includes/content/EntityContentHandler.php",
                "BSApiTestCase": "tests/BSApiTestCase.php",
                "BSFixturesProvider": "tests/BSFixturesProvider.php",
                "BSPageFixturesProvider": "tests/BSPageFixturesProvider.php",
diff --git a/includes/content/EntityContent.php 
b/includes/content/EntityContent.php
deleted file mode 100644
index 6e317f4..0000000
--- a/includes/content/EntityContent.php
+++ /dev/null
@@ -1,108 +0,0 @@
-<?php
-
-abstract class BSEntityContent extends JsonContent {
-
-       public function __construct( $text, $modelId = '' ) {
-               parent::__construct( $text, $modelId );
-       }
-
-       /**
-        * Decodes the JSON into a PHP associative array.
-        * @return array
-        */
-       public function getJsonData() {
-               return FormatJson::decode( $this->getNativeData(), true );
-       }
-
-       /**
-        * @return bool Whether content is valid JSON.
-        */
-       public function isValid() {
-               return $this->getJsonData() !== null;
-       }
-
-       /**
-        * Pretty-print JSON
-        *
-        * @return bool|null|string
-        */
-       public function beautifyJSON() {
-               $decoded = FormatJson::decode( $this->getNativeData(), true );
-               if ( !is_array( $decoded ) ) {
-                       return null;
-               }
-               return FormatJson::encode( $decoded, true );
-
-       }
-
-       /**
-        * Beautifies JSON prior to save.
-        * @param Title $title Title
-        * @param User $user User
-        * @param ParserOptions $popts
-        * @return JsonContent
-        */
-       public function preSaveTransform( Title $title, User $user, 
ParserOptions $popts ) {
-               return new static( $this->beautifyJSON() );
-       }
-
-       /**
-        * Set the HTML and add the appropriate styles
-        *
-        *
-        * @param Title $title
-        * @param int $revId
-        * @param ParserOptions $options
-        * @param bool $generateHtml
-        * @param ParserOutput $output
-        */
-       protected function fillParserOutput( Title $title, $revId,
-               ParserOptions $options, $generateHtml, ParserOutput &$output
-       ) {
-               return parent::fillParserOutput(
-                       $title,
-                       $revId,
-                       $options,
-                       $generateHtml,
-                       $output
-               );
-       }
-       /**
-        * Constructs an HTML representation of a JSON object.
-        * @param array $mapping
-        * @return string HTML
-        */
-       protected function objectTable( $mapping ) {
-               $rows = array();
-
-               foreach ( $mapping as $key => $val ) {
-                       $rows[] = $this->objectRow( $key, $val );
-               }
-               return Xml::tags( 'table', array( 'class' => 'mw-json' ),
-                       Xml::tags( 'tbody', array(), join( "\n", $rows ) )
-               );
-       }
-
-       /**
-        * Constructs HTML representation of a single key-value pair.
-        * @param string $key
-        * @param mixed $val
-        * @return string HTML.
-        */
-       protected function objectRow( $key, $val ) {
-               $th = Xml::elementClean( 'th', array(), $key );
-               if ( is_array( $val ) ) {
-                       $td = Xml::tags( 'td', array(), self::objectTable( $val 
) );
-               } else {
-                       if ( is_string( $val ) ) {
-                               $val = '"' . $val . '"';
-                       } else {
-                               $val = FormatJson::encode( $val );
-                       }
-
-                       $td = Xml::elementClean( 'td', array( 'class' => 
'value' ), $val );
-               }
-
-               return Xml::tags( 'tr', array(), $th . $td );
-       }
-}
\ No newline at end of file
diff --git a/includes/content/EntityContentHandler.php 
b/includes/content/EntityContentHandler.php
deleted file mode 100644
index ad86f3c..0000000
--- a/includes/content/EntityContentHandler.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-abstract class BSEntityContentHandler extends JsonContentHandler {
-
-       public function __construct( $modelId = '' ) {
-               parent::__construct( $modelId );
-       }
-
-       /**
-        * @return string
-        */
-       protected function getContentClass() {
-               return 'BSEntityContent';
-       }
-}
\ No newline at end of file
diff --git a/src/Content/Entity.php b/src/Content/Entity.php
new file mode 100644
index 0000000..ae5910e
--- /dev/null
+++ b/src/Content/Entity.php
@@ -0,0 +1,109 @@
+<?php
+namespace BlueSpice\Content;
+
+class Entity extends \JsonContent {
+
+       public function __construct( $text, $modelId = '' ) {
+               parent::__construct( $text, $modelId );
+       }
+
+       /**
+        * Decodes the JSON into a PHP associative array.
+        * @return array
+        */
+       public function getJsonData() {
+               return \FormatJson::decode( $this->getNativeData(), true );
+       }
+
+       /**
+        * @return bool Whether content is valid JSON.
+        */
+       public function isValid() {
+               return $this->getJsonData() !== null;
+       }
+
+       /**
+        * Pretty-print JSON
+        *
+        * @return bool|null|string
+        */
+       public function beautifyJSON() {
+               $decoded = \FormatJson::decode( $this->getNativeData(), true );
+               if ( !is_array( $decoded ) ) {
+                       return null;
+               }
+               return \FormatJson::encode( $decoded, true );
+
+       }
+
+       /**
+        * Beautifies JSON prior to save.
+        * @param \Title $title Title
+        * @param \User $user User
+        * @param ParserOptions $popts
+        * @return JsonContent
+        */
+       public function preSaveTransform( \Title $title, \User $user, 
\ParserOptions $popts ) {
+               return new static( $this->beautifyJSON() );
+       }
+
+       /**
+        * Set the HTML and add the appropriate styles
+        *
+        *
+        * @param \Title $title
+        * @param int $revId
+        * @param \ParserOptions $options
+        * @param bool $generateHtml
+        * @param \ParserOutput $output
+        */
+       protected function fillParserOutput( \Title $title, $revId,
+               \ParserOptions $options, $generateHtml, \ParserOutput &$output
+       ) {
+               return parent::fillParserOutput(
+                       $title,
+                       $revId,
+                       $options,
+                       $generateHtml,
+                       $output
+               );
+       }
+       /**
+        * Constructs an HTML representation of a JSON object.
+        * @param array $mapping
+        * @return string HTML
+        */
+       protected function objectTable( $mapping ) {
+               $rows = array();
+
+               foreach ( $mapping as $key => $val ) {
+                       $rows[] = $this->objectRow( $key, $val );
+               }
+               return \Xml::tags( 'table', array( 'class' => 'mw-json' ),
+                       \Xml::tags( 'tbody', array(), join( "\n", $rows ) )
+               );
+       }
+
+       /**
+        * Constructs HTML representation of a single key-value pair.
+        * @param string $key
+        * @param mixed $val
+        * @return string HTML.
+        */
+       protected function objectRow( $key, $val ) {
+               $th = \Xml::elementClean( 'th', array(), $key );
+               if ( is_array( $val ) ) {
+                       $td = \Xml::tags( 'td', array(), self::objectTable( 
$val ) );
+               } else {
+                       if ( is_string( $val ) ) {
+                               $val = '"' . $val . '"';
+                       } else {
+                               $val = \FormatJson::encode( $val );
+                       }
+
+                       $td = \Xml::elementClean( 'td', array( 'class' => 
'value' ), $val );
+               }
+
+               return \Xml::tags( 'tr', array(), $th . $td );
+       }
+}
\ No newline at end of file
diff --git a/src/Content/EntityHandler.php b/src/Content/EntityHandler.php
new file mode 100644
index 0000000..1cfd85e
--- /dev/null
+++ b/src/Content/EntityHandler.php
@@ -0,0 +1,16 @@
+<?php
+namespace BlueSpice\Content;
+
+abstract class EntityHandler extends \JsonContentHandler {
+
+       public function __construct( $modelId = '' ) {
+               parent::__construct( $modelId );
+       }
+
+       /**
+        * @return string
+        */
+       protected function getContentClass() {
+               return "\\BlueSpice\\Content\\Entity";
+       }
+}
\ No newline at end of file
diff --git a/includes/Entity.php b/src/Entity.php
similarity index 72%
rename from includes/Entity.php
rename to src/Entity.php
index df4bcb0..ddfa552 100644
--- a/includes/Entity.php
+++ b/src/Entity.php
@@ -1,6 +1,6 @@
 <?php
 /**
- * BSEntity base class for BlueSpice
+ * Entity base class for BlueSpice
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -26,13 +26,16 @@
  * @license    http://www.gnu.org/copyleft/gpl.html GNU Public License v2 or 
later
  * @filesource
  */
-class BSEntity implements JsonSerializable {
+namespace BlueSpice;
+use BlueSpice\Content\Entity as EntityContent;
+
+abstract class Entity implements \JsonSerializable {
        const NS = '';
        protected static $aEntitiesByID = array();
        protected $bUnsavedChanges = true;
 
        /**
-        * @var BSEntityConfig
+        * @var EntityConfig
         */
        protected $oConfig = null;
 
@@ -41,7 +44,7 @@
        protected $sType = '';
        protected $bArchived = false;
 
-       protected function __construct( stdClass $oStdClass, BSEntityConfig 
$oConfig ) {
+       protected function __construct( \stdClass $oStdClass, EntityConfig 
$oConfig ) {
                $this->oConfig = $oConfig;
                if( !empty($oStdClass->id) ) {
                        $this->iID = (int) $oStdClass->id;
@@ -60,8 +63,8 @@
        }
 
        protected static function factory( $sType, $oData ) {
-               $oConfig = BSEntityConfig::factory( $sType );
-               if( !$oConfig instanceof BSEntityConfig ) {
+               $oConfig = EntityConfig::factory( $sType );
+               if( !$oConfig instanceof EntityConfig ) {
                        //TODO: Return a DummyEntity instead of null.
                        return null;
                }
@@ -72,7 +75,7 @@
        }
 
        protected function generateID() {
-               //this is the case if the current BSEntity is new (no Title 
created yet)
+               //this is the case if the current Entity is new (no Title 
created yet)
                //Get the page_title of the last created title in entity 
namespace and
                //add +1. Entities are stored like: MYEntityNamespace:1,
                //MYEntityNamespace:2, MYEntityNamespace:3
@@ -98,11 +101,11 @@
        }
 
        /**
-        * Get BSEntity by BSEntityContent Object, wrapper for newFromObject
-        * @param BSEntityContent $sContent
-        * @return BSEntity
+        * Get Entity by EntityContent Object, wrapper for newFromObject
+        * @param EntityContent $sContent
+        * @return Entity
         */
-       public static function newFromContent( BSEntityContent $sContent ) {
+       public static function newFromContent( EntityContent $sContent ) {
                $aContent = $sContent->getJsonData();
                if ( empty($aContent) ) {
                        return null;
@@ -112,9 +115,9 @@
        }
 
        /**
-        * Get BSEntity by Json Object
+        * Get Entity by Json Object
         * @param Object $oObject
-        * @return BSEntity
+        * @return Entity
         */
        public static function newFromObject( $oObject ) {
                if( !is_object($oObject) ) {
@@ -122,10 +125,10 @@
                }
 
                if( empty($oObject->type) ) {
-                       //$oObject->type = 
BSEntityRegistry::getDefaultHandlerType();
+                       //$oObject->type = 
EntityRegistry::getDefaultHandlerType();
                        return null;
                }
-               if( !BSEntityRegistry::isRegisteredType($oObject->type) ) {
+               if( !EntityRegistry::isRegisteredType($oObject->type) ) {
                        return null;
                }
 
@@ -142,7 +145,7 @@
 
        /**
         * Gets the related config object
-        * @return BSEntityConfig
+        * @return EntityConfig
         */
        public function getConfig() {
                return $this->oConfig;
@@ -150,10 +153,10 @@
 
        /**
         * Gets the related Title object by ID
-        * @return Title
+        * @return \Title
         */
        public static function getTitleFor( $iID ) {
-               return Title::newFromText( $iID, static::NS );
+               return \Title::makeTitle( static::NS, $iID );
        }
 
        /**
@@ -173,10 +176,10 @@
        }
 
        /**
-        * Get BSEntity from ID, wrapper for newFromTitle
+        * Get Entity from ID, wrapper for newFromTitle
         * @param int $iID
         * @param boolean $bForceReload
-        * @return BSEntity | null
+        * @return Entity | null
         */
        public static function newFromID( $iID, $bForceReload = false ) {
                if ( !is_numeric( $iID ) ) {
@@ -194,18 +197,18 @@
                        return null;
                }
 
-               $sText = 
BsPageContentProvider::getInstance()->getContentFromTitle(
+               $sText = 
\BsPageContentProvider::getInstance()->getContentFromTitle(
                        $oTitle
                );
 
-               $oBSEntityContent = new JsonContent( $sText );
-               $oData = (object) $oBSEntityContent->getData()->getValue();
+               $oEntityContent = new EntityContent( $sText );
+               $oData = (object) $oEntityContent->getData()->getValue();
 
                if( empty($oData->type) ) {
                        return null;
-                       //$oData->type = 
BSEntityRegistry::getDefaultHandlerType();
+                       //$oData->type = 
EntityRegistry::getDefaultHandlerType();
                }
-               if( !BSEntityRegistry::isRegisteredType($oData->type) ) {
+               if( !EntityRegistry::isRegisteredType($oData->type) ) {
                        return null;
                }
 
@@ -217,12 +220,12 @@
        }
 
        /**
-        * Main method for getting a BSEntity from a Title
-        * @param Title $oTitle
+        * Main method for getting a Entity from a Title
+        * @param \Title $oTitle
         * @param boolean $bForceReload
-        * @return BSEntity
+        * @return Entity
         */
-       public static function newFromTitle( Title $oTitle, $bForceReload = 
false ) {
+       public static function newFromTitle( \Title $oTitle, $bForceReload = 
false ) {
                if ( is_null( $oTitle ) || $oTitle->getNamespace() !== 
static::NS ) {
                        return null;
                }
@@ -232,37 +235,37 @@
        }
 
        /**
-        * Saves the current BSEntity
-        * @return Status
+        * Saves the current Entity
+        * @return \Status
         */
-       public function save( User $oUser = null, $aOptions = array() ) {
+       public function save( \User $oUser = null, $aOptions = [] ) {
                if( !$oUser instanceof User ) {
-                       return Status::newFatal( 'No User' );
+                       return \Status::newFatal( 'No User' );
                }
                if( $this->exists() && !$this->hasUnsavedChanges() ) {
-                       return Status::newGood( $this );
+                       return \Status::newGood( $this );
                }
                if( empty($this->getID()) ) {
                        $this->generateID();
                }
                if( empty($this->getID()) ) {
-                       return Status::newFatal( 'No ID generated' );
+                       return \Status::newFatal( 'No ID generated' );
                }
                if( empty($this->getOwnerID()) ) {
                        $this->setOwnerID( (int) $oUser->getId() );
                }
                $sType = $this->getType();
                if( empty($sType) ) {
-                       return Status::newFatal('Related Type error');
+                       return \Status::newFatal( 'Related Type error' );
                }
 
                $oTitle = $this->getTitle();
                if ( is_null( $oTitle ) ) {
-                       return Status::newFatal('Related Title error');
+                       return \Status::newFatal( 'Related Title error' );
                }
 
-               $oWikiPage = WikiPage::factory( $oTitle );
-               $sContentClass = $this->getConfig()->get('ContentClass');
+               $oWikiPage = \WikiPage::factory( $oTitle );
+               $sContentClass = $this->getConfig()->get( 'ContentClass' );
                try {
                        $oStatus = $oWikiPage->doEditContent(
                                new $sContentClass( json_encode( $this ) ),
@@ -272,9 +275,9 @@
                                $oUser,
                                null
                        );
-               } catch( Exception $e ) {
+               } catch( \Exception $e ) {
                        //Something probalby breaks json
-                       return Status::newFatal( $e->getMessage() );
+                       return \Status::newFatal( $e->getMessage() );
                }
                //TODO: check why this is not good
                if ( !$oStatus->isOK() ) {
@@ -283,24 +286,24 @@
 
                $this->setUnsavedChanges( false );
 
-               wfRunHooks( 'BSEntitySaveComplete', array( $this, $oStatus, 
$oUser ) );
+               \Hooks::run( 'BSEntitySaveComplete', [ $this, $oStatus, $oUser 
] );
 
                $this->invalidateCache();
                return $oStatus;
        }
 
        /**
-        * Archives the current BSEntity
-        * @return Status
+        * Archives the current Entity
+        * @return \Status
         */
-       public function delete( User $oUser = null, $aOptions = array() ) {
+       public function delete( \User $oUser = null, $aOptions = [] ) {
                $oTitle = $this->getTitle();
 
                $oStatus = null;
-               $oWikiPage = WikiPage::factory( $oTitle );
+               $oWikiPage = \WikiPage::factory( $oTitle );
 
-               wfRunHooks( 'BSEntityDelete', array( $this, $oStatus, $oUser ) 
);
-               if( $oStatus instanceof Status && $oStatus->isOK() ) {
+               \Hooks::run( 'BSEntityDelete', [ $this, $oStatus, $oUser ] );
+               if( $oStatus instanceof \Status && $oStatus->isOK() ) {
                        return $oStatus;
                }
                $this->bArchived = true;
@@ -308,11 +311,11 @@
 
                try {
                        $oStatus = $this->save();
-               } catch( Exception $e ) {
-                       return Status::newFatal( $e->getMessage() );
+               } catch( \Exception $e ) {
+                       return \Status::newFatal( $e->getMessage() );
                }
 
-               wfRunHooks( 'BSEntityDeleteComplete', array( $this, $oStatus ) 
);
+               \Hooks::run( 'BSEntityDeleteComplete', [ $this, $oStatus ] );
                if( !$oStatus->isOK() ) {
                        return $oStatus;
                }
@@ -322,8 +325,8 @@
        }
 
        /**
-        * Gets the BSEntity attributes formated for the api
-        * @return object
+        * Gets the Entity attributes formated for the api
+        * @return array
         */
        public function getFullData( $aData = array() ) {
                $aData = array_merge(
@@ -335,7 +338,7 @@
                                'archived' => $this->isArchived(),
                        )
                );
-               Hooks::run('BSEntityGetFullData', [
+               \Hooks::run('BSEntityGetFullData', [
                        $this,
                        &$aData
                ]);
@@ -343,12 +346,12 @@
        }
 
        /**
-        * Adds a BSEntity to the cache
-        * @param BSEntity $oInstance
-        * @return BSEntity
+        * Adds a Entity to the cache
+        * @param Entity $oInstance
+        * @return Entity
         */
-       protected static function appendCache( BSEntity &$oInstance ) {
-               if( static::hasCacheEntry($oInstance->getID()) ) {
+       protected static function appendCache( Entity &$oInstance ) {
+               if( static::hasCacheEntry( $oInstance->getID() ) ) {
                        return $oInstance;
                }
                static::$aEntitiesByID[$oInstance->getID()] = $oInstance;
@@ -356,11 +359,11 @@
        }
 
        /**
-        * Removes a BSEntity from the cache if it's in
-        * @param BSEntity $oInstance
-        * @return BSEntity
+        * Removes a Entity from the cache if it's in
+        * @param Entity $oInstance
+        * @return Entity
         */
-       protected static function detachCache( BSEntity &$oInstance ) {
+       protected static function detachCache( Entity &$oInstance ) {
                if( !static::hasCacheEntry($oInstance->getID()) ) {
                        return $oInstance;
                }
@@ -369,9 +372,9 @@
        }
 
        /**
-        * Gets a instance of the BSEntity from the cache by ID
+        * Gets a instance of the Entity from the cache by ID
         * @param int $iID
-        * @return BSEntity
+        * @return Entity
         */
        protected static function getInstanceFromCacheByID( $iID ) {
                if( !static::hasCacheEntry( $iID ) ) {
@@ -385,7 +388,7 @@
        }
 
        /**
-        * Checks, if the current BSEntity exists in the Wiki
+        * Checks, if the current Entity exists in the Wiki
         * @return boolean
         */
        public function exists() {
@@ -416,7 +419,7 @@
        }
 
        /**
-        * Returns the current id for the BSEntity
+        * Returns the current id for the Entity
         * @return int
         */
        public function getID() {
@@ -424,7 +427,7 @@
        }
 
        /**
-        * Returns the current user id for the BSEntity
+        * Returns the current user id for the Entity
         * @return int
         */
        public function getOwnerID() {
@@ -440,9 +443,9 @@
        }
 
        /**
-        * Sets the current BSEntity to an unsaved changes mode, refreshes cache
+        * Sets the current Entity to an unsaved changes mode, refreshes cache
         * @param String $bStatus
-        * @return BSEntity
+        * @return Entity
         */
        public function setUnsavedChanges( $bStatus = true ) {
                $this->bUnsavedChanges = (bool) $bStatus;
@@ -452,7 +455,7 @@
        /**
         * Sets the current user ID
         * @param int
-        * @return BSEntity
+        * @return Entity
         */
        public function setOwnerID( $iOwnerID ) {
                return $this->setUnsavedChanges(
@@ -461,7 +464,7 @@
        }
 
        /**
-        * Subclass needs to return the current BSEntity as a Json encoded
+        * Subclass needs to return the current Entity as a Json encoded
         * string
         * @deprecated since 2.27.0 - Use json_encode( $oInstance ) instead
         * @return stdObject - Subclass needs to return encoded string!
@@ -479,13 +482,13 @@
        }
 
        /**
-        * @param stdClass $oData
+        * @param \stdClass $oData
         */
-       public function setValuesByObject( stdClass $oData ) {
+       public function setValuesByObject( \stdClass $oData ) {
                if( isset($oData->ownerid) ) {
                        $this->setOwnerID( $oData->ownerid );
                }
-               Hooks::run('BSEntitySetValuesByObject', [
+               \Hooks::run('BSEntitySetValuesByObject', [
                        $this,
                        $oData
                ]);
@@ -493,10 +496,10 @@
 
        /**
         * Checks if the given User is the owner of this entity
-        * @param User $oUser
+        * @param \User $oUser
         * @return boolean
         */
-       public function userIsOwner( User $oUser ) {
+       public function userIsOwner( \User $oUser ) {
                if( $oUser->isAnon() || $this->getOwnerID() < 1) {
                        return false;
                }
@@ -505,12 +508,12 @@
 
        /**
         * Invalidated the cache
-        * @return BSEntity
+        * @return Entity
         */
        public function invalidateCache() {
                $this->invalidateTitleCache( wfTimestampNow() );
                static::detachCache( $this );
-               Hooks::run( 'BSEntityInvalidate', array( $this ) );
+               \Hooks::run( 'BSEntityInvalidate', [ $this ] );
                return $this;
        }
 
diff --git a/includes/entityconfigs/EntityConfig.php b/src/EntityConfig.php
similarity index 84%
rename from includes/entityconfigs/EntityConfig.php
rename to src/EntityConfig.php
index 5d86140..99d33e9 100644
--- a/includes/entityconfigs/EntityConfig.php
+++ b/src/EntityConfig.php
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * BSEntityConfig class for BlueSpice
+ * EntityConfig class for BlueSpice
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -26,30 +26,31 @@
  * @license    http://www.gnu.org/copyleft/gpl.html GNU Public License v2 or 
later
  * @filesource
  */
+namespace BlueSpice;
 
 /**
- * BSEntityConfig class for BlueSpice
+ * EntityConfig class for BlueSpice
  * @package BlueSpiceFoundation
  */
-abstract class BSEntityConfig {
+abstract class EntityConfig implements \JsonSerializable {
        protected static $aEntityConfigs = null;
        protected static $aDefaults = array();
        protected $sType = '';
 
        /**
-        * BSEntityConfig factory
+        * EntityConfig factory
         * @param string $sType - Entity type
-        * @return BSEntityConfig - or null
+        * @return EntityConfig - or null
         */
        public static function factory( $sType ) {
-               if( !is_null(static::$aEntityConfigs) ) {
-                       if( !isset(static::$aEntityConfigs[$sType]) ) {
+               if( !is_null( static::$aEntityConfigs ) ) {
+                       if( !isset( static::$aEntityConfigs[$sType] ) ) {
                                return null;
                        }
                        return static::$aEntityConfigs[$sType];
                }
                //TODO: Check params and classes
-               $aRegisteredEntities = 
BSEntityRegistry::getRegisteredEntities();
+               $aRegisteredEntities = EntityRegistry::getRegisteredEntities();
                foreach( $aRegisteredEntities as $sKey => $sConfigClass ) {
                        static::$aEntityConfigs[$sKey] = new $sConfigClass();
                        static::$aEntityConfigs[$sKey]->sType = $sKey;
@@ -58,13 +59,13 @@
                                
static::$aEntityConfigs[$sKey]->addGetterDefaults()
                        );
                }
-               Hooks::run( 'BSEntityConfigDefaults', array( 
&static::$aDefaults ) );
+               \Hooks::run( 'BSEntityConfigDefaults', [ &static::$aDefaults ] 
);
                return static::$aEntityConfigs[$sType];
        }
 
 
        protected static function getDefault( $sOption ) {
-               if( !isset(static::$aDefaults[$sOption]) ) {
+               if( !isset( static::$aDefaults[$sOption] ) ) {
                        return false;
                }
                return static::$aDefaults[$sOption];
@@ -115,6 +116,6 @@
        abstract protected function get_EntityClass();
 
        protected function get_ContentClass() {
-               return 'BSEntityContent';
+               return "\\BlueSpice\\Content\\Entity";
        }
 }
diff --git a/includes/EntityRegistry.php b/src/EntityRegistry.php
similarity index 89%
rename from includes/EntityRegistry.php
rename to src/EntityRegistry.php
index dc78a6c..b3cce5d 100644
--- a/includes/EntityRegistry.php
+++ b/src/EntityRegistry.php
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * BSEntityRegistry class for BlueSpice
+ * EntityRegistry class for BlueSpice
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -26,12 +26,13 @@
  * @license    http://www.gnu.org/copyleft/gpl.html GNU Public License v2 or 
later
  * @filesource
  */
+namespace BlueSpice;
 
 /**
- * BSEntityRegistry class for BSSocial extension
+ * EntityRegistry class for BlueSpice
  * @package BlueSpiceFoundation
  */
-class BSEntityRegistry {
+class EntityRegistry {
        private function __construct() {}
        private static $bEntitiesRegistered = false;
        private static $aEntities = array();
@@ -41,9 +42,9 @@
                        return true;
                }
 
-               $b = wfRunHooks( 'BSEntityRegister', array(
+               $b = \Hooks::run( 'BSEntityRegister', [
                        &self::$aEntities,
-               ));
+               ]);
 
                return $b ? static::$bEntitiesRegistered = true : $b;
        }
@@ -54,7 +55,7 @@
         */
        public static function getRegisteredEntities() {
                if( !self::runRegister() ) {
-                       return array();
+                       return [];
                }
                return self::$aEntities;
        }
@@ -77,8 +78,8 @@
         * @return array
         */
        public static function getRegisteredEntityByType( $sType ) {
-               if( !self::isRegisteredType($sType) ) {
-                       return array();
+               if( !self::isRegisteredType( $sType ) ) {
+                       return [];
                }
                return self::$aEntities[$sType];
        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idb7e29f796688dcc6716dca66524c06b3a12a829
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: master
Gerrit-Owner: Pwirth <wi...@hallowelt.biz>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to