Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
通知类的实例化
Browse files Browse the repository at this point in the history
  • Loading branch information
Joyboo committed Apr 21, 2022
1 parent 6efc319 commit fd5b964
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/DingTalk/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace WonderGame\EsNotify\DingTalk;

use WonderGame\EsNotify\Interfaces\ConfigInterface;
use WonderGame\EsNotify\Interfaces\NotifyInterface;
use EasySwoole\Spl\SplBean;

class Config extends SplBean implements ConfigInterface
Expand Down Expand Up @@ -55,8 +56,8 @@ public function getAt()
return $this->at;
}

public function notifyClassName()
public function getNotifyClass(): NotifyInterface
{
return Notify::class;
return new Notify();
}
}
4 changes: 1 addition & 3 deletions src/EsNotify.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ public function register(ConfigInterface $Config, string $name = 'default')
throw new \Exception('EsNotify name already exists: ' . $name);
}

$className = $Config->notifyClassName();
/** @var NotifyInterface $class */
$class = new $className();
$class = $Config->getNotifyClass();
$class->register($Config);

$this->container[$name] = $class;
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/ConfigInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

interface ConfigInterface
{
public function notifyClassName();
public function getNotifyClass(): NotifyInterface;
}
5 changes: 3 additions & 2 deletions src/WeChat/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace WonderGame\EsNotify\WeChat;

use WonderGame\EsNotify\Interfaces\ConfigInterface;
use WonderGame\EsNotify\Interfaces\NotifyInterface;
use EasySwoole\Spl\SplBean;

class Config extends SplBean implements ConfigInterface
Expand Down Expand Up @@ -107,8 +108,8 @@ public function getUrl()
return $this->url;
}

public function notifyClassName()
public function getNotifyClass(): NotifyInterface
{
return Notify::class;
return new Notify();
}
}

0 comments on commit fd5b964

Please sign in to comment.