Skip to content

Commit

Permalink
moved the closures out from the config into the module class
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmarsal committed Jan 30, 2014
1 parent ce50a40 commit 0e0c735
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 40 deletions.
24 changes: 24 additions & 0 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

use RbComment\Model\Comment as RbComment;
use RbComment\Model\CommentTable as RbCommentTable;
use ZendService\Akismet\Akismet;
use Zend\Db\ResultSet\ResultSet;
use Zend\Mail\Transport\Sendmail;
use Zend\Db\TableGateway\TableGateway;

class Module
Expand Down Expand Up @@ -43,6 +45,28 @@ public function getServiceConfig()
$resultSetPrototype->setArrayObjectPrototype(new RbComment());
return new TableGateway('rb_comments', $dbAdapter, null, $resultSetPrototype);
},
/**
* Placeholder transport config. Do not use this in production.
* Replace with smtp.
*/
'RbComment\Mailer' => function () {
return new Sendmail();
},
/**
* Akismet service instance factory. Uses the config down below.
*/
'RbComment\Akismet' => function ($serviceManager) {

$config = $serviceManager->get('Config');
$viewHelperManager = $serviceManager->get('viewhelpermanager');

$akismetConfig = $config['rb_comment']['akismet'];

return new Akismet(
$akismetConfig['api_key'],
$viewHelperManager->get('serverUrl')->__invoke()
);
}
),
);
}
Expand Down
19 changes: 5 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,11 @@ This array contains email notifications parameters
'context_link_text' => 'See this comment in context',
),
```
For sending the emails the module uses a service factory called `RbComment\Mailer`. As a default it configures a sendmail transport. This should be changed in production and customized to your needs (probably with smtp). To do this rewrite the service factory in your `config/autoload/global.php` file.
```php
'service_manager' => array(
'factories' => array(
/**
* Placeholder transport config. Do not use this in production.
* Replace with smtp.
*/
'RbComment\Mailer' => function () {
return new Zend\Mail\Transport\Sendmail();
},
),
),
```
For sending the emails the module uses a service factory called `RbComment\Mailer`.
As a default it configures a sendmail transport. This should be changed in
production and customized to your needs (probably with smtp).
To do this rewrite the service factory `RbComment\Mailer`.

#### akismet

The module provides integration with the Akismet service. Comments marked as
Expand Down
26 changes: 0 additions & 26 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,6 @@
'rbcomment/theme/default' => __DIR__ . '/../view/theme/default.phtml',
),
),
'service_manager' => array(
'factories' => array(
/**
* Placeholder transport config. Do not use this in production.
* Replace with smtp.
*/
'RbComment\Mailer' => function () {
return new Zend\Mail\Transport\Sendmail();
},
/**
* Akismet service instance factory. Uses the config down below.
*/
'RbComment\Akismet' => function ($serviceManager) {

$config = $serviceManager->get('Config');
$viewHelperManager = $serviceManager->get('viewhelpermanager');

$akismetConfig = $config['rb_comment']['akismet'];

return new ZendService\Akismet\Akismet(
$akismetConfig['api_key'],
$viewHelperManager->get('serverUrl')->__invoke()
);
}
),
),
'rb_comment' => array(
/**
* Default visibility of the comments.
Expand Down

0 comments on commit 0e0c735

Please sign in to comment.