Initial Contact bundle.

This commit is contained in:
michalmarcinkowski 2014-09-24 12:38:08 +02:00
parent 280551152c
commit 569f1b0be5
28 changed files with 983 additions and 37 deletions

View file

@ -28,6 +28,7 @@ suites:
CartBundle : { namespace: Sylius, spec_path: src/Sylius/Bundle/CartBundle }
CoreBundle : { namespace: Sylius, spec_path: src/Sylius/Bundle/CoreBundle }
CurrencyBundle : { namespace: Sylius, spec_path: src/Sylius/Bundle/CurrencyBundle }
ContactBundle : { namespace: Sylius, spec_path: src/Sylius/Bundle/ContactBundle }
FlowBundle : { namespace: Sylius, spec_path: src/Sylius/Bundle/FlowBundle }
InstallerBundle : { namespace: Sylius, spec_path: src/Sylius/Bundle/InstallerBundle }
InventoryBundle : { namespace: Sylius, spec_path: src/Sylius/Bundle/InventoryBundle }

View file

@ -0,0 +1,5 @@
vendor/
bin/
composer.phar
composer.lock

View file

@ -0,0 +1,13 @@
language: php
php:
- 5.3
- 5.4
- 5.5
before_script: composer install --prefer-source --no-interaction
script: bin/phpspec run -fpretty --verbose
notifications:
irc: "irc.freenode.org#sylius-dev"

View file

@ -0,0 +1,6 @@
CHANGELOG
=========
### v0.12.0
* Initial dev release.

View file

@ -0,0 +1,109 @@
<?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\ContactBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
/**
* This class contains the configuration information for the bundle.
*
* This information is solely responsible for how the different configuration
* sections are normalized, and merged.
*
* @author Michał Marcinkowski <michal.marcinkowski@lakion.com>
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('sylius_contact');
$rootNode
->children()
->scalarNode('driver')->isRequired()->cannotBeEmpty()->end()
->end()
;
$this->addValidationGroupsSection($rootNode);
$this->addClassesSection($rootNode);
return $treeBuilder;
}
/**
* Adds `validation_groups` section.
*
* @param ArrayNodeDefinition $node
*/
private function addValidationGroupsSection(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('validation_groups')
->addDefaultsIfNotSet()
->children()
->arrayNode('contact_request')
->prototype('scalar')->end()
->defaultValue(array('sylius'))
->end()
->arrayNode('contact_topic')
->prototype('scalar')->end()
->defaultValue(array('sylius'))
->end()
->end()
->end()
->end()
;
}
/**
* Adds `classes` section.
*
* @param ArrayNodeDefinition $node
*/
private function addClassesSection(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('classes')
->addDefaultsIfNotSet()
->children()
->arrayNode('contact_request')
->addDefaultsIfNotSet()
->children()
->scalarNode('model')->defaultValue('Sylius\Component\Contact\Model\ContactRequest')->end()
->scalarNode('controller')->defaultValue('Sylius\Bundle\ResourceBundle\Controller\ResourceController')->end()
->scalarNode('repository')->end()
->scalarNode('form')->defaultValue('Sylius\Bundle\ContactBundle\Form\Type\ContactRequestType')->end()
->end()
->end()
->arrayNode('contact_topic')
->addDefaultsIfNotSet()
->children()
->scalarNode('model')->defaultValue('Sylius\Component\Contact\Model\ContactTopic')->end()
->scalarNode('controller')->defaultValue('Sylius\Bundle\ResourceBundle\Controller\ResourceController')->end()
->scalarNode('repository')->end()
->scalarNode('form')->defaultValue('Sylius\Bundle\ContactBundle\Form\Type\ContactTopicType')->end()
->end()
->end()
->end()
->end()
->end()
;
}
}

View file

@ -0,0 +1,40 @@
<?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\ContactBundle\DependencyInjection;
use Sylius\Bundle\ResourceBundle\DependencyInjection\AbstractResourceExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* Contact extension.
*
* @author Michał Marcinkowski <michal.marcinkowski@lakion.com>
*/
class SyliusContactExtension extends AbstractResourceExtension
{
protected $configFiles = array(
'services',
);
/**
* {@inheritdoc}
*/
public function load(array $config, ContainerBuilder $container)
{
$this->configure(
$config,
new Configuration(),
$container,
self::CONFIGURE_LOADER | self::CONFIGURE_DATABASE | self::CONFIGURE_PARAMETERS | self::CONFIGURE_VALIDATORS
);
}
}

View file

@ -0,0 +1,56 @@
<?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\ContactBundle\Form\Type;
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
use Symfony\Component\Form\FormBuilderInterface;
/**
* Sylius contact request form type.
*
* @author Michał Marcinkowski <michal.marcinkowski@lakion.com>
*/
class ContactRequestType extends AbstractResourceType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('firstName', 'text', array(
'label' => 'sylius.form.contact_request.first_name'
))
->add('lastName', 'text', array(
'label' => 'sylius.form.contact_request.last_name'
))
->add('email', 'email', array(
'label' => 'sylius.form.contact_request.email'
))
->add('message', 'textarea', array(
'label' => 'sylius.form.contact_request.message'
))
->add('topic', 'sylius_contact_topic_choice', array(
'label' => 'sylius.form.contact_request.topic',
'required' => false,
))
;
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'sylius_contact_request';
}
}

View file

@ -0,0 +1,60 @@
<?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\ContactBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
/**
* Base contact topic choice type.
*
* @author Michał Marcinkowski <michal.marcinkowski@lakion.com>
*/
abstract class ContactTopicChoiceType extends AbstractType
{
/**
* Shipping category class name.
*
* @var string
*/
protected $className;
/**
* Constructor.
*
* @param string $className
*/
public function __construct($className)
{
$this->className = $className;
}
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver
->setDefaults(array(
'class' => $this->className
))
;
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'sylius_contact_topic_choice';
}
}

View file

@ -0,0 +1,28 @@
<?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\ContactBundle\Form\Type;
/**
* Contact topic choice type for "doctrine/orm" driver.
*
* @author Michał Marcinkowski <michal.marcinkowski@lakion.com>
*/
class ContactTopicEntityType extends ContactTopicChoiceType
{
/**
* {@inheritdoc}
*/
public function getParent()
{
return 'entity';
}
}

View file

@ -0,0 +1,43 @@
<?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\ContactBundle\Form\Type;
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
use Symfony\Component\Form\FormBuilderInterface;
/**
* Sylius contact topic form type.
*
* @author Michał Marcinkowski <michal.marcinkowski@lakion.com>
*/
class ContactTopicType extends AbstractResourceType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title', 'text', array(
'label' => 'sylius.form.contact_topic.title'
))
;
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'sylius_contact_topic';
}
}

View file

@ -0,0 +1,75 @@
SyliusContactBundle [![Build status...](https://secure.travis-ci.org/Sylius/SyliusContactBundle.png?branch=master)](http://travis-ci.org/Sylius/SyliusContactBundle)
====================
[**Symfony2**](http://symfony.com) integration of Sylius Contact processing
component.
Sylius
------
**Sylius** - Modern ecommerce for Symfony2. Visit [Sylius.org](http://sylius.org).
[phpspec](http://phpspec.net) examples
--------------------------------------
```bash
$ composer install
$ bin/phpspec run -f pretty
```
Documentation
-------------
Documentation is available on [**docs.sylius.org**](http://sylius.org/en/latest/bundles/SyliusContactBundle/index.html).
Contributing
------------
All informations about contributing to Sylius can be found on [this page](http://docs.sylius.org/en/latest/contributing/index.html).
Mailing lists
-------------
### Users
Questions? Feel free to ask on [users mailing list](http://groups.google.com/group/sylius).
### Developers
To contribute and develop this bundle, use the [developers mailing list](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).
Bug tracking
------------
This bundle uses [GitHub issues](https://github.com/Sylius/Sylius/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.
MIT License
-----------
License can be found [here](https://github.com/Sylius/SyliusContactBundle/blob/master/Contacts/meta/LICENSE).
Authors
-------
The bundle was originally created by [Paweł Jędrzejewski](http://pjedrzejewski.com).
See the list of [contributors](https://github.com/Sylius/SyliusContactBundle/contributors).

View file

@ -0,0 +1,42 @@
<?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.
-->
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<mapped-superclass name="Sylius\Component\Contact\Model\ContactRequest" table="sylius_contact_request">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
<field name="firstName" column="first_name" type="string" />
<field name="lastName" column="last_name" type="string" />
<field name="email" column="email" type="string" />
<field name="message" column="message" type="text" />
<many-to-one field="topic" target-entity="Sylius\Component\Contact\Model\ContactTopicInterface">
<join-column name="topic_id" referenced-column-name="id" />
</many-to-one>
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>
</mapped-superclass>
</doctrine-mapping>

View file

@ -0,0 +1,27 @@
<?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.
-->
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<mapped-superclass name="Sylius\Component\Contact\Model\ContactTopic" table="sylius_contact_topic">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
<field name="title" column="title" type="string" />
</mapped-superclass>
</doctrine-mapping>

View file

@ -0,0 +1,23 @@
<?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.form.type.contact_topic_choice.class">Sylius\Bundle\ContactBundle\Form\Type\ContactTopicEntityType</parameter>
</parameters>
</container>

View file

@ -0,0 +1,36 @@
<?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.form.type.contact_request" class="%sylius.form.type.contact_request.class%">
<argument>%sylius.model.contact_request.class%</argument>
<argument>%sylius.validation_group.contact_request%</argument>
<tag name="form.type" alias="sylius_contact_request" />
</service>
<service id="sylius.form.type.contact_topic" class="%sylius.form.type.contact_topic.class%">
<argument>%sylius.model.contact_topic.class%</argument>
<argument>%sylius.validation_group.contact_topic%</argument>
<tag name="form.type" alias="sylius_contact_topic" />
</service>
<service id="sylius.form.type.contact_topic_choice" class="%sylius.form.type.contact_topic_choice.class%">
<argument>%sylius.model.contact_topic.class%</argument>
<tag name="form.type" alias="sylius_contact_topic_choice" />
</service>
</services>
</container>

View file

@ -0,0 +1,80 @@
<?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.
-->
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping
http://symfony.com/schema/dic/services/constraint-mapping-1.0.xsd">
<class name="Sylius\Component\Contact\Model\ContactRequest">
<property name="firstName">
<constraint name="NotBlank">
<option name="message">sylius.contact_request.first_name.not_blank</option>
<option name="groups">sylius</option>
</constraint>
<constraint name="Length">
<option name="min">2</option>
<option name="max">255</option>
<option name="minMessage">sylius.contact_request.first_name.min_length</option>
<option name="maxMessage">sylius.contact_request.first_name.max_length</option>
<option name="groups">sylius</option>
</constraint>
</property>
<property name="lastName">
<constraint name="NotBlank">
<option name="message">sylius.contact_request.last_name.not_blank</option>
<option name="groups">sylius</option>
</constraint>
<constraint name="Length">
<option name="min">2</option>
<option name="max">255</option>
<option name="minMessage">sylius.contact_request.last_name.min_length</option>
<option name="maxMessage">sylius.contact_request.last_name.max_length</option>
<option name="groups">sylius</option>
</constraint>
</property>
<property name="email">
<constraint name="NotBlank">
<option name="message">sylius.contact_request.email.not_blank</option>
<option name="groups">sylius</option>
</constraint>
<constraint name="Email">
<option name="message">sylius.contact_request.email.email</option>
<option name="groups">sylius</option>
</constraint>
</property>
<property name="message">
<constraint name="NotBlank">
<option name="message">sylius.contact_request.message.not_blank</option>
<option name="groups">sylius</option>
</constraint>
</property>
</class>
<class name="Sylius\Component\Contact\Model\ContactTopic">
<property name="title">
<constraint name="NotBlank">
<option name="message">sylius.contact_topic.title.not_blank</option>
<option name="groups">sylius</option>
</constraint>
<constraint name="Length">
<option name="min">2</option>
<option name="max">255</option>
<option name="minMessage">sylius.contact_topic.title.min_length</option>
<option name="maxMessage">sylius.contact_topic.title.max_length</option>
<option name="groups">sylius</option>
</constraint>
</property>
</class>
</constraint-mapping>

View file

@ -0,0 +1,19 @@
Copyright (c) 2011-2014 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,9 @@
sylius:
form:
contact_request:
first_name: First name
last_name: Last name
email: Email
message: Message
contact_topic:
title: Title

View file

@ -0,0 +1,10 @@
sylius:
contact_request:
first_name: First name
last_name: Last name
email: Email
message: Message
contact_topic:
title:
not_blank: Please choose currency code.
unique: Currency code must be unique.

View file

@ -0,0 +1,60 @@
<?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\ContactBundle;
use Sylius\Bundle\ResourceBundle\AbstractResourceBundle;
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
/**
* Contact bundle.
*
* @author Michał Marcinkowski <michal.marcinkowski@lakion.com>
*/
class SyliusContactBundle extends AbstractResourceBundle
{
/**
* {@inheritdoc}
*/
public static function getSupportedDrivers()
{
return array(
SyliusResourceBundle::DRIVER_DOCTRINE_ORM
);
}
/**
* {@inheritdoc}
*/
protected function getBundlePrefix()
{
return 'sylius_contact';
}
/**
* {@inheritdoc}
*/
protected function getModelInterfaces()
{
return array(
'Sylius\Component\Contact\Model\ContactRequestInterface' => 'sylius.model.contact_request.class',
'Sylius\Component\Contact\Model\ContactTopicInterface' => 'sylius.model.contact_topic.class',
);
}
/**
* {@inheritdoc}
*/
protected function getModelNamespace()
{
return 'Sylius\Component\Contact\Model';
}
}

View file

@ -0,0 +1,50 @@
{
"name": "sylius/contact-bundle",
"type": "symfony-bundle",
"description": "Contact form processing for Symfony2.",
"keywords": ["contact", "contact request", "support", "contact form"],
"homepage": "http://sylius.org",
"license": "MIT",
"authors": [
{
"name": "Paweł Jędrzejewski",
"homepage": "http://pjedrzejewski.com"
},
{
"name": "Michał Marcinkowski",
"homepage": "http://michalmarcinkowski.com"
},
{
"name": "Sylius project",
"homepage": "http://sylius.org"
},
{
"name": "Community contributions",
"homepage": "http://github.com/Sylius/Sylius/contributors"
}
],
"require": {
"php": ">=5.3.3",
"sylius/resource-bundle": "0.12.*@dev",
"symfony/framework-bundle": "~2.3"
},
"require-dev": {
"phpspec/phpspec": "~2.0",
"symfony/form": "~2.3"
},
"config": {
"bin-dir": "bin"
},
"autoload": {
"psr-4": { "Sylius\\Bundle\\ContactBundle\\": "" }
},
"autoload-dev": {
"psr-4": { "Sylius\\Bundle\\ContactBundle\\spec\\": "spec/" }
},
"extra": {
"branch-alias": {
"dev-master": "0.12-dev"
}
}
}

View file

@ -0,0 +1,85 @@
<?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 spec\Sylius\Bundle\ContactBundle\Form\Type;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
/**
* @author Michał Marcinkowski <michal.marcinkowski@lakion.com>
*/
class ContactRequestTypeSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('Contact', array('sylius'));
}
function it_is_initializable()
{
$this->shouldHaveType('Sylius\Bundle\ContactBundle\Form\Type\ContactRequestType');
}
function it_is_a_form_type()
{
$this->shouldImplement('Symfony\Component\Form\FormTypeInterface');
}
function it_should_build_form_with_proper_fields(FormBuilder $builder)
{
$builder
->add('firstName', 'text', Argument::any())
->willReturn($builder)
;
$builder
->add('lastName', 'text', Argument::any())
->willReturn($builder)
;
$builder
->add('email', 'email', Argument::any())
->willReturn($builder)
;
$builder
->add('message', 'textarea', Argument::any())
->willReturn($builder)
;
$builder
->add('topic', 'sylius_contact_topic_choice', Argument::any())
->willReturn($builder)
;
$this->buildForm($builder, array());
}
function it_should_define_assigned_data_class_and_validation_groups(OptionsResolverInterface $resolver)
{
$resolver
->setDefaults(array(
'data_class' => 'Contact',
'validation_groups' => array('sylius')
))
->shouldBeCalled();
$this->setDefaultOptions($resolver);
}
function it_has_valid_name()
{
$this->getName()->shouldReturn('sylius_contact_request');
}
}

View file

@ -0,0 +1,65 @@
<?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 spec\Sylius\Bundle\ContactBundle\Form\Type;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
/**
* @author Michał Marcinkowski <michal.marcinkowski@lakion.com>
*/
class ContactTopicTypeSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('Contact', array('sylius'));
}
function it_is_initializable()
{
$this->shouldHaveType('Sylius\Bundle\ContactBundle\Form\Type\ContactTopicType');
}
function it_is_a_form_type()
{
$this->shouldImplement('Symfony\Component\Form\FormTypeInterface');
}
function it_should_build_form_with_proper_fields(FormBuilder $builder)
{
$builder
->add('title', 'text', Argument::any())
->willReturn($builder)
;
$this->buildForm($builder, array());
}
function it_should_define_assigned_data_class_and_validation_groups(OptionsResolverInterface $resolver)
{
$resolver
->setDefaults(array(
'data_class' => 'Contact',
'validation_groups' => array('sylius')
))
->shouldBeCalled();
$this->setDefaultOptions($resolver);
}
function it_has_valid_name()
{
$this->getName()->shouldReturn('sylius_contact_topic');
}
}

View file

@ -30,6 +30,7 @@ class SyliusCoreExtension extends AbstractResourceExtension implements PrependEx
'sylius_addressing',
'sylius_inventory',
'sylius_currency',
'sylius_contact',
'sylius_locale',
'sylius_payment',
'sylius_payum',

View file

@ -38,6 +38,7 @@ abstract class Kernel extends BaseKernel
new \Sylius\Bundle\OrderBundle\SyliusOrderBundle(),
new \Sylius\Bundle\MoneyBundle\SyliusMoneyBundle(),
new \Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle(),
new \Sylius\Bundle\ContactBundle\SyliusContactBundle(),
new \Sylius\Bundle\LocaleBundle\SyliusLocaleBundle(),
new \Sylius\Bundle\SettingsBundle\SyliusSettingsBundle(),
new \Sylius\Bundle\CartBundle\SyliusCartBundle(),

View file

@ -32,6 +32,8 @@ sylius_locale: ~
sylius_currency: ~
sylius_contact: ~
sylius_api:
classes:
api_user:

View file

@ -71,42 +71,6 @@ class ContactRequest implements ContactRequestInterface
return $this->id;
}
/**
* {@inheritdoc}
*/
public function setTopic($topic)
{
$this->topic = $topic;
return $this;
}
/**
* {@inheritdoc}
*/
public function getTopic()
{
return $this->topic;
}
/**
* {@inheritdoc}
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* {@inheritdoc}
*/
public function getEmail()
{
return $this->email;
}
/**
* {@inheritdoc}
*/
@ -143,6 +107,24 @@ class ContactRequest implements ContactRequestInterface
return $this->lastName;
}
/**
* {@inheritdoc}
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* {@inheritdoc}
*/
public function getEmail()
{
return $this->email;
}
/**
* {@inheritdoc}
*/
@ -161,6 +143,24 @@ class ContactRequest implements ContactRequestInterface
return $this->message;
}
/**
* {@inheritdoc}
*/
public function setTopic(ContactTopicInterface $topic)
{
$this->topic = $topic;
return $this;
}
/**
* {@inheritdoc}
*/
public function getTopic()
{
return $this->topic;
}
/**
* {@inheritdoc}
*/

View file

@ -68,5 +68,5 @@ interface ContactRequestInterface extends TimestampableInterface
/**
* @param ContactTopicInterface $topic
*/
public function setTopic($topic);
public function setTopic(ContactTopicInterface $topic);
}