Skip to content

Commit

Permalink
Add module
Browse files Browse the repository at this point in the history
  • Loading branch information
bakura10 committed Jul 17, 2013
1 parent 7b64d51 commit ccf176f
Show file tree
Hide file tree
Showing 9 changed files with 276 additions and 3 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
._*
.~lock.*
.buildpath
.DS_Store
.idea
.project
.settings
Thumbs.db
phpunit.xml
tmp/
vendor/
composer.lock
composer.phar
50 changes: 50 additions & 0 deletions Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license.
*/

namespace ZfrMailChimpModule;

use Zend\ModuleManager\Feature;

/**
* @author Michaël Gallego <[email protected]>
* @licence MIT
*/
class Module implements Feature\AutoloaderProviderInterface, Feature\ConfigProviderInterface
{
/**
* {@inheritDoc}
*/
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}

/**
* {@inheritDoc}
*/
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
}
36 changes: 33 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
zfr-mailchimp-module
====================
ZfrMailChimpModule
==================

ZfrMailChimpModule is a Zend Framework 2 module based on [ZfrMailChimp](https://github.com/zf-fr/zfr-mailchimp).

Requirements
------------
* PHP 5.3
* [Zend Framework 2](https://github.com/zendframework/zf2)
* [ZfrMailChimp](https://github.com/zf-fr/zfr-mailchimp)

Installation
------------

We recommend you to use Composer to install ZfrMailChimp:

```sh
php composer.phar require zfr/zfr-mailchimp-module:dev-master
```sh
Enable ZfrMailChimpModule in your `application.config.php`, then copy-paste the file `zfr_mailchimp.local.php.dist` (that
you can find in the `config` folder of the module) to your `autoload` folder (don't forget to remove the .dist at
the end!).
Usage
-----
The module registers the MailChimpClient to the ZF 2 service manager. You can therefore get it like this:
```php
// If you want to client:
$mailChimpClient = $serviceManager->get('ZfrMailChimp\Client\MailChimpClient');
```
A Zend Framework 2 module around ZfrMailChimp
34 changes: 34 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "zfr/zfr-mailchimp-module",
"type": "library",
"license": "MIT",
"description" : "Zend Framework 2 module for interacting with the v2 MailChimp API, built on top of ZfrMailChimp",
"keywords": [
"mailchimp",
"campaign",
"mail chimp",
"zf2",
"bulk email"
],
"homepage": "https://github.com/zf-fr/zfr-mailchimp-module",
"authors": [
{
"name": "Michaël Gallego",
"email": "[email protected]",
"homepage": "http://www.michaelgallego.fr"
}
],
"require": {
"php": ">=5.3.3",
"zendframework/zend-servicemanager": "2.*",
"zfr/zfr-mailchimp": "dev-master"
},
"autoload": {
"psr-0": {
"ZfrMailChimpModule\\": "src/"
},
"classmap": [
"./"
]
}
}
25 changes: 25 additions & 0 deletions config/module.config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license.
*/

return array(
'service_manager' => array(
'factories' => array(
'ZfrMailChimp\Client\MailChimpClient' => 'ZfrMailChimpModule\Factory\MailChimpClientFactory',
),
),
);
26 changes: 26 additions & 0 deletions config/zfr_mailchimp.local.php.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license.
*/

return array(
'zfr_mailchimp' => array(
/**
* Specify your MailChimp API key. You can find it on your account
*/
// 'key' => ''
)
);
29 changes: 29 additions & 0 deletions src/ZfrMailChimpModule/Factory/Exception/RuntimeExcepti.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license.
*/

namespace ZfrMailChimpModule\Factory\Exception;

use RuntimeException as BaseRuntimeException;

/**
* @author Michaël Gallego <[email protected]>
* @licence MIT
*/
class RuntimeException extends BaseRuntimeException
{
}
38 changes: 38 additions & 0 deletions src/ZfrMailChimpModule/Factory/MailChimpClientFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Copyright (C) Maestrooo SAS - All Rights Reserved
*
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
*
* Written by Michaël Gallego <[email protected]>
*/

namespace ZfrMailChimpModule\Factory;

use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use ZfrMailChimp\Client\MailChimpClient;

/**
* @author Michaël Gallego <[email protected]>
* @licence MIT
*/
class MailChimpClientFactory implements FactoryInterface
{
/**
* {@inheritDoc}
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Config');

if (!isset($config['zfr_mailchimp'])) {
throw new Exception\RuntimeException(
'No config was found for ZfrMailChimpModule. Did you copy the `zfr_mailchimp.local.php` file to your autoload folder?'
);
}

return new MailChimpClient($config['zfr_mailchimp']['key']);
}
}
28 changes: 28 additions & 0 deletions src/ZfrMailChimpModule/Version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license.
*/

namespace ZfrMailChimpModule;

/**
* @author Michaël Gallego <[email protected]>
* @licence MIT
*/
class Version
{
const VERSION = '1.0.0-beta1';
}

0 comments on commit ccf176f

Please sign in to comment.