mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
Initial Contact component.
This commit is contained in:
parent
62f7f60e20
commit
280551152c
13 changed files with 667 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ suites:
|
|||
Attribute : { namespace: Sylius, spec_path: src/Sylius/Component/Attribute }
|
||||
Cart : { namespace: Sylius, spec_path: src/Sylius/Component/Cart }
|
||||
Core : { namespace: Sylius, spec_path: src/Sylius/Component/Core }
|
||||
Contact : { namespace: Sylius, spec_path: src/Sylius/Component/Contact }
|
||||
Currency : { namespace: Sylius, spec_path: src/Sylius/Component/Currency }
|
||||
Installer : { namespace: Sylius, spec_path: src/Sylius/Component/Installer }
|
||||
Inventory : { namespace: Sylius, spec_path: src/Sylius/Component/Inventory }
|
||||
|
|
|
|||
5
src/Sylius/Component/Contact/.gitignore
vendored
Normal file
5
src/Sylius/Component/Contact/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
vendor/
|
||||
bin/
|
||||
|
||||
composer.phar
|
||||
composer.lock
|
||||
13
src/Sylius/Component/Contact/.travis.yml
Normal file
13
src/Sylius/Component/Contact/.travis.yml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
language: php
|
||||
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
|
||||
before_script: composer install --dev --prefer-source
|
||||
|
||||
script: bin/phpspec run -fpretty --verbose
|
||||
|
||||
notifications:
|
||||
irc: "irc.freenode.org#sylius-dev"
|
||||
6
src/Sylius/Component/Contact/CHANGELOG.md
Normal file
6
src/Sylius/Component/Contact/CHANGELOG.md
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
CHANGELOG
|
||||
=========
|
||||
|
||||
### v0.12.0
|
||||
|
||||
* Initial dev release.
|
||||
19
src/Sylius/Component/Contact/LICENCE
Normal file
19
src/Sylius/Component/Contact/LICENCE
Normal 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.
|
||||
199
src/Sylius/Component/Contact/Model/ContactRequest.php
Normal file
199
src/Sylius/Component/Contact/Model/ContactRequest.php
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
<?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\Contact\Model;
|
||||
|
||||
/**
|
||||
* Default contact request representation.
|
||||
*
|
||||
* @author Michał Marcinkowski <michal.marcinkowski@lakion.com>
|
||||
*/
|
||||
class ContactRequest implements ContactRequestInterface
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $firstName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $lastName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $email;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $message;
|
||||
|
||||
/**
|
||||
* @var ContactTopicInterface
|
||||
*/
|
||||
protected $topic;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $createdAt;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $updatedAt;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->createdAt = new \DateTime();
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
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}
|
||||
*/
|
||||
public function setFirstName($firstName)
|
||||
{
|
||||
$this->firstName = $firstName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFirstName()
|
||||
{
|
||||
return $this->firstName;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setLastName($lastName)
|
||||
{
|
||||
$this->lastName = $lastName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLastName()
|
||||
{
|
||||
return $this->lastName;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setMessage($message)
|
||||
{
|
||||
$this->message = $message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getMessage()
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setCreatedAt(\DateTime $createdAt)
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getUpdatedAt()
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUpdatedAt(\DateTime $updatedAt)
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
<?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\Contact\Model;
|
||||
|
||||
use Sylius\Component\Resource\Model\TimestampableInterface;
|
||||
|
||||
/**
|
||||
* Interface for the model representing a contact request.
|
||||
*
|
||||
* @author Michał Marcinkowski <michal.marcinkowski@lakion.com>
|
||||
*/
|
||||
interface ContactRequestInterface extends TimestampableInterface
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFirstName();
|
||||
|
||||
/**
|
||||
* @param string $firstName
|
||||
*/
|
||||
public function setFirstName($firstName);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLastName();
|
||||
|
||||
/**
|
||||
* @param string $lastName
|
||||
*/
|
||||
public function setLastName($lastName);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail();
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
*/
|
||||
public function setEmail($email);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage();
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
*/
|
||||
public function setMessage($message);
|
||||
|
||||
/**
|
||||
* @return ContactTopicInterface
|
||||
*/
|
||||
public function getTopic();
|
||||
|
||||
/**
|
||||
* @param ContactTopicInterface $topic
|
||||
*/
|
||||
public function setTopic($topic);
|
||||
}
|
||||
60
src/Sylius/Component/Contact/Model/ContactTopic.php
Normal file
60
src/Sylius/Component/Contact/Model/ContactTopic.php
Normal 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\Component\Contact\Model;
|
||||
|
||||
/**
|
||||
* Default contact topic representation
|
||||
*
|
||||
* @author Michał Marcinkowski <michal.marcinkowski@lakion.com>
|
||||
*/
|
||||
class ContactTopic implements ContactTopicInterface
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $title;
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
}
|
||||
32
src/Sylius/Component/Contact/Model/ContactTopicInterface.php
Normal file
32
src/Sylius/Component/Contact/Model/ContactTopicInterface.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?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\Contact\Model;
|
||||
|
||||
|
||||
/**
|
||||
* Interface for the model representing a contact topic.
|
||||
*
|
||||
* @author Michał Marcinkowski <michal.marcinkowski@lakion.com>
|
||||
*/
|
||||
interface ContactTopicInterface
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle();
|
||||
|
||||
/**
|
||||
* @param string $title
|
||||
*/
|
||||
public function setTitle($title);
|
||||
|
||||
}
|
||||
47
src/Sylius/Component/Contact/README.md
Normal file
47
src/Sylius/Component/Contact/README.md
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
Contact Component [](http://travis-ci.org/Sylius/Contact)
|
||||
===============
|
||||
|
||||
Contact request component for e-commerce applications.
|
||||
|
||||
Sylius
|
||||
------
|
||||
|
||||
Modern ecommerce for PHP and Symfony2. Visit [Sylius.org](http://sylius.org).
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
Documentation is available on [**docs.sylius.org**](http://docs.sylius.org/en/latest/components/Contact/index.html).
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
All instructions for contributing to Sylius can be found in the [Contributing Guide](http://docs.sylius.org/en/latest/contributing/index.html).
|
||||
|
||||
Support
|
||||
-------
|
||||
|
||||
If you have a question regarding the usage of this library, please ask on
|
||||
[Stackoverflow](http://stackoverflow.com). You should use "sylius"
|
||||
tag when posting and make sure to [browse existing questions](http://stackoverflow.com/questions/tagged/sylius).
|
||||
|
||||
Sylius on Twitter
|
||||
-----------------
|
||||
|
||||
[Follow the official Sylius account on Twitter!](http://twitter.com/Sylius).
|
||||
|
||||
Bug Tracking
|
||||
------------
|
||||
|
||||
If you find a bug, please refer to the [Reporting a Bug](http://docs.sylius.org/en/latest/contributing/code/bugs.html) guide.
|
||||
|
||||
MIT License
|
||||
-----------
|
||||
|
||||
License can be found [here](https://github.com/Sylius/Contact/blob/master/LICENSE).
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
The component was originally created by [Paweł Jędrzejewski](http://pjedrzejewski.com).
|
||||
See the list of [contributors](https://github.com/Sylius/Contact/contributors).
|
||||
48
src/Sylius/Component/Contact/composer.json
Normal file
48
src/Sylius/Component/Contact/composer.json
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
"name": "sylius/contact",
|
||||
"type": "library",
|
||||
"description": "Contact component for PHP applications.",
|
||||
"keywords": ["contact", "contact form", "support", "contact request"],
|
||||
"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": "0.12.*@dev"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpspec/phpspec": "~2.0"
|
||||
},
|
||||
"config": {
|
||||
"bin-dir": "bin"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Sylius\\Component\\Contact\\": "" }
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": { "Sylius\\Component\\Contact\\spec\\": "spec/" }
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "0.12-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
<?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\Component\Contact\Model;
|
||||
|
||||
use Sylius\Component\Contact\Model\ContactTopicInterface;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
|
||||
/**
|
||||
* @author Michał Marcinkowski <michal.marcinkowski@lakion.com>
|
||||
*/
|
||||
class ContactRequestSpec extends ObjectBehavior
|
||||
{
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Component\Contact\Model\ContactRequest');
|
||||
}
|
||||
|
||||
function it_implements_Sylius_contact_request_interface()
|
||||
{
|
||||
$this->shouldImplement('Sylius\Component\Contact\Model\ContactRequestInterface');
|
||||
}
|
||||
|
||||
function it_has_no_id_by_default()
|
||||
{
|
||||
$this->getId()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function it_has_no_first_name_by_default()
|
||||
{
|
||||
$this->getFirstName()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_first_name_is_mutable()
|
||||
{
|
||||
$this->setFirstName('Michal');
|
||||
$this->getFirstName()->shouldReturn('Michal');
|
||||
}
|
||||
|
||||
function it_has_no_last_name_by_default()
|
||||
{
|
||||
$this->getLastName()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_last_name_is_mutable()
|
||||
{
|
||||
$this->setLastName('lastname');
|
||||
$this->getLastName()->shouldReturn('lastname');
|
||||
}
|
||||
|
||||
function it_has_no_email_by_default()
|
||||
{
|
||||
$this->getEmail()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_email_is_mutable()
|
||||
{
|
||||
$this->setEmail('michal@lakion.com');
|
||||
$this->getEmail()->shouldReturn('michal@lakion.com');
|
||||
}
|
||||
|
||||
function it_has_no_message_by_default()
|
||||
{
|
||||
$this->getMessage()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_message_is_mutable()
|
||||
{
|
||||
$this->setMessage('hello');
|
||||
$this->getMessage()->shouldReturn('hello');
|
||||
}
|
||||
|
||||
function it_has_no_topic_by_default()
|
||||
{
|
||||
$this->getTopic()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_topic_is_mutable(ContactTopicInterface $topic)
|
||||
{
|
||||
$this->setTopic($topic);
|
||||
$this->getTopic()->shouldReturn($topic);
|
||||
}
|
||||
|
||||
function it_initializes_creation_date_by_default()
|
||||
{
|
||||
$this->getCreatedAt()->shouldHaveType('DateTime');
|
||||
}
|
||||
|
||||
function its_creation_date_is_mutable()
|
||||
{
|
||||
$date = new \DateTime();
|
||||
|
||||
$this->setCreatedAt($date);
|
||||
$this->getCreatedAt()->shouldReturn($date);
|
||||
}
|
||||
|
||||
function it_has_no_last_update_date_by_default()
|
||||
{
|
||||
$this->getUpdatedAt()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_last_update_date_is_mutable()
|
||||
{
|
||||
$date = new \DateTime();
|
||||
|
||||
$this->setUpdatedAt($date);
|
||||
$this->getUpdatedAt()->shouldReturn($date);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<?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\Component\Contact\Model;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
|
||||
/**
|
||||
* @author Michał Marcinkowski <michal.marcinkowski@lakion.com>
|
||||
*/
|
||||
class ContactTopicSpec extends ObjectBehavior
|
||||
{
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Component\Contact\Model\ContactTopic');
|
||||
}
|
||||
|
||||
function it_implements_Sylius_contact_topic_interface()
|
||||
{
|
||||
$this->shouldImplement('Sylius\Component\Contact\Model\ContactTopicInterface');
|
||||
}
|
||||
|
||||
function it_has_no_id_by_default()
|
||||
{
|
||||
$this->getId()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function it_has_no_title_by_default()
|
||||
{
|
||||
$this->getTitle()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_title_is_mutable()
|
||||
{
|
||||
$this->setTitle('Title');
|
||||
$this->getTitle()->shouldReturn('Title');
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue