mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-13 14:58:52 +00:00
[ticket/11103] Get subscription types/methods functions in the service
PHPBB3-11103
This commit is contained in:
parent
3242ce0d3a
commit
28c8c0ce46
1 changed files with 69 additions and 0 deletions
|
@ -439,6 +439,43 @@ class phpbb_notifications_service
|
||||||
$this->db->sql_query($sql);
|
$this->db->sql_query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all of the subscription types
|
||||||
|
*
|
||||||
|
* @return array Array of item types
|
||||||
|
*/
|
||||||
|
public function get_subscription_types()
|
||||||
|
{
|
||||||
|
$subscription_types = array();
|
||||||
|
|
||||||
|
foreach ($this->get_subscription_files('notifications/type/') as $class => $file)
|
||||||
|
{
|
||||||
|
$class = $this->get_item_type_class_name($class);
|
||||||
|
|
||||||
|
if (!class_exists($class))
|
||||||
|
{
|
||||||
|
include($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method_exists($class, 'get_item_type'))
|
||||||
|
{
|
||||||
|
$subscription_types[] = $class::get_item_type();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $subscription_types;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all of the subscription methods
|
||||||
|
*
|
||||||
|
* @return array Array of methods
|
||||||
|
*/
|
||||||
|
public function get_subscription_methods()
|
||||||
|
{
|
||||||
|
return array_keys($this->get_subscription_files('notifications/method/'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a subscription
|
* Add a subscription
|
||||||
*
|
*
|
||||||
|
@ -536,4 +573,36 @@ class phpbb_notifications_service
|
||||||
|
|
||||||
return 'phpbb_notifications_type_' . $item_type;
|
return 'phpbb_notifications_type_' . $item_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper to get subscription related files with the finder
|
||||||
|
*/
|
||||||
|
private function get_subscription_files($path)
|
||||||
|
{
|
||||||
|
$ext_manager = $this->phpbb_container->get('ext.manager');
|
||||||
|
$php_ext = $this->phpbb_container->getParameter('core.php_ext');
|
||||||
|
|
||||||
|
$finder = $ext_manager->get_finder();
|
||||||
|
|
||||||
|
$subscription_files = array();
|
||||||
|
|
||||||
|
$files = $finder
|
||||||
|
->core_path('includes/' . $path)
|
||||||
|
->extension_directory($path)
|
||||||
|
->get_files();
|
||||||
|
foreach ($files as $file)
|
||||||
|
{
|
||||||
|
$class = substr($file, strrpos($file, '/'));
|
||||||
|
$class = substr($class, 1, (strpos($class, '.' . $php_ext) - 1));
|
||||||
|
|
||||||
|
if ($class == 'interface' || $class == 'base')
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$subscription_files[$class] = $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $subscription_files;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue