Permalink
Browse files

Change methods static to non-static. Remove dependency to PluginsServ…

…ice in Repository, by moving streamWrapper detection to AJXP_MetaStreamWrapper. Remove unnecessary calls to detectStreamWrapper() in all editors / meta plugins.
  • Loading branch information...
1 parent a3e77b5 commit 4af6e810f659778297d4918c9d08a17f00faa70f @cdujeu cdujeu committed Jun 2, 2016
Showing with 154 additions and 193 deletions.
  1. +13 −9 core/src/core/src/pydio/Core/Model/RepositoryInterface.php
  2. +59 −68 core/src/core/src/pydio/Core/PluginFramework/PluginsService.php
  3. +10 −6 core/src/core/src/pydio/Core/Services/ConfService.php
  4. +3 −3 core/src/plugins/access.inbox/class.inboxAccessDriver.php
  5. +1 −1 core/src/plugins/access.inbox/class.inboxAccessWrapper.php
  6. +0 −3 core/src/plugins/action.timestamp/class.TimestampCreator.php
  7. +37 −3 core/src/plugins/core.access/src/AJXP_MetaStreamWrapper.php
  8. +2 −2 core/src/plugins/core.access/src/AbstractAccessDriver.php
  9. +17 −28 core/src/plugins/core.access/src/Model/Repository.php
  10. +1 −1 core/src/plugins/core.authfront/class.FrontendsLoader.php
  11. +1 −4 core/src/plugins/editor.audio/class.AudioPreviewer.php
  12. +1 −5 core/src/plugins/editor.browser/class.FileMimeSender.php
  13. +0 −3 core/src/plugins/editor.diaporama/class.ImagePreviewer.php
  14. +1 −5 core/src/plugins/editor.eml/class.EmlParser.php
  15. +0 −4 core/src/plugins/editor.etherpad/class.EtherpadClient.php
  16. +0 −3 core/src/plugins/editor.imagick/class.IMagickPreviewer.php
  17. +0 −4 core/src/plugins/editor.pixlr/class.PixlrEditor.php
  18. +0 −4 core/src/plugins/editor.video/class.VideoReader.php
  19. +0 −3 core/src/plugins/editor.zoho/class.ZohoEditor.php
  20. +0 −3 core/src/plugins/meta.exif/class.ExifMetaManager.php
  21. +0 −3 core/src/plugins/meta.filehasher/class.FileHasher.php
  22. +0 −3 core/src/plugins/meta.svn/class.SvnManager.php
  23. +0 −3 core/src/plugins/uploader.html/class.SimpleUploadProcessor.php
  24. +0 −3 core/src/plugins/uploader.http/class.HttpDownloader.php
  25. +7 −15 core/src/plugins/uploader.jumploader/class.JumploaderProcessor.php
  26. +0 −3 core/src/plugins/uploader.plupload/class.PluploadProcessor.php
  27. +1 −1 core/src/worker.php
@@ -22,6 +22,7 @@
defined('AJXP_EXEC') or die('Access not allowed');
+use Pydio\Access\Core\AbstractAccessDriver;
use Pydio\Access\Core\Filter\ContentFilter;
@@ -33,6 +34,17 @@
*/
interface RepositoryInterface
{
+
+ /**
+ * @return AbstractAccessDriver
+ */
+ public function getDriverInstance();
+
+ /**
+ * @param AbstractAccessDriver $driverInstance
+ */
+ public function setDriverInstance($driverInstance);
+
/**
* @param ContentFilter $contentFilter
*/
@@ -101,15 +113,7 @@ public function setSlug($slug = null);
* @return \DOMElement|\DOMNodeList|string
*/
public function getClientSettings();
-
- /**
- * Find the streamWrapper declared by the access driver
- * @param bool $register
- * @param array $streams
- * @return bool
- */
- public function detectStreamWrapper($register = false, &$streams = null);
-
+
/**
* Add options
* @param $oName
@@ -59,35 +59,6 @@ class PluginsService
/*********************************/
/**
- * Build the XML Registry if not already built, and return it.
- * @static
- * @param bool $extendedVersion
- * @return \DOMDocument The registry
- */
- public static function getXmlRegistry($extendedVersion = true)
- {
- $self = self::getInstance();
- if (!isSet($self->xmlRegistry) || ($self->registryVersion == "light" && $extendedVersion)) {
- $self->buildXmlRegistry( $extendedVersion );
- $self->registryVersion = ($extendedVersion ? "extended":"light");
- }
- return $self->xmlRegistry;
- }
-
- /**
- * Replace the current xml registry
- * @static
- * @param $registry
- * @param bool $extendedVersion
- */
- public static function updateXmlRegistry($registry, $extendedVersion = true)
- {
- $self = self::getInstance();
- $self->xmlRegistry = $registry;
- $self->registryVersion = ($extendedVersion? "extended" : "light");
- }
-
- /**
* Search all plugins manifest with an XPath query, and return either the Nodes, or directly an XML string.
* @param string $query
* @param string $stringOrNodeFormat
@@ -147,21 +118,7 @@ public static function clearPluginsCache(){
}
/**
- * Add a plugin to the list of active plugins
- * @static
- * @param string $type
- * @param string $name
- * @param bool $active
- * @param Plugin $updateInstance
- * @return void
- */
- public static function setPluginActive($type, $name, $active=true, $updateInstance = null)
- {
- self::getInstance()->setPluginActiveInst($type, $name, $active, $updateInstance);
- }
-
- /**
- *
+ * Find a plugin by its type/name
* @param string $type
* @param string $name
* @return Plugin
@@ -224,6 +181,36 @@ public static function searchManifestsWithCache($query, $callback, $typeChecker
/* PUBLIC FUNCTIONS */
/*********************************/
+
+ /**
+ * Build the XML Registry if not already built, and return it.
+ * @static
+ * @param bool $extendedVersion
+ * @return \DOMDocument The registry
+ */
+ public function getXmlRegistry($extendedVersion = true)
+ {
+ $self = self::getInstance();
+ if (!isSet($self->xmlRegistry) || ($self->registryVersion == "light" && $extendedVersion)) {
+ $self->buildXmlRegistry( $extendedVersion );
+ $self->registryVersion = ($extendedVersion ? "extended":"light");
+ }
+ return $self->xmlRegistry;
+ }
+
+ /**
+ * Replace the current xml registry
+ * @static
+ * @param $registry
+ * @param bool $extendedVersion
+ */
+ public function updateXmlRegistry($registry, $extendedVersion = true)
+ {
+ $self = self::getInstance();
+ $self->xmlRegistry = $registry;
+ $self->registryVersion = ($extendedVersion? "extended" : "light");
+ }
+
/**
* @param string $plugType
* @param string $plugName
@@ -240,7 +227,8 @@ public function getPluginByTypeName($plugType, $plugName)
/**
* Loads the full registry, from the cache only
- *
+ * @param AbstractCacheDriver
+ * @return bool
*/
public function loadPluginsRegistryFromCache($cacheStorage = null) {
@@ -252,6 +240,8 @@ public function loadPluginsRegistryFromCache($cacheStorage = null) {
if($this->_loadRegistryFromCache()){
return true;
}
+
+ return false;
}
/**
@@ -392,6 +382,25 @@ public function storeToPluginQueriesCache($key, $value)
/*********************************/
/* PUBLIC: ACTIVE PLUGINS */
/*********************************/
+
+ /**
+ * Set the service in defer mode : do not rebuild
+ * registry on each plugin activation
+ */
+ public function deferBuildingRegistry(){
+ $this->tmpDeferRegistryBuild = true;
+ }
+
+ /**
+ * If service was in defer mode, now build the registry
+ */
+ public function flushDeferredRegistryBuilding(){
+ $this->tmpDeferRegistryBuild = false;
+ if (isSet($this->xmlRegistry)) {
+ $this->buildXmlRegistry(($this->registryVersion == "extended"));
+ }
+ }
+
/**
* Load the plugins list, and set active the plugins automatically,
* except for the specific types that declare a "core.*" plugin. In that case,
@@ -420,7 +429,7 @@ public function initActivePlugins()
try {
$pObject->performChecks();
if(!$pObject->isEnabled() || $pObject->hasMissingExtensions()) continue;
- $this->setPluginActiveInst($pObject->getType(), $pObject->getName(), true);
+ $this->setPluginActive($pObject->getType(), $pObject->getName(), true);
} catch (\Exception $e) {
//$this->errors[$pName] = "[$pName] ".$e->getMessage();
}
@@ -429,14 +438,14 @@ public function initActivePlugins()
}
/**
- * Instance implementation of the setPluginActive
+ * Add a plugin to the list of active plugins
* @param $type
* @param $name
* @param bool $active
* @param Plugin $updateInstance
* @return void
*/
- public function setPluginActiveInst($type, $name, $active=true, $updateInstance = null)
+ public function setPluginActive($type, $name, $active=true, $updateInstance = null)
{
if ($active) {
// Check active plugin dependencies
@@ -469,24 +478,6 @@ public function setPluginActiveInst($type, $name, $active=true, $updateInstance
}
/**
- * Set the service in defer mode : do not rebuild
- * registry on each plugin activation
- */
- public function deferBuildingRegistry(){
- $this->tmpDeferRegistryBuild = true;
- }
-
- /**
- * If service was in defer mode, now build the registry
- */
- public function flushDeferredRegistryBuilding(){
- $this->tmpDeferRegistryBuild = false;
- if (isSet($this->xmlRegistry)) {
- $this->buildXmlRegistry(($this->registryVersion == "extended"));
- }
- }
-
- /**
* Some type require only one active plugin at a time
* @param $type
* @param $name
@@ -499,10 +490,10 @@ public function setPluginUniqueActiveForType($type, $name, $updateInstance = nul
$originalValue = $this->tmpDeferRegistryBuild;
$this->tmpDeferRegistryBuild = true;
foreach ($typePlugs as $plugName => $plugObject) {
- $this->setPluginActiveInst($type, $plugName, false);
+ $this->setPluginActive($type, $plugName, false);
}
$this->tmpDeferRegistryBuild = $originalValue;
- $this->setPluginActiveInst($type, $name, true, $updateInstance);
+ $this->setPluginActive($type, $name, true, $updateInstance);
}
/**
@@ -22,6 +22,7 @@
use DOMXPath;
use Pydio\Access\Core\AbstractAccessDriver;
+use Pydio\Access\Core\AJXP_MetaStreamWrapper;
use Pydio\Access\Core\Model\Repository;
use Pydio\Auth\Core\AbstractAuthDriver;
use Pydio\Cache\Core\AbstractCacheDriver;
@@ -233,6 +234,7 @@ public static function clearAllCaches(){
public static function instanciatePluginFromGlobalParams($globalsArray, $interfaceCheck = "")
{
$plugin = false;
+ $pService = PluginsService::getInstance();
if (is_string($globalsArray)) {
$globalsArray = array("instance_name" => $globalsArray);
@@ -242,7 +244,7 @@ public static function instanciatePluginFromGlobalParams($globalsArray, $interfa
$pName = $globalsArray["instance_name"];
unset($globalsArray["instance_name"]);
- $plugin = PluginsService::getInstance()->softLoad($pName, $globalsArray);
+ $plugin = $pService->softLoad($pName, $globalsArray);
$plugin->performChecks();
}
@@ -252,7 +254,7 @@ public static function instanciatePluginFromGlobalParams($globalsArray, $interfa
}
}
if ($plugin !== false) {
- PluginsService::getInstance()->setPluginActive($plugin->getType(), $plugin->getName(), true, $plugin);
+ $pService->setPluginActive($plugin->getType(), $plugin->getName(), true, $plugin);
}
return $plugin;
@@ -379,13 +381,15 @@ public static function reloadServicesAndActivePlugins(){
public static function getFilteredXMLRegistry($extendedVersion = true, $clone = false, $useCache = false){
+ $pluginService = PluginsService::getInstance();
+
if($useCache){
$cacheKey = self::getRegistryCacheKey($extendedVersion);
$cachedXml = CacheService::fetch(AJXP_CACHE_SERVICE_NS_SHARED, $cacheKey);
if($cachedXml !== false){
$registry = new \DOMDocument("1.0", "utf-8");
$registry->loadXML($cachedXml);
- PluginsService::updateXmlRegistry($registry, $extendedVersion);
+ $pluginService->updateXmlRegistry($registry, $extendedVersion);
if($clone){
return $registry->cloneNode(true);
}else{
@@ -394,10 +398,10 @@ public static function getFilteredXMLRegistry($extendedVersion = true, $clone =
}
}
- $registry = PluginsService::getXmlRegistry($extendedVersion);
+ $registry = $pluginService->getXmlRegistry($extendedVersion);
$changes = self::filterRegistryFromRole($registry);
if($changes){
- PluginsService::updateXmlRegistry($registry, $extendedVersion);
+ $pluginService->updateXmlRegistry($registry, $extendedVersion);
}
if($useCache && isSet($cacheKey)){
@@ -981,7 +985,7 @@ public function detectRepositoryStreamsInst($register = false)
$streams = array();
$currentRepos = $this->getLoadedRepositories();
foreach ($currentRepos as $repository) {
- $repository->detectStreamWrapper($register, $streams);
+ AJXP_MetaStreamWrapper::detectWrapperForRepository($repository,$register, $streams);
}
return $streams;
}
@@ -20,6 +20,7 @@
*/
namespace Pydio\Access\Driver\StreamProvider\Inbox;
+use Pydio\Access\Core\AJXP_MetaStreamWrapper;
use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Access\Core\Filter\ContentFilter;
use Pydio\Access\Driver\StreamProvider\FS\fsAccessDriver;
@@ -87,7 +88,7 @@ public static function getNodeData($nodePath){
$node->getRepository()->driverInstance = null;
try{
ConfService::loadDriverForRepository($node->getRepository());
- $node->getRepository()->detectStreamWrapper(true);
+ AJXP_MetaStreamWrapper::detectWrapperForRepository($node->getRepository(), true);
if($node->getRepository()->hasContentFilter()){
$node->setLeaf(true);
}
@@ -166,8 +167,7 @@ public static function getNodes($checkStats = false, $touch = true){
$ext = "error";
$meta["ajxp_mime"] = "error";
}
- $node->getRepository()->detectStreamWrapper(true);
-
+ AJXP_MetaStreamWrapper::detectWrapperForRepository($node->getRepository(), true);
$stat = @stat($url);
if($stat === false){
$ext = "error";
@@ -149,7 +149,7 @@ public static function translateURL($path){
}catch (\Exception $e){
}
- $node->getRepository()->detectStreamWrapper(true);
+ AJXP_MetaStreamWrapper::detectWrapperForRepository($node->getRepository(), true);
}
return $url;
}
@@ -39,9 +39,6 @@ public function switchAction(\Psr\Http\Message\ServerRequestInterface $requestIn
//Get active repository
$repository = ConfService::getRepository();
- if (!$repository->detectStreamWrapper(true)) {
- return false;
- }
$selection = new UserSelection($repository, $requestInterface->getParsedBody());
$destStreamURL = $selection->currentBaseUrl();
Oops, something went wrong.

0 comments on commit 4af6e81

Please sign in to comment.