This repository has been archived by the owner on Jul 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
435 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
SlackBundle v1.1.0 | ||
================== | ||
- Feature: Added Provider for Silex-Integration | ||
- Feature: Added Attachments to the Messaging-Methods | ||
- (NOT BC) Refactor: Identities are only needed for Chat, so no general use is needed | ||
|
||
SlackBundle v1.0.0 | ||
================== | ||
- Initial Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Silex Integration | ||
|
||
In the Bundle there is a SilexProvider you can use with your Silex-Application. There is no need to get an extra Package. The Provider delivers the following Extensions: | ||
|
||
$app['dz.slack.connection'] # Slack/Client/Connection.php | ||
$app['dz.slack.client'] # Slack/Client.php | ||
$app['dz.slack.identity_bag'] # Slack/Messaging/IdentityBag.php | ||
$app['dz.slack.messaging'] # Slack/Messaging.php | ||
|
||
To configure the SlackBundle in Silex there is the need to set some Configuration-Values | ||
|
||
``` php | ||
$app['dz.slack.options'] = [ | ||
'token' => 'YOUR TOKEN HERE, | ||
'identities' => [ | ||
'YOUR IDENTITIY' => [] | ||
], | ||
'logging' => [ | ||
'enabled' => true, | ||
'channel' => 'YOUR CHANNEL TO LOG TO', | ||
'identity' => 'THE IDENTITY TO LOG WITH' | ||
] | ||
]; | ||
``` | ||
|
||
Wit these Options set you can load the Provider in your index | ||
|
||
``` php | ||
$app->register(new DZunke\SlackBundle\Silex\Provider\SlackServiceProvider()); | ||
``` | ||
|
||
## Monolog Integration | ||
|
||
If you want to integrate the SlackHandler to an Instance of Monolog be sure the logging is enabled in the config. In that case the Provider will try to add the Handler to the default Logger ```$app['monolog']```. It will use the same LogLevel as the default Logger. | ||
|
||
Be sure that the MonologProvider is handled before! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
|
||
namespace DZunke\SlackBundle\Silex\Provider; | ||
|
||
use DZunke\SlackBundle\Monolog\Handler\SlackHandler; | ||
use DZunke\SlackBundle\Slack\Client; | ||
use DZunke\SlackBundle\Slack\Messaging; | ||
use Silex\Application; | ||
use Silex\Provider\MonologServiceProvider; | ||
use Silex\ServiceProviderInterface; | ||
|
||
class SlackServiceProvider implements ServiceProviderInterface | ||
{ | ||
|
||
public function register(Application $app) | ||
{ | ||
$default_options = [ | ||
'endpoint' => 'slack.com/api/', | ||
'token' => null, | ||
'limit_retries' => 5, | ||
'identities' => [ | ||
'Silex' => [] | ||
], | ||
'logging' => [ | ||
'enabled' => false, | ||
'channel' => '', | ||
'identity' => '' | ||
] | ||
]; | ||
|
||
if (isset($app['dz.slack.options'])) { | ||
$app['dz.slack.options'] = array_merge($default_options, $app['dz.slack.options']); | ||
} else { | ||
$app['dz.slack.options'] = $default_options; | ||
} | ||
|
||
$app['dz.slack.identity_bag'] = $app->share( | ||
function ($app) { | ||
$identityBag = new Messaging\IdentityBag(); | ||
$identityBag->createIdentities($app['dz.slack.options']['identities']); | ||
|
||
return $identityBag; | ||
} | ||
); | ||
|
||
$app['dz.slack.connection'] = $app->share( | ||
function ($app) { | ||
$connection = new Client\Connection(); | ||
$connection->setEndpoint($app['dz.slack.options']['endpoint']); | ||
$connection->setLimitRetries($app['dz.slack.options']['limit_retries']); | ||
$connection->setToken($app['dz.slack.options']['token']); | ||
|
||
return $connection; | ||
} | ||
); | ||
|
||
$app['dz.slack.client'] = $app->share( | ||
function ($app) { | ||
return new Client($app['dz.slack.connection']); | ||
} | ||
); | ||
|
||
$app['dz.slack.messaging'] = $app->share( | ||
function ($app) { | ||
return new Messaging($app['dz.slack.client'], $app['dz.slack.identity_bag']); | ||
} | ||
); | ||
|
||
if ($app['dz.slack.options']['logging']['enabled']) { | ||
|
||
$app['monolog.handler.slack'] = $app->share( | ||
function ($app) { | ||
$level = MonologServiceProvider::translateLevel($app['monolog.level']); | ||
|
||
return new SlackHandler( | ||
$app['dz.slack.messaging'], | ||
$app['dz.slack.options']['logging']['channel'], | ||
$app['dz.slack.options']['logging']['identity'], | ||
$level | ||
); | ||
} | ||
); | ||
|
||
$app['monolog']->pushHandler($app['monolog.handler.slack']); | ||
|
||
} | ||
} | ||
|
||
public function boot(Application $app) | ||
{ | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.