/**
* Initialize the widget
*
* @throws InvalidConfigException
*/
public function init()
{
static $initDone = false;
$this->validPlugins = [self::COMMENTS, self::POST, self::COMMUNITY, self::LIKE, self::RECO, self::POLL, self::AUTH, self::SHARE, self::SUBSCRIBE];
parent::init();
$this->setConfig('vk');
$initRequired = !in_array($this->type, [self::POST, self::COMMUNITY, self::SHARE, self::SUBSCRIBE]);
$this->_initVk = $initRequired && !$initDone;
if ($this->_initVk) {
$initDone = true;
}
if (empty($this->options['id'])) {
$this->options['id'] = $this->getId();
}
if (empty($this->type)) {
throw new InvalidConfigException("The plugin 'type' must be set.");
}
if (empty($this->apiId) && $this->_initVk) {
throw new InvalidConfigException("The VKontakte 'apiId' has not been set.");
}
if (!isset($this->noscript)) {
$this->noscript = Yii::t('kvsocial', 'Please enable JavaScript on your browser to view the VKontakte {pluginName} plugin correctly on this site.', ['pluginName' => Yii::t('kvsocial', str_replace('vk_', '', $this->type))]);
}
$this->_options = $this->options;
$this->options = ['id' => $this->options['id'], 'class' => $this->type];
unset($this->_options['id']);
$this->registerAssets();
echo $this->renderPlugin();
}