diff --git a/CHANGELOG.md b/CHANGELOG.md index d8f4ee2..d9664c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,13 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip ### Breaking changes - NaN +## [2.1.0] - 2020-10-08 +### Fixed +- Redundant class `ClientManager::class` removed and config handling moved to depending library "webklex/php-imap" #345 #344 + +### Breaking changes +- `\Webklex\IMAP\ClientManager::class` no longer exists. Please use the `\Webklex\IMAP\Facades\Client::class` facade or `\Webklex\PHPIMAP\ClientManager::class` instead. + ## [2.0.2] - 2020-09-23 ### Fixed - Missing default config parameter added (#337) diff --git a/src/ClientManager.php b/src/ClientManager.php deleted file mode 100644 index df47433..0000000 --- a/src/ClientManager.php +++ /dev/null @@ -1,134 +0,0 @@ -app = $app; - CM::$config = $this->app['config']["imap"]; - } - - /** - * Resolve a account instance. - * @param string $name - * - * @return Client - * @throws MaskNotFoundException - */ - public function account($name = null) { - $name = $name ?: $this->getDefaultAccount(); - - // If the connection has not been resolved yet we will resolve it now as all - // of the connections are resolved when they are actually needed so we do - // not make any unnecessary connection to the various queue end-points. - if (!isset($this->accounts[$name])) { - $this->accounts[$name] = $this->resolve($name); - } - - return $this->accounts[$name]; - } - - /** - * Resolve a account. - * @param string $name - * - * @return Client - * @throws MaskNotFoundException - */ - protected function resolve($name) { - $config = $this->getConfig($name); - - return new Client($config); - } - - /** - * Get the account configuration. - * - * @param string $name - * - * @return array - */ - protected function getConfig($name) { - if ($name === null || $name === 'null') { - return ['driver' => 'null']; - } - - return $this->app['config']["imap.accounts.{$name}"]; - } - - /** - * Get the name of the default account. - * - * @return string - */ - public function getDefaultAccount() { - return $this->app['config']['imap.default']; - } - - /** - * Set the name of the default account. - * - * @param string $name - * - * @return void - */ - public function setDefaultAccount($name) { - $this->app['config']['imap.default'] = $name; - CM::$config['default'] = $name; - } - - /** - * Dynamically pass calls to the default account. - * - * @param string $method - * @param array $parameters - * - * @return mixed - * @throws MaskNotFoundException - */ - public function __call($method, $parameters) { - $callable = [$this->account(), $method]; - - return call_user_func_array($callable, $parameters); - } -} \ No newline at end of file diff --git a/src/Facades/Client.php b/src/Facades/Client.php index 12a480f..eda49a6 100644 --- a/src/Facades/Client.php +++ b/src/Facades/Client.php @@ -13,7 +13,7 @@ namespace Webklex\IMAP\Facades; use Illuminate\Support\Facades\Facade; -use Webklex\IMAP\ClientManager; +use Webklex\PHPIMAP\ClientManager; /** * Class Client diff --git a/src/Providers/LaravelServiceProvider.php b/src/Providers/LaravelServiceProvider.php index 3a37e12..d96d893 100644 --- a/src/Providers/LaravelServiceProvider.php +++ b/src/Providers/LaravelServiceProvider.php @@ -13,7 +13,7 @@ namespace Webklex\IMAP\Providers; use Illuminate\Support\ServiceProvider; -use Webklex\IMAP\ClientManager; +use Webklex\PHPIMAP\ClientManager; use Webklex\PHPIMAP\Client; /** @@ -40,15 +40,15 @@ public function boot() { * @return void */ public function register() { + $this->setVendorConfig(); + $this->app->singleton(ClientManager::class, function($app) { - return new ClientManager($app); + return new ClientManager($app['config']["imap"]); }); $this->app->singleton(Client::class, function($app) { return $app[ClientManager::class]->account(); }); - - $this->setVendorConfig(); } /**