Skip to content

Commit

Permalink
Merge pull request #107 from shandyDev/master
Browse files Browse the repository at this point in the history
[Feature] ZF3 support (no BC breaks)
  • Loading branch information
bakura10 authored Oct 10, 2016
2 parents e63377c + d45ae3b commit c7de104
Show file tree
Hide file tree
Showing 23 changed files with 450 additions and 62 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
composer.phar
composer.lock
vendor/
.idea/
27 changes: 23 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
language: php

php:
- 5.6
- 7.0
matrix:
fast_finish: true
include:
- php: 5.6
env:
- DEPS=lowest
- php: 5.6
env:
- DEPS=latest
- php: 7.0
env:
- DEPS=lowest
- php: 7.0
env:
- DEPS=latest
env:
global:
- COMPOSER_ARGS="--no-interaction --ignore-platform-reqs"

cache:
directories:
- $HOME/.composer/cache

before_script:
install:
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update --prefer-stable --prefer-source $COMPOSER_ARGS ; fi
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable --prefer-source $COMPOSER_ARGS ; fi
- composer install --dev --prefer-source
- travis_retry composer install --dev $COMPOSER_ARGS
- composer show --installed

script:
- phpunit --configuration tests/phpunit.xml
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# CHANGELOG
## 2.1.0
- Added ZF3 support
-- which allow install zend-servicemanager both versions v2 or v3 by composer
- Updated & reduced composer dependencies (dropped install full ZF2 framework)
- Small PHP syntax's fixes & added gitignore file


## 2.0.0
- bump to aws-sdk-for-php ZF2 module to 2.*
-- which in turn bumps support to AWS SDK for PHP v3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Requirements
------------

* PHP 5.6
* [Zend Framework 2](https://github.com/zendframework/zf2)
* [Zend Framework 2](https://github.com/zendframework/zf2) OR [ZF3 components](https://docs.zendframework.com/tutorials/)
* [Amazon AWS ZF 2 Module](https://github.com/aws/aws-sdk-php-zf2): only if you plan to use Amazon SES service

Installation
Expand Down
19 changes: 15 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,24 @@
}
],
"require": {
"php": ">=5.6",
"zendframework/zend-mail": "~2.0",
"zendframework/zend-http": "~2.0"
"php": "^5.6 || ^7.0",
"zendframework/zend-mail": "^2.6",
"zendframework/zend-http": "^2.5",
"zendframework/zend-mime": "^2.6",
"zendframework/zend-servicemanager": "^2.7 || ^3.1"
},
"require-dev": {
"aws/aws-sdk-php-zf2": "~2.0",
"zendframework/zendframework": "~2.0"
"container-interop/container-interop": "^1.1",
"zendframework/zend-modulemanager": "^2.7",
"zendframework/zend-mvc": "^2.7 || ^3.0",
"zendframework/zend-view": "^2.6",
"zendframework/zend-log": "^2.6",
"zendframework/zend-i18n": "^2.6",
"zendframework/zend-serializer": "^2.6",
"zendframework/zend-config": "^2.6",
"doctrine/instantiator": "^1.0.5",
"phpunit/phpunit": "^5.5"
},
"suggest": {
"aws/aws-sdk-php-zf2": "If you need to use Amazon SES"
Expand Down
53 changes: 26 additions & 27 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,40 +37,39 @@
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @link http://juriansluiman.nl
*/
use SlmMail\Factory;
use SlmMail\Service;

return array(
'service_manager' => array(
'factories' => array(
return [
'service_manager' => [
'factories' => [
/**
* Transport
*/
'SlmMail\Mail\Transport\ElasticEmailTransport' => 'SlmMail\Factory\ElasticEmailTransportFactory',
'SlmMail\Mail\Transport\MailgunTransport' => 'SlmMail\Factory\MailgunTransportFactory',
'SlmMail\Mail\Transport\MandrillTransport' => 'SlmMail\Factory\MandrillTransportFactory',
'SlmMail\Mail\Transport\PostageTransport' => 'SlmMail\Factory\PostageTransportFactory',
'SlmMail\Mail\Transport\PostmarkTransport' => 'SlmMail\Factory\PostmarkTransportFactory',
'SlmMail\Mail\Transport\SendGridTransport' => 'SlmMail\Factory\SendGridTransportFactory',
'SlmMail\Mail\Transport\SesTransport' => 'SlmMail\Factory\SesTransportFactory',

'SlmMail\Mail\Transport\ElasticEmailTransport' => Factory\ElasticEmailTransportFactory::class,
'SlmMail\Mail\Transport\MailgunTransport' => Factory\MailgunTransportFactory::class,
'SlmMail\Mail\Transport\MandrillTransport' => Factory\MandrillTransportFactory::class,
'SlmMail\Mail\Transport\PostageTransport' => Factory\PostageTransportFactory::class,
'SlmMail\Mail\Transport\PostmarkTransport' => Factory\PostmarkTransportFactory::class,
'SlmMail\Mail\Transport\SendGridTransport' => Factory\SendGridTransportFactory::class,
'SlmMail\Mail\Transport\SesTransport' => Factory\SesTransportFactory::class,
/**
* Services
*/
'SlmMail\Service\ElasticEmailService' => 'SlmMail\Factory\ElasticEmailServiceFactory',
'SlmMail\Service\MailgunService' => 'SlmMail\Factory\MailgunServiceFactory',
'SlmMail\Service\MandrillService' => 'SlmMail\Factory\MandrillServiceFactory',
'SlmMail\Service\PostageService' => 'SlmMail\Factory\PostageServiceFactory',
'SlmMail\Service\PostmarkService' => 'SlmMail\Factory\PostmarkServiceFactory',
'SlmMail\Service\SendGridService' => 'SlmMail\Factory\SendGridServiceFactory',
'SlmMail\Service\SesService' => 'SlmMail\Factory\SesServiceFactory',

Service\ElasticEmailService::class => Factory\ElasticEmailServiceFactory::class,
Service\MailgunService::class => Factory\MailgunServiceFactory::class,
Service\MandrillService::class => Factory\MandrillServiceFactory::class,
Service\PostageService::class => Factory\PostageServiceFactory::class,
Service\PostmarkService::class => Factory\PostmarkServiceFactory::class,
Service\SendGridService::class => Factory\SendGridServiceFactory::class,
Service\SesService::class => Factory\SesServiceFactory::class,
/**
* HTTP client
*/
'SlmMail\Http\Client' => 'SlmMail\Factory\HttpClientFactory',
),
),

'slm_mail' => array(
'http_adapter' => 'Zend\Http\Client\Adapter\Socket',
),
);
'SlmMail\Http\Client' => Factory\HttpClientFactory::class,
],
],
'slm_mail' => [
'http_adapter' => \Zend\Http\Client\Adapter\Socket::class,
],
];
26 changes: 24 additions & 2 deletions src/SlmMail/Factory/ElasticEmailServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@

namespace SlmMail\Factory;

use Interop\Container\ContainerInterface;
use Interop\Container\Exception\ContainerException;
use SlmMail\Factory\Exception\RuntimeException;
use SlmMail\Service\ElasticEmailService;
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
use Zend\ServiceManager\Exception\ServiceNotFoundException;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

Expand All @@ -52,7 +56,25 @@ class ElasticEmailServiceFactory implements FactoryInterface
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Config');
return $this($serviceLocator, ElasticEmailService::class);
}

/**
* Create an object
*
* @param ContainerInterface $container
* @param string $requestedName
* @param null|array $options
*
* @return ElasticEmailService
* @throws ServiceNotFoundException if unable to resolve the service.
* @throws ServiceNotCreatedException if an exception is raised when
* creating a service.
* @throws ContainerException if any other error occurs
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
$config = $container->get('Config');

if (!isset($config['slm_mail']['elastic_email'])) {
throw new RuntimeException(
Expand All @@ -63,7 +85,7 @@ public function createService(ServiceLocatorInterface $serviceLocator)
$config = $config['slm_mail']['elastic_email'];
$service = new ElasticEmailService($config['username'], $config['key']);

$client = $serviceLocator->get('SlmMail\Http\Client');
$client = $container->get('SlmMail\Http\Client');
$service->setClient($client);

return $service;
Expand Down
25 changes: 24 additions & 1 deletion src/SlmMail/Factory/ElasticEmailTransportFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@

namespace SlmMail\Factory;

use Interop\Container\ContainerInterface;
use Interop\Container\Exception\ContainerException;
use SlmMail\Mail\Transport\HttpTransport;
use SlmMail\Service\ElasticEmailService;
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
use Zend\ServiceManager\Exception\ServiceNotFoundException;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

Expand All @@ -51,6 +56,24 @@ class ElasticEmailTransportFactory implements FactoryInterface
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
return new HttpTransport($serviceLocator->get('SlmMail\Service\ElasticEmailService'));
return $this($serviceLocator, 'SlmMail\Mail\Transport\ElasticEmailTransport');
}

/**
* Create an object
*
* @param ContainerInterface $container
* @param string $requestedName
* @param null|array $options
*
* @return HttpTransport
* @throws ServiceNotFoundException if unable to resolve the service.
* @throws ServiceNotCreatedException if an exception is raised when
* creating a service.
* @throws ContainerException if any other error occurs
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
return new HttpTransport($container->get(ElasticEmailService::class));
}
}
24 changes: 23 additions & 1 deletion src/SlmMail/Factory/HttpClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@

namespace SlmMail\Factory;

use Interop\Container\ContainerInterface;
use Interop\Container\Exception\ContainerException;
use Zend\Http\Client as HttpClient;
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
use Zend\ServiceManager\Exception\ServiceNotFoundException;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

Expand All @@ -51,7 +55,25 @@ class HttpClientFactory implements FactoryInterface
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Config');
return $this($serviceLocator, 'SlmMail\Http\Client');
}

/**
* Create an object
*
* @param ContainerInterface $container
* @param string $requestedName
* @param null|array $options
*
* @return object
* @throws ServiceNotFoundException if unable to resolve the service.
* @throws ServiceNotCreatedException if an exception is raised when
* creating a service.
* @throws ContainerException if any other error occurs
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
$config = $container->get('Config');

$client = new HttpClient();
$client->setAdapter($config['slm_mail']['http_adapter']);
Expand Down
26 changes: 24 additions & 2 deletions src/SlmMail/Factory/MailgunServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@

namespace SlmMail\Factory;

use Interop\Container\ContainerInterface;
use Interop\Container\Exception\ContainerException;
use SlmMail\Factory\Exception\RuntimeException;
use SlmMail\Service\MailgunService;
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
use Zend\ServiceManager\Exception\ServiceNotFoundException;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

Expand All @@ -52,7 +56,25 @@ class MailgunServiceFactory implements FactoryInterface
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Config');
return $this($serviceLocator, MailgunService::class);
}

/**
* Create an object
*
* @param ContainerInterface $container
* @param string $requestedName
* @param null|array $options
*
* @return MailgunService
* @throws ServiceNotFoundException if unable to resolve the service.
* @throws ServiceNotCreatedException if an exception is raised when
* creating a service.
* @throws ContainerException if any other error occurs
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
$config = $container->get('Config');

if (!isset($config['slm_mail']['mailgun'])) {
throw new RuntimeException(
Expand All @@ -63,7 +85,7 @@ public function createService(ServiceLocatorInterface $serviceLocator)
$config = $config['slm_mail']['mailgun'];
$service = new MailgunService($config['domain'], $config['key']);

$client = $serviceLocator->get('SlmMail\Http\Client');
$client = $container->get('SlmMail\Http\Client');
$service->setClient($client);

return $service;
Expand Down
25 changes: 24 additions & 1 deletion src/SlmMail/Factory/MailgunTransportFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@

namespace SlmMail\Factory;

use Interop\Container\ContainerInterface;
use Interop\Container\Exception\ContainerException;
use SlmMail\Mail\Transport\HttpTransport;
use SlmMail\Service\MailgunService;
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
use Zend\ServiceManager\Exception\ServiceNotFoundException;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

Expand All @@ -51,6 +56,24 @@ class MailgunTransportFactory implements FactoryInterface
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
return new HttpTransport($serviceLocator->get('SlmMail\Service\MailgunService'));
return $this($serviceLocator, 'SlmMail\Mail\Transport\MailgunTransport');
}

/**
* Create an object
*
* @param ContainerInterface $container
* @param string $requestedName
* @param null|array $options
*
* @return HttpTransport
* @throws ServiceNotFoundException if unable to resolve the service.
* @throws ServiceNotCreatedException if an exception is raised when
* creating a service.
* @throws ContainerException if any other error occurs
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
return new HttpTransport($container->get(MailgunService::class));
}
}
Loading

0 comments on commit c7de104

Please sign in to comment.