container->get('ext.manager');
if (!$ext_manager->is_enabled('phpbbstudio/aps'))
{
if (phpbb_version_compare(PHPBB_VERSION, '3.3.0@dev', '<'))
{
$user = $this->container->get('user');
$lang = $user->lang;
$user->add_lang_ext('phpbbstudio/ass', 'ass_ext');
$lang['EXTENSION_NOT_ENABLEABLE'] .= '
' . $user->lang('ASS_REQUIRES_APS');
$user->lang = $lang;
return false;
}
if (phpbb_version_compare(PHPBB_VERSION, '3.3.0@dev', '>'))
{
$language= $this->container->get('language');
$language->add_lang('ass_ext', 'phpbbstudio/ass');
return $language->lang('ASS_REQUIRES_APS');
}
}
$md_manager = $ext_manager->create_extension_metadata_manager('phpbbstudio/aps');
$aps_version = (string) $md_manager->get_metadata('version');
$aps_required = '1.0.6-RC';
/** Make sure the APS version is 1.0.6-RC or higher */
if (phpbb_version_compare($aps_version, $aps_required, '<'))
{
if (phpbb_version_compare(PHPBB_VERSION, '3.3.0@dev', '<'))
{
$user = $this->container->get('user');
$lang = $user->lang;
$user->add_lang_ext('phpbbstudio/ass', 'ass_ext');
$lang['EXTENSION_NOT_ENABLEABLE'] .= '
' . $user->lang('ASS_REQUIRES_APS_VERSION', $aps_required);
$user->lang = $lang;
return false;
}
if (phpbb_version_compare(PHPBB_VERSION, '3.3.0@dev', '>'))
{
$language= $this->container->get('language');
$language->add_lang('ass_ext', 'phpbbstudio/ass');
return $language->lang('ASS_REQUIRES_APS_VERSION', $aps_required);
}
}
return true;
}
/**
* Enable notifications for the extension.
*
* @param mixed $old_state State returned by previous call of this method
* @return mixed Returns false after last step, otherwise temporary state
* @access public
*/
public function enable_step($old_state)
{
if ($old_state === false)
{
/** @var \phpbb\notification\manager $notification_manager */
$notification_manager = $this->container->get('notification_manager');
$notification_manager->enable_notifications('phpbbstudio.ass.notification.type.gift');
$notification_manager->enable_notifications('phpbbstudio.ass.notification.type.stock');
return 'notification';
}
return parent::enable_step($old_state);
}
/**
* Disable notifications for the extension.
*
* @param mixed $old_state State returned by previous call of this method
* @return mixed Returns false after last step, otherwise temporary state
* @access public
*/
public function disable_step($old_state)
{
if ($old_state === false)
{
try
{
if ($this->container->hasParameter('phpbbstudio.ass.extended'))
{
$language = $this->container->get('language');
$language->add_lang('ass_ext', 'phpbbstudio/ass');
$message = $language->lang('ASS_DISABLE_EXTENDED', $this->container->getParameter('phpbbstudio.ass.extended'));
// Trigger error for the ACP
@trigger_error($message, E_USER_WARNING);
// Throw an exception for the CLI
throw new \RuntimeException($message);
}
}
catch (\InvalidArgumentException $e)
{
// Continue
}
/** @var \phpbb\notification\manager $notification_manager */
$notification_manager = $this->container->get('notification_manager');
$notification_manager->disable_notifications('phpbbstudio.ass.notification.type.gift');
$notification_manager->disable_notifications('phpbbstudio.ass.notification.type.stock');
return 'notification';
}
return parent::disable_step($old_state);
}
/**
* Purge notifications for the extension.
*
* @param mixed $old_state State returned by previous call of this method
* @return mixed Returns false after last step, otherwise temporary state
* @access public
*/
public function purge_step($old_state)
{
if ($old_state === false)
{
/** @var \phpbb\notification\manager $notification_manager */
$notification_manager = $this->container->get('notification_manager');
$notification_manager->purge_notifications('phpbbstudio.ass.notification.type.gift');
$notification_manager->purge_notifications('phpbbstudio.ass.notification.type.stock');
return 'notification';
}
return parent::purge_step($old_state);
}
}