Permalink
Browse files

Pass context in plugin init(), initMeta() and beforeInitMeta() methods

  • Loading branch information...
1 parent 7c540a4 commit 7c63857114d7e3057780aa9ffcf5386584e58ad7 @cdujeu cdujeu committed Jun 5, 2016
Showing with 575 additions and 244 deletions.
  1. +11 −2 core/src/core/src/pydio/Core/PluginFramework/Plugin.php
  2. +12 −10 core/src/core/src/pydio/Core/PluginFramework/PluginsService.php
  3. +5 −2 core/src/core/src/sabredav/ajaxplorer/class.AJXP_Sabre_Node.php
  4. +7 −0 core/src/plugins/access.ajxp_conf/class.ajxp_confAccessDriver.php
  5. +7 −0 core/src/plugins/access.ajxp_home/class.HomePagePlugin.php
  6. +4 −1 core/src/plugins/access.ajxp_user/class.UserDashboardDriver.php
  7. +7 −1 core/src/plugins/access.dropbox/class.dropboxAccessDriver.php
  8. +8 −3 core/src/plugins/access.fs/class.fsAccessDriver.php
  9. +6 −1 core/src/plugins/access.ftp/class.ftpAccessDriver.php
  10. +7 −1 core/src/plugins/access.imap/class.imapAccessDriver.php
  11. +8 −1 core/src/plugins/access.inbox/class.inboxAccessDriver.php
  12. +8 −0 core/src/plugins/access.jsapi/class.jsapiAccessDriver.php
  13. +7 −1 core/src/plugins/access.mysql/class.mysqlAccessDriver.php
  14. +6 −1 core/src/plugins/access.s3/class.s3AccessDriver.php
  15. +6 −1 core/src/plugins/access.sftp/class.sftpAccessDriver.php
  16. +3 −2 core/src/plugins/access.sftp_psl/class.sftpPSLAccessDriver.php
  17. +6 −1 core/src/plugins/access.smb/class.smbAccessDriver.php
  18. +5 −2 core/src/plugins/access.swift/class.swiftAccessDriver.php
  19. +13 −6 core/src/plugins/access.webdav/src/Driver.php
  20. +8 −0 core/src/plugins/access.wms/class.WmsBrowser.php
  21. +9 −5 core/src/plugins/action.scheduler/class.AjxpScheduler.php
  22. +12 −7 core/src/plugins/action.share/src/ShareCenter.php
  23. +8 −5 core/src/plugins/action.updater/class.UpdateController.php
  24. +7 −2 core/src/plugins/auth.custom_db/class.customDbAuthDriver.php
  25. +9 −3 core/src/plugins/auth.ftp/class.ftpAuthDriver.php
  26. +7 −2 core/src/plugins/auth.ldap/class.ldapAuthDriver.php
  27. +6 −2 core/src/plugins/auth.multi/class.multiAuthDriver.php
  28. +8 −2 core/src/plugins/auth.radius/class.radiusAuthDriver.php
  29. +7 −2 core/src/plugins/auth.remote/class.remoteAuthDriver.php
  30. +7 −2 core/src/plugins/auth.serial/class.serialAuthDriver.php
  31. +7 −2 core/src/plugins/auth.sql/class.sqlAuthDriver.php
  32. +0 −4 core/src/plugins/authfront.keystore/class.KeystoreAuthFrontend.php
  33. +7 −2 core/src/plugins/boot.conf/class.BootConfLoader.php
  34. +5 −6 core/src/plugins/cache.doctrine/class.DoctrineCacheDriver.php
  35. +7 −2 core/src/plugins/conf.serial/class.serialConfDriver.php
  36. +6 −2 core/src/plugins/conf.sql/class.sqlConfDriver.php
  37. +29 −9 core/src/plugins/core.access/src/AbstractAccessDriver.php
  38. +10 −4 core/src/plugins/core.authfront/class.FrontendsLoader.php
  39. +2 −6 core/src/plugins/core.cache/class.AbstractCacheDriver.php
  40. +6 −3 core/src/plugins/core.conf/class.AbstractConfDriver.php
  41. +10 −4 core/src/plugins/core.log/class.AJXP_Logger.php
  42. +10 −4 core/src/plugins/core.mailer/class.AjxpMailer.php
  43. +4 −2 core/src/plugins/core.meta/class.AJXP_AbstractMetaSource.php
  44. +10 −2 core/src/plugins/core.metastore/interface.MetaStoreProvider.php
  45. +13 −6 core/src/plugins/core.mq/class.MqManager.php
  46. +10 −5 core/src/plugins/core.notifications/class.AJXP_NotificationCenter.php
  47. +7 −2 core/src/plugins/core.ocs/src/OCSPlugin.php
  48. +6 −2 core/src/plugins/core.tasks/src/TaskController.php
  49. +8 −2 core/src/plugins/editor.zoho/class.ZohoEditor.php
  50. +6 −2 core/src/plugins/feed.sql/class.AJXP_SqlFeedStore.php
  51. +17 −9 core/src/plugins/index.elasticsearch/class.AjxpElasticSearch.php
  52. +12 −8 core/src/plugins/index.lucene/class.AjxpLuceneIndexer.php
  53. +7 −6 core/src/plugins/log.sql/class.sqlLogDriver.php
  54. +6 −5 core/src/plugins/log.syslog/class.sysLogDriver.php
  55. +5 −5 core/src/plugins/log.text/class.textLogDriver.php
  56. +11 −4 core/src/plugins/meta.comments/class.CommentsMetaManager.php
  57. +16 −5 core/src/plugins/meta.exif/class.ExifMetaManager.php
  58. +12 −5 core/src/plugins/meta.filehasher/class.FileHasher.php
  59. +4 −2 core/src/plugins/meta.git/class.GitManager.php
  60. +4 −2 core/src/plugins/meta.monitor_fs/class.FSMonitoringManager.php
  61. +7 −9 core/src/plugins/meta.mount/class.FilesystemMounter.php
  62. +12 −5 core/src/plugins/meta.simple_lock/class.SimpleLockManager.php
  63. +14 −4 core/src/plugins/meta.svn/class.SvnManager.php
  64. +7 −2 core/src/plugins/meta.syncable/class.ChangesTracker.php
  65. +20 −9 core/src/plugins/meta.user/class.UserMetaManager.php
  66. +13 −6 core/src/plugins/meta.watch/class.MetaWatchRegister.php
  67. +9 −15 core/src/plugins/metastore.s3/class.s3MetaStore.php
  68. +5 −2 core/src/plugins/metastore.serial/class.SerialMetaStore.php
  69. +7 −2 core/src/plugins/mq.sql/class.AJXP_SqlMessageExchanger.php
@@ -61,6 +61,9 @@ class Plugin implements \Serializable
protected $enabled;
protected $registryContributions = array();
protected $contributionsLoaded = false;
+ /**
+ * @var array
+ */
protected $options; // can be passed at init time
protected $pluginConf; // can be passed at load time
protected $pluginConfDefinition;
@@ -150,14 +153,20 @@ protected function getXPath(){
}
/**
- * @param $options
+ * @param ContextInterface $ctx
+ * @param array $options
* @return void
*/
- public function init($options)
+ public function init(ContextInterface $ctx, $options = [])
{
$this->options = array_merge($this->loadOptionsDefaults(), $options);
}
+ /**
+ * @param ContextInterface $ctx
+ * @param $optionName
+ * @return mixed|null
+ */
protected function getContextualOption(ContextInterface $ctx, $optionName){
if($ctx->hasRepository()){
$repo = $ctx->getRepository();
@@ -37,6 +37,7 @@
use Pydio\Core\Services\ConfService;
use Pydio\Core\Utils\Utils;
use Pydio\Log\Core\AJXP_Logger;
+use Pydio\Meta\Core\AJXP_AbstractMetaSource;
defined('AJXP_EXEC') or die( 'Access not allowed');
@@ -238,6 +239,7 @@ private function initRepositoryPlugins($ctx){
$keys = array_keys($metaSources);
foreach ($keys as $plugId) {
if($plugId == "") continue;
+ /** @var AJXP_AbstractMetaSource $instance */
$instance = $this->getPluginById($plugId);
if (!is_object($instance)) {
continue;
@@ -246,8 +248,8 @@ private function initRepositoryPlugins($ctx){
continue;
}
try {
- $instance->init(AuthService::filterPluginParameters($plugId, $metaSources[$plugId], $ctx));
- $instance->beforeInitMeta($plugInstance, $repository);
+ $instance->init($ctx, AuthService::filterPluginParameters($plugId, $metaSources[$plugId], $ctx));
+ $instance->beforeInitMeta($ctx, $plugInstance);
} catch (\Exception $e) {
AJXP_Logger::error(__CLASS__, 'Meta plugin', 'Cannot instanciate Meta plugin, reason : '.$e->getMessage());
$errors[] = $e->getMessage();
@@ -257,14 +259,13 @@ private function initRepositoryPlugins($ctx){
// INIT MAIN DRIVER
try {
- $plugInstance->init($repository);
- $plugInstance->initRepository();
+ $plugInstance->init($ctx);
}catch (PydioUserAlertException $ua){
throw $ua;
}catch (\Exception $e){
new RepositoryLoadException($repository, [$e->getMessage()]);
}
- $repository->driverInstance = $plugInstance;
+ $repository->setDriverInstance($plugInstance);
$this->deferBuildingRegistry();
$this->setPluginUniqueActiveForType("access", $accessType);
@@ -276,16 +277,17 @@ private function initRepositoryPlugins($ctx){
foreach ($keys as $plugId) {
if($plugId == "") continue;
$split = explode(".", $plugId);
+ /** @var AJXP_AbstractMetaSource $instance */
$instance = $this->getPluginById($plugId);
if (!is_object($instance)) {
continue;
}
try {
- $instance->init(AuthService::filterPluginParameters($plugId, $metaSources[$plugId], $ctx));
+ $instance->init($ctx, AuthService::filterPluginParameters($plugId, $metaSources[$plugId], $ctx));
if(!method_exists($instance, "initMeta")) {
throw new \Exception("Meta Source $plugId does not implement the initMeta method.");
}
- $instance->initMeta($plugInstance);
+ $instance->initMeta($ctx, $plugInstance);
} catch (\Exception $e) {
AJXP_Logger::error(__CLASS__, 'Meta plugin', 'Cannot instanciate Meta plugin, reason : '.$e->getMessage());
$errors[] = $e->getMessage();
@@ -528,7 +530,7 @@ public function softLoad($pluginId, $pluginOptions)
* @var Plugin $plugin
*/
$plugin = $this->detectedPlugins[$type][$name];
- $plugin->init($pluginOptions);
+ $plugin->init($this->context, $pluginOptions);
return clone $plugin;
}
@@ -537,7 +539,7 @@ public function softLoad($pluginId, $pluginOptions)
$plugin->loadManifest();
$plugin = $this->instanciatePluginClass($plugin);
$plugin->loadConfigs(array()); // Load default
- $plugin->init($pluginOptions);
+ $plugin->init($this->context, $pluginOptions);
return $plugin;
}
@@ -641,7 +643,7 @@ public function initActivePlugins()
$o = $this->getOrderByDependency($toActivate, false);
foreach ($o as $id) {
$pObject = $toActivate[$id];
- $pObject->init(array());
+ $pObject->init($this->context, array());
try {
$pObject->performChecks();
if(!$pObject->isEnabled() || $pObject->hasMissingExtensions()) continue;
@@ -21,6 +21,7 @@
use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Access\Core\IAjxpWrapperProvider;
use Pydio\Access\Core\Model\Repository;
+use Pydio\Core\Model\Context;
use Pydio\Core\Services\ConfService;
use Pydio\Core\Controller\Controller;
use Pydio\Core\PluginFramework\PluginsService;
@@ -245,9 +246,11 @@ protected function getResourceData()
*/
protected function getMetastore()
{
- $metaStore = PluginsService::getInstance()->getUniqueActivePluginForType("metastore");
+ $ctx = Context::fromGlobalServices();
+ /** @var MetaStoreProvider $metaStore */
+ $metaStore = PluginsService::getInstance($ctx)->getUniqueActivePluginForType("metastore");
if($metaStore === false) return false;
- $metaStore->initMeta($this->getAccessDriver());
+ $metaStore->initMeta($ctx, $this->getAccessDriver());
return $metaStore;
}
@@ -2954,4 +2954,11 @@ public function flattenKeyValues(&$result, &$definitions, $values, $parent = "")
}
}
+ /**
+ * @param ContextInterface $ctx
+ */
+ protected function initRepository(ContextInterface $ctx)
+ {
+ // TODO: Implement initRepository() method.
+ }
}
@@ -55,4 +55,11 @@ public function parseSpecificContributions(ContextInterface $ctx, \DOMNode &$con
}
}
+ /**
+ * @param ContextInterface $ctx
+ */
+ protected function initRepository(ContextInterface $ctx)
+ {
+ // TODO: Implement initRepository() method.
+ }
}
@@ -49,7 +49,10 @@
class UserDashboardDriver extends AbstractAccessDriver
{
- public function initRepository()
+ /**
+ * @param ContextInterface $contextInterface
+ */
+ protected function initRepository(ContextInterface $contextInterface)
{
require_once AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/action.share/vendor/autoload.php";
}
@@ -24,6 +24,7 @@
use Pydio\Access\Core\Model\Repository;
use Pydio\Access\Driver\StreamProvider\FS\fsAccessDriver;
use Pydio\Core\Exception\PydioUserAlertException;
+use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Services\AuthService;
use Pydio\Core\Utils\Utils;
@@ -44,7 +45,12 @@ class dropboxAccessDriver extends fsAccessDriver
protected $wrapperClassName;
protected $urlBase;
- public function initRepository()
+ /**
+ * @param ContextInterface $contextInterface
+ * @throws PydioUserAlertException
+ * @throws \Exception
+ */
+ protected function initRepository(ContextInterface $contextInterface)
{
if (is_array($this->pluginConf)) {
$this->driverConf = $this->pluginConf;
@@ -80,16 +80,21 @@ class fsAccessDriver extends AbstractAccessDriver implements IAjxpWrapperProvide
protected $wrapperClassName;
protected $urlBase;
- public function initRepository()
+ /**
+ * @param ContextInterface $contextInterface
+ * @throws PydioException
+ * @throws \Exception
+ */
+ protected function initRepository(ContextInterface $contextInterface)
{
if (is_array($this->pluginConf)) {
$this->driverConf = $this->pluginConf;
} else {
$this->driverConf = array();
}
- if ( $this->getFilteredOption("PROBE_REAL_SIZE", $this->repository) == true ) {
+ if ( $this->getContextualOption($contextInterface, "PROBE_REAL_SIZE") == true ) {
// PASS IT TO THE WRAPPER
- ConfService::setConf("PROBE_REAL_SIZE", $this->getFilteredOption("PROBE_REAL_SIZE", $this->repository));
+ ConfService::setConf("PROBE_REAL_SIZE", true);
}
$create = $this->repository->getOption("CREATE");
$path = TextEncoder::toStorageEncoding($this->repository->getOption("PATH"));
@@ -76,7 +76,12 @@ protected function parseSpecificContributions(ContextInterface $ctx, \DOMNode &$
$this->redirectActionsToMethod($contribNode, array("upload", "next_to_remote", "trigger_remote_copy"), "uploadActions");
}
- public function initRepository()
+ /**
+ * @param ContextInterface $contextInterface
+ * @throws PydioException
+ * @throws \Exception
+ */
+ protected function initRepository(ContextInterface $contextInterface)
{
if (is_array($this->pluginConf)) {
$this->driverConf = $this->pluginConf;
@@ -24,6 +24,7 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Pydio\Access\Driver\StreamProvider\FS\fsAccessDriver;
+use Pydio\Core\Exception\PydioException;
use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Utils\Utils;
@@ -44,7 +45,12 @@ class imapAccessDriver extends fsAccessDriver
protected $wrapperClassName;
protected $urlBase;
- public function initRepository()
+ /**
+ * @param ContextInterface $contextInterface
+ * @throws PydioException
+ * @throws \Exception
+ */
+ protected function initRepository(ContextInterface $contextInterface)
{
if (is_array($this->pluginConf)) {
$this->driverConf = $this->pluginConf;
@@ -24,6 +24,8 @@
use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Access\Core\Filter\ContentFilter;
use Pydio\Access\Driver\StreamProvider\FS\fsAccessDriver;
+use Pydio\Core\Exception\PydioException;
+use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Services\AuthService;
use Pydio\Core\Services\ConfService;
use Pydio\Core\Controller\Controller;
@@ -35,7 +37,12 @@ class inboxAccessDriver extends fsAccessDriver
{
private static $output;
- public function initRepository()
+ /**
+ * @param ContextInterface $contextInterface
+ * @throws PydioException
+ * @throws \Exception
+ */
+ protected function initRepository(ContextInterface $contextInterface)
{
$this->detectStreamWrapper(true);
$this->urlBase = "pydio://".$this->repository->getId();
@@ -23,6 +23,7 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Pydio\Access\Core\AbstractAccessDriver;
+use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Utils\Utils;
use Pydio\Core\Controller\HTMLWriter;
use RecursiveDirectoryIterator;
@@ -83,4 +84,11 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
}
+ /**
+ * @param ContextInterface $ctx
+ */
+ protected function initRepository(ContextInterface $ctx)
+ {
+ // TODO: Implement initRepository() method.
+ }
}
@@ -22,6 +22,7 @@
use Pydio\Access\Core\AbstractAccessDriver;
use Pydio\Access\Core\Model\UserSelection;
+use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Services\ConfService;
use Pydio\Core\Exception\PydioException;
use Pydio\Core\Utils\Utils;
@@ -41,7 +42,12 @@ class mysqlAccessDriver extends AbstractAccessDriver
/** The user password */
public $password;
- public function initRepository()
+ /**
+ * @param ContextInterface $contextInterface
+ * @throws PydioException
+ * @throws \Exception
+ */
+ protected function initRepository(ContextInterface $contextInterface)
{
$this->user = $this->repository->getOption("DB_USER");
$this->password = $this->repository->getOption("DB_PASS");
@@ -112,7 +112,12 @@ public function detectStreamWrapper($register = false){
return parent::detectStreamWrapper($register);
}
- public function initRepository()
+ /**
+ * @param ContextInterface $contextInterface
+ * @throws PydioException
+ * @throws \Exception
+ */
+ protected function initRepository(ContextInterface $contextInterface)
{
$this->detectStreamWrapper(true);
@@ -50,7 +50,12 @@ class sftpAccessDriver extends fsAccessDriver
protected $wrapperClassName;
protected $urlBase;
- public function initRepository()
+ /**
+ * @param ContextInterface $contextInterface
+ * @throws PydioException
+ * @throws \Exception
+ */
+ protected function initRepository(ContextInterface $contextInterface)
{
if (is_array($this->pluginConf)) {
$this->driverConf = $this->pluginConf;
@@ -52,9 +52,10 @@ class sftpPSLAccessDriver extends fsAccessDriver
protected $urlBase;
/**
- * initRepository
+ * @param ContextInterface $contextInterface
+ * @throws \Exception
*/
- public function initRepository()
+ protected function initRepository(ContextInterface $contextInterface)
{
if (is_array($this->pluginConf)) {
$this->driverConf = $this->pluginConf;
@@ -50,7 +50,12 @@ class smbAccessDriver extends fsAccessDriver
protected $wrapperClassName;
protected $urlBase;
- public function initRepository()
+ /**
+ * @param ContextInterface $contextInterface
+ * @throws PydioException
+ * @throws \Exception
+ */
+ protected function initRepository(ContextInterface $contextInterface)
{
if (is_array($this->pluginConf)) {
$this->driverConf = $this->pluginConf;
@@ -58,8 +58,11 @@ public function performChecks()
}
-
- public function initRepository()
+ /**
+ * @param ContextInterface $contextInterface
+ * @throws \Exception
+ */
+ protected function initRepository(ContextInterface $contextInterface)
{
if (is_array($this->pluginConf)) {
$this->driverConf = $this->pluginConf;
Oops, something went wrong.

0 comments on commit 7c63857

Please sign in to comment.