Completed
Pull Request — master (#392)
by
unknown
01:34
created

DrupalMailManager::restoreInitialMailBackend()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Drupal;
4
5
use Drupal\Driver\DriverInterface;
6
7
/**
8
 * Default implementation of the Drupal mail manager service.
9
 * 
10
 * This uses Drupal core's test_mail_collector mail backend, which both
11
 * collects outbound mail and prevents it from being sent. Therefore using
12
 * this implementation, mail is collected if and only if sending is disabled.
13
 */
14
class DrupalMailManager implements DrupalMailManagerInterface {
15
16
  /**
17
   * The active Drupal driver.
18
   *
19
   * @var \Drupal\Driver\DriverInterface
20
   */
21
  protected $driver;
22
  
23
  public function __construct(DriverInterface $driver) {
24
    $this->driver = $driver;
25
  }
26
27
  /**
28
   * {@inheritdoc}
29
   */
30
  public function startCollectingMail() {
31
    $this->driver->startCollectingMail();
0 ignored issues
show
Bug introduced by
The method startCollectingMail() does not seem to exist on object<Drupal\Driver\DriverInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
    $this->clearMail();
33
  }
34
35
  /**
36
   * {@inheritdoc}
37
   */
38
  public function stopCollectingMail() {
39
    $this->driver->stopCollectingMail();
0 ignored issues
show
Bug introduced by
The method stopCollectingMail() does not seem to exist on object<Drupal\Driver\DriverInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
40
  }
41
  
42
  /**
43
   * {@inheritdoc}
44
   */
45
  public function enableMail() {
46
    $this->stopCollectingMail();
47
  }
48
49
  /**
50
   * {@inheritdoc}
51
   */
52
  public function disableMail() {
53
    $this->startCollectingMail();
54
  }
55
  
56
  /**
57
   * {@inheritdoc}
58
   */
59
  public function getMail($store = 'default') {
60
    return $this->driver->getMail();
0 ignored issues
show
Bug introduced by
The method getMail() does not seem to exist on object<Drupal\Driver\DriverInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
61
  }
62
63
  /**
64
   * {@inheritdoc}
65
   */
66
  public function clearMail($store = 'default') {
67
    $this->driver->clearMail();
0 ignored issues
show
Bug introduced by
The method clearMail() does not seem to exist on object<Drupal\Driver\DriverInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
68
  }
69
70
}
71