99
1010namespace Dot \Controller \Plugin \Mail \Factory ;
1111
12-
1312use Dot \Controller \Plugin \Mail \MailPlugin ;
1413use Dot \Mail \Factory \AbstractMailFactory ;
1514use 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+ }
0 commit comments