Skip to content

Commit c1b98ea

Browse files
authored
Merge pull request #1 from dotkernel/develop
Develop
2 parents ac0e66b + eb9d697 commit c1b98ea

4 files changed

Lines changed: 43 additions & 45 deletions

File tree

composer.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,17 @@
1111
],
1212
"require": {
1313
"php": "^5.6 || ^7.0",
14-
"psr/http-message": "^1.0",
1514
"container-interop/container-interop": "^1.1",
16-
"zendframework/zend-stdlib": "^3.0",
1715

18-
"dotkernel/dot-event": "0.6.x-dev",
19-
"dotkernel/dot-helpers": "0.6.x-dev",
20-
"dotkernel/dot-mail": "0.6.x-dev",
2116
"dotkernel/dot-controller": "0.6.x-dev"
2217
},
2318
"require-dev": {
2419
"phpunit/phpunit": "^4.8",
25-
"squizlabs/php_codesniffer": "^2.3"
20+
"squizlabs/php_codesniffer": "^2.3",
21+
22+
"dotkernel/dot-event": "0.6.x-dev",
23+
"dotkernel/dot-helpers": "0.6.x-dev",
24+
"dotkernel/dot-mail": "0.6.x-dev"
2625
},
2726
"autoload": {
2827
"psr-4": {

src/ConfigProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace Dot\Controller\Plugin\Mail;
1111

12-
1312
use Dot\Controller\Plugin\Mail\Factory\MailPluginAbstractFactory;
1413

1514
/**
@@ -34,4 +33,4 @@ public function __invoke()
3433
],
3534
];
3635
}
37-
}
36+
}

src/Factory/MailPluginAbstractFactory.php

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace Dot\Controller\Plugin\Mail\Factory;
1111

12-
1312
use Dot\Controller\Plugin\Mail\MailPlugin;
1413
use Dot\Mail\Factory\AbstractMailFactory;
1514
use Dot\Mail\Factory\MailServiceAbstractFactory;
@@ -42,24 +41,6 @@ public function canCreate(ContainerInterface $container, $requestedName)
4241
return array_key_exists($specificServiceName, $this->getConfig($container));
4342
}
4443

45-
/**
46-
* @param ContainerInterface $container
47-
* @param string $requestedName
48-
* @param array|null $options
49-
* @return MailPlugin
50-
*/
51-
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
52-
{
53-
$specificServiceName = $this->getSpecificServiceName($requestedName);
54-
55-
/** @var MailServiceInterface $mailService */
56-
$mailService = $container->get(sprintf(
57-
'%s.%s.%s', self::DOT_MAIL_PART, MailServiceAbstractFactory::SPECIFIC_PART, $specificServiceName
58-
));
59-
60-
return new MailPlugin($mailService);
61-
}
62-
6344
/**
6445
* @param $requestedName
6546
* @return string
@@ -74,12 +55,9 @@ protected function getSpecificServiceName($requestedName)
7455

7556
//discard the sendMail part
7657
$parts = array_slice($parts, 2);
77-
$specificServiceName = '';
78-
foreach ($parts as $part) {
79-
$specificServiceName .= $part;
80-
}
58+
$specificServiceName = implode('_', $parts);
8159

82-
//convert from camecase to underscores and set to lower
60+
//convert from camelcase to underscores and set to lower
8361
return strtolower($specificServiceName);
8462
}
8563

@@ -103,4 +81,27 @@ protected function camelCaseToUnderscore($value)
10381

10482
return preg_replace($pattern, $replacement, $value);
10583
}
106-
}
84+
85+
/**
86+
* @param ContainerInterface $container
87+
* @param string $requestedName
88+
* @param array|null $options
89+
* @return MailPlugin
90+
*/
91+
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
92+
{
93+
$specificServiceName = $this->getSpecificServiceName($requestedName);
94+
95+
/** @var MailServiceInterface $mailService */
96+
$mailService = $container->get(
97+
sprintf(
98+
'%s.%s.%s',
99+
self::DOT_MAIL_PART,
100+
MailServiceAbstractFactory::SPECIFIC_PART,
101+
$specificServiceName
102+
)
103+
);
104+
105+
return new MailPlugin($mailService);
106+
}
107+
}

src/MailPlugin.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,10 @@ protected function applyArgsToMailService(array $args)
108108
{
109109
if (isset($args['body'])) {
110110
$body = $args['body'];
111-
if(is_array($body)) {
111+
if (is_array($body)) {
112112
//consider this as a template name and its params
113113
$this->mailService->setTemplate($body[0], $body[1]);
114-
}
115-
else {
114+
} else {
116115
$this->mailService->setBody($body);
117116
}
118117
}
@@ -150,20 +149,20 @@ protected function applyArgsToMailService(array $args)
150149
}
151150

152151
/**
153-
* @param MailServiceInterface $mailService
154-
* @return $this
152+
* @return MailServiceInterface
155153
*/
156-
public function setMailService(MailServiceInterface $mailService)
154+
public function getMailService()
157155
{
158-
$this->mailService = $mailService;
159-
return $this;
156+
return $this->mailService;
160157
}
161158

162159
/**
163-
* @return MailServiceInterface
160+
* @param MailServiceInterface $mailService
161+
* @return $this
164162
*/
165-
public function getMailService()
163+
public function setMailService(MailServiceInterface $mailService)
166164
{
167-
return $this->mailService;
165+
$this->mailService = $mailService;
166+
return $this;
168167
}
169-
}
168+
}

0 commit comments

Comments
 (0)