function mailsystem_get_classes in Mail System 8.2
Same name and namespace in other branches
- 8 mailsystem.admin.inc \mailsystem_get_classes()
- 6.2 mailsystem.module \mailsystem_get_classes()
- 6 mailsystem.admin.inc \mailsystem_get_classes()
- 7.3 mailsystem.module \mailsystem_get_classes()
- 7 mailsystem.admin.inc \mailsystem_get_classes()
- 7.2 mailsystem.module \mailsystem_get_classes()
Returns a list of classes which implement MailSystemInterface.
2 calls to mailsystem_get_classes()
- mailsystem_admin_settings in ./
mailsystem.admin.inc - @file Administrative form for setting the mail_system variable.
- mailsystem_init in ./
mailsystem.module - Implements hook_init().
1 string reference to 'mailsystem_get_classes'
- mailsystem_create_class in ./
mailsystem.module - Creates and registers a new MailSystemInterface class.
File
- ./
mailsystem.module, line 259 - Provide UI for controlling the mail_system variable.
Code
function &mailsystem_get_classes() {
$mailsystem_classes =& drupal_static(__FUNCTION__);
if (!isset($mailsystem_classes)) {
$mailsystem_classes = array();
// @todo Is there a better way to find all mail-related classes?
$declared_classes = get_declared_classes();
$all_classes = array_combine($declared_classes, array_fill(0, count($declared_classes), 0));
$mail_classes = db_select('registry', 'registry')
->distinct()
->fields('registry', array(
'name',
'filename',
))
->where("type=:type AND ( filename like :filename OR name like :name )", array(
':type' => 'class',
':name' => '%MailSystem',
':filename' => '%.mail.%',
))
->execute()
->fetchAllKeyed();
foreach ($mail_classes as $classname => $classfile) {
if (file_exists($classfile) && drupal_autoload_class($classname)) {
$all_classes[$classname] = 1;
}
}
foreach ($all_classes as $classname => $autoload) {
if (($autoload || preg_match('/MailSystem/', $classname)) && ($object = new $classname()) && $object instanceof MailSystemInterface) {
$mailsystem_classes[$classname] = $classname;
}
elseif ($autoload) {
// Clear classes that are no longer available.
db_delete('registry')
->condition('name', $classname)
->execute();
}
}
foreach (array_unique(mailsystem_get()) as $classname) {
if (class_exists($classname)) {
$mailsystem_classes[$classname] = $classname;
}
else {
mailsystem_clear(array(
mailsystem_default_id() => $classname,
));
}
}
ksort($mailsystem_classes);
}
return $mailsystem_classes;
}