Initial commit

This commit is contained in:
Paweł Jędrzejewski 2012-10-28 12:53:42 +01:00
commit c01edec86b
23 changed files with 1153 additions and 0 deletions

View file

@ -0,0 +1,7 @@
phpunit.xml
Tests/autoload.php
vendor/
composer.phar
composer.lock

View file

@ -0,0 +1,10 @@
language: php
php:
- 5.3
- 5.4
before_script: composer install --dev
notifications:
email: travis-ci@sylius.org

View file

@ -0,0 +1,390 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\ResourceBundle\Controller;
use FOS\RestBundle\Util\Pluralization;
use FOS\RestBundle\View\RouteRedirectView;
use FOS\RestBundle\View\View;
use Sylius\Bundle\ResourceBundle\Model\ResourceInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Base resource controller for Sylius.
*
* @author Paweł Jędrzejewski <pjedrzejewski@sylius.pl>
*/
abstract class ResourceController extends Controller implements ResourceControllerInterface
{
/**
* Get one resource.
*
* @param Request $request
*
* @return Response
*/
public function getAction(Request $request)
{
$identifier = $this->getIdentifierValue($request);
$resource = $this->findResourceOr404($identifier);
$view = View::create()
->setTemplate($this->getFullTemplateName('show'))
->setTemplateVar($this->getResourceName())
->setData($resource)
;
return $this->handleView($view);
}
/**
* Get all paginated resourcees.
*
* @param Request $request
*
* @return Response
*/
public function getCollectionAction(Request $request)
{
$paginator = $this->getManager()->createPaginator();
$paginator->setCurrentPage($request->query->get('page', 1), true, true);
$resources = $paginator->getCurrentPageResults();
$data = $this->isHtmlRequest() ? array(Pluralization::pluralize($this->getResourceName()) => $resources, 'paginator' => $paginator) : $resourcees;
$view = View::create()
->setTemplate($this->getFullTemplateName('list'))
->setData($data)
;
return $this->handleView($view);
}
/**
* Display form for creating new resource.
*
* @param Request $request
*
* @return Response
*/
public function newAction(Request $request)
{
$resource = $this->createResource();
$form = $this->createResourceForm($resource);
return $this->renderResponse('create', array(
$this->getResourceName() => $resource,
'form' => $form->createView()
));
}
/**
* Create resource.
*
* @param Request $request
*
* @return Response
*/
public function postAction(Request $request)
{
$resource = $this->createResource();
$form = $this->createResourceForm($resource);
$form->bind($request);
if ($form->isValid()) {
$this->getManipulator()->create($resource);
$this->setFlash('success', sprintf("%s has been created", ucfirst($this->getResourceName())));
return $this->redirectToResource($resource);
}
$htmlView = View::create()
->setTemplate($this->getFullTemplateName('create.html'))
->setData(array(
$this->getResourceName() => $resource,
'form' => $form->createView()
))
;
$view = $this->isHtmlRequest() ? $htmlView : View::create($form);
return $this->handleView($view);
}
/**
* Display form for editing resource.
*
* @param Request $request
*
* @return Response
*/
public function editAction(Request $request)
{
$resource = $this->findResourceOr404($request->get('id'));
$form = $this->createResourceForm($resource);
return $this->renderResponse('update', array(
$this->getResourceName() => $resource,
'form' => $form->createView()
));
}
/**
* Update resource.
*
* @param Request $request
*
* @return Response
*/
public function putAction(Request $request)
{
$resource = $this->findResourceOr404($request->get('id'));
$form = $this->createResourceForm($resource);
$form->bind($request);
if ($form->isValid()) {
$this->getManager()->persist($resource);
$this->setFlash('success', sprintf("%s has been updated", ucfirst($this->getResourceName())));
return $this->redirectToResource($resource);
}
$htmlView = View::create()
->setTemplate($this->getFullTemplateName('update.html'))
->setData(array(
$this->getResourceName() => $resource,
'form' => $form->createView()
))
;
$view = $this->isHtmlRequest() ? $htmlView : View::create($form);
return $this->handleView($view);
}
/**
* Deletes resource.
*
* @param Request $request
*
* @return Response
*/
public function deleteAction(Request $request)
{
$resource = $this->findResourceOr404($request->get('id'));
$this->getManager()->remove($resource);
$this->setFlash('success', sprintf("%s has been deleted", ucfirst($this->getResourceName())));
return $this->redirectToResourceCollection();
}
public function setFlash($name, $value)
{
if ($this->isHtmlRequest()) {
parent::setFlash($name, $value);
}
}
/**
* Create new resource instance.
*/
protected function createResource()
{
return $this->getManager()->create();
}
/**
* Create resource form.
*
* @param ResourceInterface $resource
*
* @return FormInterface
*/
protected function createResourceForm(ResourceInterface $resource = null)
{
return $this->createNamedForm('', $this->getResourceFormType(), $resource, array(
'csrf_protection' => false
));
}
/**
* Redirect to resource resource.
*
* @param ResourceInterface $resource
*
* @return RouteRedirectView
*/
protected function redirectToResource(ResourceInterface $resource)
{
$redirect = $this->getRequest()->attributes->get('_sylius.redirect');
$route = $redirect ? $redirect : $this->getResourceRoute();
return RouteRedirectView::create($route, array('id' => $resource->getId()));
}
/**
* Redirect to list of resourcees.
*
* @return RouteRedirectView
*/
protected function redirectToResourceCollection()
{
$redirect = $this->getRequest()->attributes->get('_sylius.redirect');
$route = $redirect ? $redirect : $this->getResourceCollectionRoute();
return RouteRedirectView::create($route);
}
protected function getResourceRoute()
{
throw new \BadMethodCallException('You have to implement this method');
}
protected function getResourceCollectionRoute()
{
throw new \BadMethodCallException('You have to implement this method');
}
/**
* Get resource manager.
*
* @return ManagerInterface
*/
protected function getManager()
{
return $this->container->get($this->getServiceName('manager'));
}
protected function getServiceName($name)
{
return sprintf('%s.%s.%s', $this->getBundlePrefix(), $name, $this->getResourceName());
}
/**
* Tries to find resource with given id.
* Throws special 404 exception when unsuccessful.
*
* @param mixed $id The resource identifier
*
* @return ResourceInterface
*
* @throws NotFoundHttpException
*/
protected function findResourceOr404($identifier)
{
$criteria = array($this->getIdentifierName() => $this->getIdentifierValue());
if (!$resource = $this->getManager()->findOneBy($criteria)) {
throw new NotFoundHttpException('Requested resource does not exist');
}
return $resource;
}
protected function getIdentifierName()
{
return $this->getRequest()->attributes->get('_sylius.identifier', 'id');
}
protected function getIdentifierValue()
{
if (!$identifier = $this->getRequest()->attributes->get($this->getIdentifierName())) {
throw new NotFoundHttpException('No resource identifier supplied');
}
return $identifier;
}
protected function renderResponse($templateName, array $parameters = array())
{
return $this->render($this->getFullTemplateName($templateName), $parameters);
}
/**
* Get full template name.
*
* @param string
*
* @return string
*/
protected function getFullTemplateName($name)
{
$template = $this->getRequest()->attributes->get('_sylius.template');
if (null !== $template) {
return $template;
}
return sprintf('%s:%s.%s',
$this->getTemplateNamespace(),
$name,
$this->getEngine()
);
}
/**
* Get engine.
*
* @return string
*/
protected function getEngine()
{
return $this->container->getParameter(sprintf('%s.engine', $this->getBundlePrefix()));
}
/**
* Check if request accepts html format.
*
* @return Boolean
*/
protected function isHtmlRequest()
{
return 'html' === $this->getRequest()->getRequestFormat();
}
/**
* Convert view to a response object.
*
* @param View $view
*
* @return Response
*/
protected function handleView(View $view)
{
return $this->get('fos_rest.view_handler')->handle($view);
}
/**
* Get name of the form type to use.
*
* @return string
*/
protected function getResourceFormType()
{
return sprintf('%s_%s', $this->getBundlePrefix(), $this->getResourceName());
}
/**
* Get templates namespace.
*
* @return string
*/
abstract protected function getTemplateNamespace();
abstract protected function getBundlePrefix();
}

View file

@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\ResourceBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
/**
* Resource controlller interface.
*
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
*/
interface ResourceControllerInterface
{
function getAction(Request $request);
function getCollectionAction(Request $request);
function newAction(Request $request);
function postAction(Request $request);
function editAction(Request $request);
function putAction(Request $request);
function deleteAction(Request $request);
}

View file

@ -0,0 +1,33 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\ResourceBundle\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
/**
* Resource system extension.
*
* @author Paweł Jędrzejewski <pjedrzejewski@sylius.pl>
*/
class SyliusResourceExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $config, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/container'));
}
}

View file

@ -0,0 +1,89 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\ResourceBundle\Manager\Doctrine;
use Doctrine\Common\Persistence\ObjectManager;
use Sylius\Bundle\ResourceBundle\Manager\ResourceManager;
use Sylius\Bundle\ResourceBundle\ResourceInterface;
/**
* Doctrine resource manager class.
*
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
*/
class DoctrineResourceManager extends ResourceManager implements DoctrineResourceManagerInterface
{
protected $objectManager;
protected $objectRepository;
public function __construct(ObjectManager $objectManager, $class)
{
$this->objectManager = $objectManager;
$this->objectRepository = $objectManager->getRepository($class);
parent::__construct($class);
}
/**
* {@inheritdoc}
*/
public function persist(ResourceInterface $resource, $commit = true)
{
$this->objectManager->persist($resource);
if ($commit) {
$this->objectManager->flush();
}
}
/**
* {@inheritdoc}
*/
public function remove(ResourceInterface $resource, $commit = true)
{
$this->objectManager->remove($resource);
if ($commit) {
$this->objectManager->flush();
}
}
public function find($id)
{
return $this->objectRepository->find($id);
}
public function findOneBy(array $criteria)
{
return $this->objectRepository->findOneBy($criteria);
}
public function findAll()
{
return $this->objectRepository->findAll();
}
public function findBy(array $criteria)
{
return $this->objectRepository->findBy($criteria);
}
public function getObjectManager()
{
return $this->objectManager;
}
public function getObjectRepository()
{
return $this->objectRepository;
}
}

View file

@ -0,0 +1,25 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Component\Resource\Manager\Doctrine;
use Sylius\Component\Resource\Manager\ResourceManagerInterface;
/**
* Doctrine resource manager interface.
*
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
*/
interface DoctrineResourceManagerInterface extends ResourceManagerInterface
{
function getObjectManager();
function getObjectRepository();
}

View file

@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Component\Resource\Manager\Doctrine;
use Doctrine\ORM\EntityManager;
use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Pagerfanta;
use Sylius\Bundle\ResourceBundle\Manager\Doctrine\DoctrineResourceManager;
/**
* Doctrine ORM driver resource manager.
*
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
*/
class ResourceManager extends DoctrineResourceManager
{
public function createPaginator()
{
return new Pagerfanta(new DoctrineORMAdapter($this->objectRepository->createQueryBuilder('r')));
}
}

View file

@ -0,0 +1,39 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\ResourceBundle\Manager;
/**
* Default resource manager class.
*
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
*/
abstract class ResourceManager implements ResourceManagerInterface
{
protected $class;
public function __construct($class)
{
$this->class = $class;
}
public function create()
{
$class = $this->getClass();
return new $class;
}
public function getClass()
{
return $this->class;
}
}

View file

@ -0,0 +1,93 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\ResourceBundle\Manager;
use Sylius\Bundle\ResourceBundle\Model\ResourceInterface;
/**
* Resource manager interface.
*
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
*/
interface ResourceManagerInterface
{
/**
* Creates new resource object.
*
* @return ResourceInterface
*/
function create();
/**
* Creates a new Pagerfanta instance to paginate the resources.
*
* @return PagerfantaInterface
*/
function createPaginator();
/**
* Persist.
*
* @param ResourceInterface $resource
* @param Boolean $flush
*/
function persist(ResourceInterface $resource, $flush = true);
/**
* Removes resource.
*
* @param ResourceInterface $resource
* @param Boolean $flush
*/
function remove(ResourceInterface $resource, $flush = true);
/**
* Finds resource by id.
*
* @param mixed Identifier
*
* @return ResourceInterface
*/
function find($id);
/**
* Finds resource by criteria.
*
* @param array $criteria
*
* @return ResourceInterface
*/
function findOneBy(array $criteria);
/**
* Find all.
*
* @return Collection
*/
function findAll();
/**
* Finds resources by criteria.
*
* @param array $criteria
*
* @return array
*/
function findBy(array $criteria);
/**
* Get resource class name.
*
* @return string
*/
function getClass();
}

View file

@ -0,0 +1,27 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Component\Resource;
/**
* Base resource class.
*
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
*/
abstract class Resource implements ResourceInterface
{
protected $id;
public function getId()
{
return $this->id;
}
}

View file

@ -0,0 +1,27 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Component\Resource;
/**
* Resource interface.
*
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
*/
interface ResourceInterface
{
/**
* Get resource identifier.
*
* @return mixed
*/
function getId();
}

View file

@ -0,0 +1,97 @@
SyliusResourceBundle [![Build status...](https://secure.travis-ci.org/Sylius/SyliusResourceBundle.png)](http://travis-ci.org/Sylius/SyliusResourceBundle)
======================
Sylius resource bundle.
Sylius
------
**Sylius** is simple but **end-user and developer friendly** webshop engine built on top of Symfony2.
Please visit [Sylius.org](http://sylius.org) for more details.
Testing and build status
------------------------
This bundle uses [travis-ci.org](http://travis-ci.org/Sylius/SyliusResourceBundle) for CI.
[![Build status...](https://secure.travis-ci.org/Sylius/SyliusResourceBundle.png)](http://travis-ci.org/Sylius/SyliusResourceBundle)
Before running tests, load the dependencies using [Composer](http://packagist.org).
``` bash
$ wget http://getcomposer.org/composer.phar
$ php composer.phar install --dev
```
Now you can run the tests by simply using this command.
``` bash
$ phpunit
```
Code examples
-------------
If you want to see working implementation, try out the [Sylius sandbox application](http://github.com/Sylius/Sylius-Sandbox).
It's open sourced github project.
Documentation
-------------
Documentation is available on [readthedocs.org](http://sylius.readthedocs.org/en/latest/bundles/SyliusSalesBundle.html).
Contributing
------------
All informations about contributing to Sylius can be found on [this page](http://sylius.readthedocs.org/en/latest/contributing/index.html).
Mailing lists
-------------
### Users
If you are using this bundle and have any questions, feel free to ask on users mailing list.
[Mail](mailto:sylius@googlegroups.com) or [view it](http://groups.google.com/group/sylius).
### Developers
If you want to contribute, and develop this bundle, use the developers mailing list.
[Mail](mailto:sylius-dev@googlegroups.com) or [view it](http://groups.google.com/group/sylius-dev).
Sylius twitter account
----------------------
If you want to keep up with updates, [follow the official Sylius account on twitter](http://twitter.com/_Sylius)
or [follow me](http://twitter.com/pjedrzejewski).
Bug tracking
------------
This bundle uses [GitHub issues](https://github.com/Sylius/SyliusResourceBundle/issues).
If you have found bug, please create an issue.
Versioning
----------
Releases will be numbered with the format `major.minor.patch`.
And constructed with the following guidelines.
* Breaking backwards compatibility bumps the major.
* New additions without breaking backwards compatibility bumps the minor.
* Bug fixes and misc changes bump the patch.
For more information on SemVer, please visit [semver.org website](http://semver.org/).
This versioning method is same for all **Sylius** bundles and applications.
License
-------
License can be found [here](https://github.com/Sylius/SyliusResourceBundle/blob/master/Resources/meta/LICENSE).
Authors
-------
The bundle was originally created by [Paweł Jędrzejewski](http://pjedrzejewski.com).
See the list of [contributors](https://github.com/Sylius/SyliusResourceBundle/contributors).

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
This file is part of the Sylius package.
(c) Paweł Jędrzejewski
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
-->
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd"
>
<services>
<service id="sylius_addressing.controller.backend.address" class="%sylius_addressing.controller.backend.address.class%">
<call method="setContainer">
<argument type="service" id="service_container" />
</call>
</service>
</services>
</container>

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
This file is part of the Sylius package.
(c) Paweł Jędrzejewski
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
-->
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd"
>
<parameters>
<parameter key="sylius_addressing.manager.address.class">Sylius\Bundle\AddressingBundle\Entity\AddressManager</parameter>
<parameter key="sylius_addressing.sorter.address.class">Sylius\Bundle\AddressingBundle\Sorting\ORM\AddressSorter</parameter>
</parameters>
<services>
<!-- managers... -->
<service id="sylius_addressing.manager.address" class="%sylius_addressing.manager.address.class%">
<argument type="service" id="doctrine.orm.default_entity_manager" />
<argument>%sylius_addressing.model.address.class%</argument>
</service>
<!-- sorters... -->
<service id="sylius_addressing.sorter.address" class="%sylius_addressing.sorter.address.class%">
<call method="setContainer">
<argument type="service" id="service_container" />
</call>
</service>
</services>
</container>

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
This file is part of the Sylius package.
(c) Paweł Jędrzejewski
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
-->
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd"
>
<services>
<service id="sylius_addressing.form.type.address" class="%sylius_addressing.form.type.address.class%">
<argument>%sylius_addressing.model.address.class%</argument>
<tag name="form.type" alias="sylius_addressing_address" />
</service>
</services>
</container>

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is part of the Sylius package.
(c) Paweł Jędrzejewski
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
-->
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd"
>
<services>
<service id="sylius_addressing.manipulator.address" class="%sylius_addressing.manipulator.address.class%">
<argument type="service" id="sylius_addressing.manager.address" />
</service>
</services>
</container>

View file

@ -0,0 +1,19 @@
Copyright (c) 2011-2012 Paweł Jędrzejewski
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View file

@ -0,0 +1,29 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\ResourceBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
/**
* Resource bundle.
*
* @author Paweł Jędrzejewski <pjedrzejewski@sylius.pl>
*/
class SyliusResourceBundle extends Bundle
{
// Bundle driver list.
const DRIVER_DOCTRINE_ORM = 'doctrine/orm';
const DRIVER_DOCTRINE_MONGODB_ODM = 'doctrine/mongodb-odm';
const DRIVER_DOCTRINE_COUCHDB_ODM = 'doctrine/couchdb-odm';
const DRIVER_PROPEL = 'propel';
const DRIVER_PROPEL2 = 'propel2';
}

View file

@ -0,0 +1,16 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
if (!file_exists($file = __DIR__.'/../vendor/autoload.php')) {
die("Please install dev dependencies using Composer to run the test suite. \n");
} else {
require_once $file;
}

View file

@ -0,0 +1,16 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
if (file_exists($file = __DIR__.'/autoload.php')) {
require_once $file;
} elseif (file_exists($file = __DIR__.'/autoload.php.dist')) {
require_once $file;
}

View file

@ -0,0 +1,33 @@
{
"name": "sylius/resource-bundle",
"type": "symfony-bundle",
"description": "Resource component for Sylius.",
"keywords": ["resource", "storage", "persistence"],
"homepage": "http://sylius.org",
"license": "MIT",
"authors": [
{
"name": "Paweł Jędrzejewski",
"email": "pjedrzejewski@diweb.pl",
"homepage": "http://pjedrzejewski.com"
},
{
"name": "Community contributions",
"homepage": "https://github.com/Sylius/SyliusResourceBundle/contributors"
}
],
"require": {
"php": ">=5.3.2",
"symfony/framework": ">=2.1.*",
"stof/doctrine-extensions-bundle": "*",
"white-october/pagerfanta-bundle": "*"
},
"require-dev": {
"doctrine/orm": "*"
},
"autoload": {
"psr-0": { "Sylius\\Bundle\\ResourceBundle": "" }
},
"target-dir": "Sylius/Bundle/ResourceBundle"
}

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./Tests/bootstrap.php" colors="true">
<testsuites>
<testsuite name="SyliusResourceBundle test suite">
<directory suffix="Test.php">./Tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>