1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Zemit Framework. |
4
|
|
|
* |
5
|
|
|
* (c) Zemit Team <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE.txt |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace App\Provider\Imap; |
12
|
|
|
|
13
|
|
|
use Phalcon\Di\DiInterface; |
14
|
|
|
use Zemit\Bootstrap\Config; |
15
|
|
|
use Zemit\Provider\AbstractServiceProvider; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Zemit\Provider\Imap\ServiceProvider |
19
|
|
|
* |
20
|
|
|
* @package Zemit\Provider\Imap |
21
|
|
|
*/ |
22
|
|
|
class ServiceProvider extends AbstractServiceProvider |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* The Service name. |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
protected $serviceName = 'imap'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* {@inheritdoc} |
32
|
|
|
* |
33
|
|
|
* Register the Flash Service with the Twitter Bootstrap classes. |
34
|
|
|
* |
35
|
|
|
* @return void |
36
|
|
|
*/ |
37
|
|
|
public function register(DiInterface $di): void |
38
|
|
|
{ |
39
|
|
|
$di->setShared($this->getName(), function() use ($di) { |
|
|
|
|
40
|
|
|
/** @var Config $config */ |
41
|
|
|
$config = $di->get('config'); |
42
|
|
|
|
43
|
|
|
$defaults = $config->path('imap')->toArray(); |
44
|
|
|
|
45
|
|
|
return new \PhpImap\Mailbox( |
46
|
|
|
$defaults['path'] ?? '', |
47
|
|
|
$defaults['login'] ?? '', |
48
|
|
|
$defaults['password'] ?? '', |
49
|
|
|
$defaults['attachmentsDir'] ?? '', |
50
|
|
|
$defaults['serverEncoding'] ?? 'UTF-8', |
51
|
|
|
$defaults['trimImapPath'] ?? true, |
52
|
|
|
$defaults['attachmentFilenameMode'] ?? false, |
53
|
|
|
); |
54
|
|
|
}); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|