| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace common\events\mall;
- use Exception;
- use common\enums\EventNameEnum;
- use common\components\BaseEvent;
- use common\services\mall\BaseAdsSettingService;
- use Yii;
- /**
- * 获取指定插件配置事件
- * @package common\events\mall
- */
- final class GetSpecifyAdsCfgEvent extends BaseEvent
- {
- /**
- * 触发事件名称(不可修改)
- *
- * @var string
- */
- public $name = EventNameEnum::GET_SPECIFY_ADDONS_CONFIG;
- /**
- * 配置文件
- *
- * @var array
- */
- protected $config = [];
- /**
- * @var int
- */
- public $mall_id;
- /**
- * @var array
- */
- public $listeners = [];
- public function __construct(int $mall_id)
- {
- $this->mall_id = $mall_id;
- }
- /**
- * @param BaseAdsSettingService $service
- * @return void
- */
- public function setService(BaseAdsSettingService $service)
- {
- $name = preg_replace_callback('/[A-Z][a-z]*/', function ($match) {
- return '_' . strtolower($match[0]);
- }, lcfirst($service->getAddosName()));
- $this->setConfig($name, $service->getSetting());
- }
- /**
- * @param string $addons_name
- * @param array $config
- * @return void
- */
- public function setConfig(string $addons_name, array $config = [])
- {
- $this->config = array_merge($this->config, $config);
- }
- /**
- * @return array
- */
- public function getConfig() : array
- {
- return $this->config;
- }
- }
|