Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] SpeckCart rewrite #30

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.buildpath
.project
.settings/
.DS_Store
.DS_Store
vendor
composer.lock
composer.phar
23 changes: 23 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Copyright (c) 2010-2015 Roave, LLC.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

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 HOLDER 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.
53 changes: 6 additions & 47 deletions Module.php
Original file line number Diff line number Diff line change
@@ -1,56 +1,24 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
* SpeckCommerce (http://speckcommerce.com)
*
* @link http://github.com/zendframework/ZendSkeletonModule for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @link http://github.com/speckcommerce/SpeckCart for the canonical source repository
* @copyright Copyright (c) 2010-2015 Roave, LLC.
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/

namespace SpeckCart;
namespace Speckcommerce\Cart;

use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\Mvc\ModuleRouteListener;

class Module implements AutoloaderProviderInterface
{
public function getServiceConfig()
{
return array(
'factories' => array(
'SpeckCart\Service\CartService' => function($sm) {
$service = new Service\CartService;
$service->setItemMapper($sm->get('SpeckCart\Mapper\CartItemMapperZendDb'));
$service->setCartMapper($sm->get('SpeckCart\Mapper\CartMapperZendDb'));
$service->setEventManager($sm->get('EventManager'));
$service->attachDefaultListeners();
return $service;
},

'SpeckCart\Mapper\CartMapperZendDb' => function($sm) {
$mapper = new Mapper\CartMapperZendDb;
$mapper->setDbAdapter($sm->get('speckcart_db_adapter'));
return $mapper;
},

'SpeckCart\Mapper\CartItemMapperZendDb' => function($sm) {
$mapper = new Mapper\CartItemMapperZendDb;
$mapper->setDbAdapter($sm->get('speckcart_db_adapter'));
return $mapper;
},
),
);
}

public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
__NAMESPACE__ => __DIR__ . '/src/Speckcommerce/Cart',
),
),
);
Expand All @@ -60,13 +28,4 @@ public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}

public function onBootstrap($e)
{
// You may not need to do this if you're doing it elsewhere in your
// application
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
}
}
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Speckcommerce Cart module
=========================

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

1. Require speckcommerce/speck-cart:

```sh
composer.phar require speckcommerce/assetmanager
#when asked for a version, type "develop".
```

Post installation
------------------

1. Enabling it in your `application.config.php`file.

```php
<?php
return array(
'modules' => array(
// ...
'Speckcommerce\Cart',
),
// ...
);
```
2. Make sure db adapter for doctrine is configured then run from application root:

```sh
vendor/bin/doctrine-module orm:schema-tool:create
```

TODO
----

- Update README with detailed installation instructions
- Add DomanEvents
- Move Doctrine annotations on entities to xml or similar
4 changes: 0 additions & 4 deletions autoload_classmap.php

This file was deleted.

12 changes: 0 additions & 12 deletions autoload_function.php

This file was deleted.

2 changes: 0 additions & 2 deletions autoload_register.php

This file was deleted.

23 changes: 16 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
{
"name": "speckcommerce/speck-cart",
"description": "",
"description": "SpeckCommerce project cart module",
"license": "BSD-2-Clause",
"type": "library",
"keywords": [
"zf2"
"zf2",
"speckcommerce",
"cart"
],
"homepage": "http://github.com/speckcommerce/SpeckCart",
"authors": [
],
"require": {
"php": ">=5.4",
"zendframework/zendframework": "2.*"
"php": ">=5.5",
"beberlei/assert": "~2.0",
"doctrine/orm": "~2.4",
"mathiasverraes/money": "~1.2",
"rhumsaa/uuid": "~2.7",
"zendframework/zendframework": "~2.3"
},
"require-dev": {
"phpunit/phpunit": "4.1.*"
},
"autoload": {
"psr-0": {
"SpeckCart": "src/"
"Speckcommerce\\Cart": "src/"
},
"classmap": [
"./"
"./Module.php"
]
}
}

62 changes: 17 additions & 45 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,25 @@
'speckcart_db_adapter' => 'Zend\Db\Adapter\Adapter'
),
),
'doctrine' => [
'driver' => [
'speckcommerce_cart_driver' => [
'class' =>'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => [__DIR__ . '/../src/Speckcommerce/Cart/Domain']
],

'controllers' => array(
'invokables' => array(
'speckcart' => 'SpeckCart\Controller\CartController',
),
),

'router' => array(
'routes' => array(
'cart' => array(
'type' => 'Literal',
'priority' => 1000,
'options' => array(
'route' => '/cart',
'defaults' => array(
'controller' => 'speckcart',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'empty-cart' => array(
'type' => 'Literal',
'options' => array(
'route' => '/empty-cart',
'defaults' => array(
'controller' => 'speckcart',
'action' => 'empty-cart',
),
),
),
'update-quantities' => array(
'type' => 'Literal',
'options' => array(
'route' => '/update-quantities',
'defaults' => array(
'controller' => 'speckcart',
'action' => 'update-quantities',
),
),
),
),
),
),
),

'orm_default' => [
'drivers' => [
'Speckcommerce\Cart\Domain' => 'speckcommerce_cart_driver'
]
]
]
],
'view_manager' => array(
'controller_map' => [
'SpeckCommerce\Cart' => true,
],
'template_path_stack' => array(
__DIR__ . '/../view',
),
Expand Down
22 changes: 0 additions & 22 deletions data/schema.sql

This file was deleted.

23 changes: 23 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<phpunit
bootstrap="vendor/autoload.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="true"
processIsolation="false"
stopOnFailure="false"
strict="false"
syntaxCheck="true"
>
<testsuite name="Speckcommerce Cart tests">
<directory>./tests/SpeckcommerceTest</directory>
</testsuite>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</phpunit>
64 changes: 0 additions & 64 deletions src/SpeckCart/Controller/CartController.php

This file was deleted.

Loading