This commit is contained in:
Xes
2025-08-14 22:41:49 +02:00
parent 2de81ccc46
commit 8ce45119b6
39774 changed files with 4309466 additions and 0 deletions

5
vendor/sylius/attribute/.gitignore vendored Normal file
View File

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

15
vendor/sylius/attribute/.travis.yml vendored Normal file
View File

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

6
vendor/sylius/attribute/CHANGELOG.md vendored Normal file
View File

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

19
vendor/sylius/attribute/LICENSE vendored Normal file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2011-2015 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,203 @@
<?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\Attribute\Model;
use Sylius\Component\Translation\Model\AbstractTranslatable;
/**
* Model for object attributes.
*
* @author Paweł Jędrzejewski <pawel@sylius.org>
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
*/
class Attribute extends AbstractTranslatable implements AttributeInterface
{
/**
* Attribute id.
*
* @var mixed
*/
protected $id;
/**
* Type.
*
* @var string
*/
protected $type = AttributeTypes::TEXT;
/**
* Internal name.
*
* @var string
*/
protected $name;
/**
* Attribute configuration.
*
* @var array
*/
protected $configuration = array();
/**
* Creation time.
*
* @var \DateTime
*/
protected $createdAt;
/**
* Last update time.
*
* @var \DateTime
*/
protected $updatedAt;
public function __construct()
{
parent::__construct();
$this->createdAt = new \DateTime();
}
/**
* {@inheritdoc}
*/
public function __toString()
{
return $this->name;
}
/**
* {@inheritdoc}
*/
public function getId()
{
return $this->id;
}
/**
* {@inheritdoc}
*/
public function getName()
{
return $this->name;
}
/**
* {@inheritdoc}
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* {@inheritdoc}
*/
public function getPresentation()
{
return $this->translate()->getPresentation();
}
/**
* {@inheritdoc}
*/
public function setPresentation($presentation)
{
$this->translate()->setPresentation($presentation);
return $this;
}
/**
* {@inheritdoc}
*/
public function getType()
{
return $this->type;
}
/**
* {@inheritdoc}
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* {@inheritdoc}
*/
public function getConfiguration()
{
return $this->configuration;
}
/**
* {@inheritdoc}
*/
public function setConfiguration(array $configuration)
{
$this->configuration = $configuration;
return $this;
}
/**
* {@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;
}
/**
* {@inheritdoc}
*/
protected function getTranslationEntityClass()
{
return get_class().'Translation';
}
}

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 Sylius\Component\Attribute\Model;
use Sylius\Component\Resource\Model\TimestampableInterface;
/**
* Attribute interface.
*
* @author Paweł Jędrzejewski <pawel@sylius.org>
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
*/
interface AttributeInterface extends TimestampableInterface, AttributeTranslationInterface
{
/**
* Get internal name.
*
* @return string
*/
public function getName();
/**
* Set internal name.
*
* @param string $name
*/
public function setName($name);
/**
* The type of the attribute.
*
* @return string
*/
public function getType();
/**
* Set type of the attribute.
*
* @param string $type
*/
public function setType($type);
/**
* Get attribute configuration.
*
* @return array
*/
public function getConfiguration();
/**
* Set attribute configuration.
*
* @param array $configuration
*/
public function setConfiguration(array $configuration);
}

View File

@@ -0,0 +1,78 @@
<?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\Attribute\Model;
use Doctrine\Common\Collections\Collection;
/**
* Interface implemented by object which can be characterized
* using the attributes.
*
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
interface AttributeSubjectInterface
{
/**
* Returns all attributes of the subject.
*
* @return Collection|AttributeValueInterface[]
*/
public function getAttributes();
/**
* Sets all attributes of the subject.
*
* @param Collection $attributes Array of AttributeValueInterface
*/
public function setAttributes(Collection $attributes);
/**
* Adds an attribute to the subject.
*
* @param AttributeValueInterface $attribute
*/
public function addAttribute(AttributeValueInterface $attribute);
/**
* Removes an attribute from the subject.
*
* @param AttributeValueInterface $attribute
*/
public function removeAttribute(AttributeValueInterface $attribute);
/**
* Checks whether the subject has a given attribute.
*
* @param AttributeValueInterface $attribute
*
* @return Boolean
*/
public function hasAttribute(AttributeValueInterface $attribute);
/**
* Checks whether the subject has a given attribute, access by name.
*
* @param string $attributeName
*
* @return Boolean
*/
public function hasAttributeByName($attributeName);
/**
* Returns an attribute of the subject by its name.
*
* @param string $attributeName
*
* @return AttributeValueInterface
*/
public function getAttributeByName($attributeName);
}

View File

@@ -0,0 +1,63 @@
<?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\Attribute\Model;
use Sylius\Component\Translation\Model\AbstractTranslation;
/**
* Model for object attributes translation.
*
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
*/
class AttributeTranslation extends AbstractTranslation implements AttributeTranslationInterface
{
/**
* Attribute id.
*
* @var mixed
*/
protected $id;
/**
* Presentation.
* Displayed to user.
*
* @var string
*/
protected $presentation;
/**
* {@inheritdoc}
*/
public function getId()
{
return $this->id;
}
/**
* {@inheritdoc}
*/
public function getPresentation()
{
return $this->presentation;
}
/**
* {@inheritdoc}
*/
public function setPresentation($presentation)
{
$this->presentation = $presentation;
return $this;
}
}

View 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\Attribute\Model;
/**
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
*/
interface AttributeTranslationInterface
{
/**
* The name displayed to user.
*
* @return string
*/
public function getPresentation();
/**
* Set presentation.
*
* @param string $presentation
*/
public function setPresentation($presentation);
}

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\Component\Attribute\Model;
/**
* Default attribute types.
*
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
class AttributeTypes
{
const CHECKBOX = 'checkbox';
const CHOICE = 'choice';
const MONEY = 'money';
const NUMBER = 'number';
const PERCENTAGE = 'percent';
const TEXT = 'text';
public static function getChoices()
{
return array(
self::CHECKBOX => 'Checkbox',
self::CHOICE => 'Choice',
self::MONEY => 'Money',
self::NUMBER => 'Number',
self::PERCENTAGE => 'Percentage',
self::TEXT => 'Text',
);
}
}

View File

@@ -0,0 +1,172 @@
<?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\Attribute\Model;
/**
* Attribute to subject relation.
*
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
class AttributeValue implements AttributeValueInterface
{
/**
* Id.
*
* @var integer
*/
protected $id;
/**
* Subject.
*
* @var AttributeSubjectInterface
*/
protected $subject;
/**
* Attribute.
*
* @var AttributeInterface
*/
protected $attribute;
/**
* Attribute value.
*
* @var mixed
*/
protected $value;
/**
* {@inheritdoc}
*/
public function __toString()
{
return $this->value;
}
/**
* {@inheritdoc}
*/
public function getId()
{
return $this->id;
}
/**
* {@inheritdoc}
*/
public function getSubject()
{
return $this->subject;
}
/**
* {@inheritdoc}
*/
public function setSubject(AttributeSubjectInterface $subject = null)
{
$this->subject = $subject;
return $this;
}
/**
* {@inheritdoc}
*/
public function getAttribute()
{
return $this->attribute;
}
/**
* {@inheritdoc}
*/
public function setAttribute(AttributeInterface $attribute)
{
$this->attribute = $attribute;
return $this;
}
/**
* {@inheritdoc}
*/
public function getValue()
{
if ($this->attribute && AttributeTypes::CHECKBOX === $this->attribute->getType()) {
return (Boolean) $this->value;
}
return $this->value;
}
/**
* {@inheritdoc}
*/
public function setValue($value)
{
$this->value = $value;
return $this;
}
/**
* {@inheritdoc}
*/
public function getName()
{
$this->assertAttributeIsSet();
return $this->attribute->getName();
}
/**
* {@inheritdoc}
*/
public function getPresentation()
{
$this->assertAttributeIsSet();
return $this->attribute->getPresentation();
}
/**
* {@inheritdoc}
*/
public function getType()
{
$this->assertAttributeIsSet();
return $this->attribute->getType();
}
/**
* {@inheritdoc}
*/
public function getConfiguration()
{
$this->assertAttributeIsSet();
return $this->attribute->getConfiguration();
}
/**
* @throws \BadMethodCallException When attribute is not set
*/
protected function assertAttributeIsSet()
{
if (null === $this->attribute) {
throw new \BadMethodCallException('The attribute is undefined, so you cannot access proxy methods.');
}
}
}

View File

@@ -0,0 +1,92 @@
<?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\Attribute\Model;
/**
* Attribute value model.
*
* This model associates the attribute with its value on the object.
*
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
interface AttributeValueInterface
{
/**
* Get subject.
*
* @return AttributeSubjectInterface
*/
public function getSubject();
/**
* Set subject.
*
* @param AttributeSubjectInterface|null $subject
*/
public function setSubject(AttributeSubjectInterface $subject = null);
/**
* Get attribute.
*
* @return AttributeInterface
*/
public function getAttribute();
/**
* Set attribute.
*
* @param AttributeInterface $attribute
*/
public function setAttribute(AttributeInterface $attribute);
/**
* Get attribute value.
*
* @return mixed
*/
public function getValue();
/**
* Set attribute value.
*
* @param mixed $value
*/
public function setValue($value);
/**
* Proxy method to access the name from real attribute.
*
* @return string
*/
public function getName();
/**
* Proxy method to access the presentation from real attribute.
*
* @return string
*/
public function getPresentation();
/**
* The type of the attribute.
*
* @return string
*/
public function getType();
/**
* Get attribute configuration.
*
* @return array
*/
public function getConfiguration();
}

47
vendor/sylius/attribute/README.md vendored Normal file
View File

@@ -0,0 +1,47 @@
Attribute Component [![Build status...](https://secure.travis-ci.org/Sylius/Attribute.png?branch=master)](http://travis-ci.org/Sylius/Attribute)
===================
Attributes engine for PHP objects.
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/Attribute/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/Attribute/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/Attribute/contributors).

44
vendor/sylius/attribute/composer.json vendored Normal file
View File

@@ -0,0 +1,44 @@
{
"name": "sylius/attribute",
"type": "library",
"description": "Component for handling object attributes in PHP projects.",
"keywords": ["shop", "ecommerce", "attribute", "feature"],
"homepage": "http://sylius.org",
"license": "MIT",
"authors": [
{
"name": "Paweł Jędrzejewski",
"homepage": "http://pjedrzejewski.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.13.*@dev"
},
"require-dev": {
"phpspec/phpspec": "~2.1"
},
"config": {
"bin-dir": "bin"
},
"autoload": {
"psr-4": { "Sylius\\Component\\Attribute\\": "" }
},
"autoload-dev": {
"psr-4": { "Sylius\\Component\\Attribute\\spec\\": "spec/" }
},
"extra": {
"branch-alias": {
"dev-master": "0.13-dev"
}
}
}

5
vendor/sylius/attribute/phpspec.yml vendored Normal file
View File

@@ -0,0 +1,5 @@
suites:
main:
namespace: Sylius\Component\Attribute
psr4_prefix: Sylius\Component\Attribute
src_path: .

View File

@@ -0,0 +1,130 @@
<?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\Attribute\Model;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Attribute\Model\AttributeTypes;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
*/
class AttributeSpec extends ObjectBehavior
{
public function let()
{
$this->setCurrentLocale('en');
}
function it_is_initializable()
{
$this->shouldHaveType('Sylius\Component\Attribute\Model\Attribute');
}
function it_implements_Sylius_attribute_interface()
{
$this->shouldImplement('Sylius\Component\Attribute\Model\AttributeInterface');
}
function it_has_no_id_by_default()
{
$this->getId()->shouldReturn(null);
}
function it_has_no_name_by_default()
{
$this->getName()->shouldReturn(null);
}
function its_name_is_mutable()
{
$this->setName('T-Shirt collection');
$this->getName()->shouldReturn('T-Shirt collection');
}
function it_returns_name_when_converted_to_string()
{
$this->setName('T-Shirt material');
$this->__toString()->shouldReturn('T-Shirt material');
}
function it_has_no_presentation_by_default()
{
$this->getPresentation()->shouldReturn(null);
}
function its_presentation_is_mutable()
{
$this->setPresentation('Size');
$this->getPresentation()->shouldReturn('Size');
}
function it_has_text_type_by_default()
{
$this->getType()->shouldReturn(AttributeTypes::TEXT);
}
function its_type_is_mutable()
{
$this->setType(AttributeTypes::CHECKBOX);
$this->getType()->shouldReturn(AttributeTypes::CHECKBOX);
}
function it_initializes_empty_configuration_array_by_default()
{
$this->getConfiguration()->shouldReturn(array());
}
function its_configuration_is_mutable()
{
$this->setConfiguration(array('choices' => array('Red', 'Blue')));
$this->getConfiguration()->shouldReturn(array('choices' => array('Red', 'Blue')));
}
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);
}
function it_has_fluent_interface()
{
$date = new \DateTime();
$this->setName('T-Shirt brand')->shouldReturn($this);
$this->setPresentation('Brand')->shouldReturn($this);
$this->setType(AttributeTypes::CHOICE)->shouldReturn($this);
$this->setConfiguration(array())->shouldReturn($this);
$this->setCreatedAt($date)->shouldReturn($this);
$this->setUpdatedAt($date)->shouldReturn($this);
}
}

View File

@@ -0,0 +1,54 @@
<?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\Attribute\Model;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Attribute\Model\AttributeTypes;
/**
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
*/
class AttributeTranslationSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('Sylius\Component\Attribute\Model\AttributeTranslation');
}
function it_implements_Sylius_attribute_interface()
{
$this->shouldImplement('Sylius\Component\Attribute\Model\AttributeTranslationInterface');
}
function it_has_no_id_by_default()
{
$this->getId()->shouldReturn(null);
}
function it_has_no_presentation_by_default()
{
$this->getPresentation()->shouldReturn(null);
}
function its_presentation_is_mutable()
{
$this->setPresentation('Size');
$this->getPresentation()->shouldReturn('Size');
}
function it_has_fluent_interface()
{
$date = new \DateTime();
$this->setPresentation('Brand')->shouldReturn($this);
}
}

View File

@@ -0,0 +1,162 @@
<?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\Attribute\Model;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Attribute\Model\AttributeInterface;
use Sylius\Component\Attribute\Model\AttributeSubjectInterface;
use Sylius\Component\Attribute\Model\AttributeTypes;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
class AttributeValueSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('Sylius\Component\Attribute\Model\AttributeValue');
}
function it_implements_Sylius_subject_attribute_interface()
{
$this->shouldImplement('Sylius\Component\Attribute\Model\AttributeValueInterface');
}
function it_has_no_id_by_default()
{
$this->getId()->shouldReturn(null);
}
function it_does_not_belong_to_a_subject_by_default()
{
$this->getSubject()->shouldReturn(null);
}
function it_allows_assigning_itself_to_a_subject(AttributeSubjectInterface $subject)
{
$this->setSubject($subject);
$this->getSubject()->shouldReturn($subject);
}
function it_allows_detaching_itself_from_a_subject(AttributeSubjectInterface $subject)
{
$this->setSubject($subject);
$this->getSubject()->shouldReturn($subject);
$this->setSubject(null);
$this->getSubject()->shouldReturn(null);
}
function it_has_no_attribute_defined_by_default()
{
$this->getAttribute()->shouldReturn(null);
}
function its_attribute_is_definable(AttributeInterface $attribute)
{
$this->setAttribute($attribute);
$this->getAttribute()->shouldReturn($attribute);
}
function it_has_no_value_by_default()
{
$this->getValue()->shouldReturn(null);
}
function its_value_is_mutable()
{
$this->setValue('XXL');
$this->getValue()->shouldReturn('XXL');
}
function it_converts_value_to_Boolean_if_attribute_has_checkbox_type(AttributeInterface $attribute)
{
$attribute->getType()->willReturn(AttributeTypes::CHECKBOX);
$this->setAttribute($attribute);
$this->setValue('1');
$this->getValue()->shouldReturn(true);
$this->setValue(0);
$this->getValue()->shouldReturn(false);
}
function it_returns_its_value_when_converted_to_string()
{
$this->setValue('S');
$this->__toString()->shouldReturn('S');
}
function it_throws_exception_when_trying_to_get_name_without_attribute_defined()
{
$this
->shouldThrow('BadMethodCallException')
->duringGetName()
;
}
function it_returns_its_attribute_name(AttributeInterface $attribute)
{
$attribute->getName()->willReturn('T-Shirt material');
$this->setAttribute($attribute);
$this->getName()->shouldReturn('T-Shirt material');
}
function it_throws_exception_when_trying_to_get_presentation_without_attribute_defined()
{
$this
->shouldThrow('BadMethodCallException')
->duringGetPresentation()
;
}
function it_returns_its_attribute_presentation(AttributeInterface $attribute)
{
$attribute->getPresentation()->willReturn('Material');
$this->setAttribute($attribute);
$this->getPresentation()->shouldReturn('Material');
}
function it_throws_exception_when_trying_to_get_type_without_attribute_defined()
{
$this
->shouldThrow('BadMethodCallException')
->duringGetType()
;
}
function it_returns_its_attribute_type(AttributeInterface $attribute)
{
$attribute->getType()->willReturn('choice');
$this->setAttribute($attribute);
$this->getType()->shouldReturn('choice');
}
function it_throws_exception_when_trying_to_get_configuration_without_attribute_defined()
{
$this
->shouldThrow('BadMethodCallException')
->duringGetConfiguration()
;
}
function it_returns_its_attribute_configuration(AttributeInterface $attribute)
{
$attribute->getConfiguration()->willReturn(array('choices' => array('Red')));
$this->setAttribute($attribute);
$this->getConfiguration()->shouldReturn(array('choices' => array('Red')));
}
}

5
vendor/sylius/resource/.gitignore vendored Normal file
View File

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

14
vendor/sylius/resource/.travis.yml vendored Normal file
View File

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

View File

@@ -0,0 +1,57 @@
<?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\Event;
use Symfony\Component\EventDispatcher\Event;
/**
* Flash message event.
*
* @author Joseph Bielawski <stloyd@gmail.com>
*/
class FlashEvent extends Event
{
/**
* Flash message
*
* @var string
*/
protected $message;
/**
* @param null|string $message
*/
public function __construct($message = null)
{
$this->message = $message;
}
/**
* Get flash message.
*
* @return null|string
*/
public function getMessage()
{
return $this->message;
}
/**
* Set flash message.
*
* @param string $message
*/
public function setMessage($message)
{
$this->message = $message;
}
}

View File

@@ -0,0 +1,146 @@
<?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\Event;
use Symfony\Component\EventDispatcher\GenericEvent;
/**
* Resource event.
*
* @author Jérémy Leherpeur <jeremy@leherpeur.net>
*/
class ResourceEvent extends GenericEvent
{
const TYPE_ERROR = 'error';
const TYPE_WARNING = 'warning';
const TYPE_INFO = 'info';
const TYPE_SUCCESS = 'success';
/**
* Message type
*
* @var string
*/
protected $messageType = '';
/**
* Message
*
* @var string
*/
protected $message = '';
/**
* Message parameters
*
* @var array
*/
protected $messageParameters = array();
/**
* Stop event propagation
*
* @param string $message
* @param string $type
* @param array $parameters
*/
public function stop($message, $type = self::TYPE_ERROR, $parameters = array())
{
$this->messageType = $type;
$this->message = $message;
$this->messageParameters = $parameters;
$this->stopPropagation();
}
/**
* Alias
*
* @return bool
*/
public function isStopped()
{
return $this->isPropagationStopped();
}
/**
* Get messageType property
*
* @return string
*/
public function getMessageType()
{
return $this->messageType;
}
/**
* Sets messageType property
*
* @param string $messageType Should be one of ResourceEvent's TYPE constants
*
* @return $this
*/
public function setMessageType($messageType)
{
$this->messageType = $messageType;
return $this;
}
/**
* Get message property
*
* @return string
*/
public function getMessage()
{
return $this->message;
}
/**
* Sets message property
*
* @param string $message
*
* @return $this
*/
public function setMessage($message)
{
$this->message = $message;
return $this;
}
/**
* Get messageParameters property
*
* @return array
*/
public function getMessageParameters()
{
return $this->messageParameters;
}
/**
* Sets messageParameters property
*
* @param array $messageParameters
*
* @return $this
*/
public function setMessageParameters(array $messageParameters)
{
$this->messageParameters = $messageParameters;
return $this;
}
}

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\Exception\Driver;
/**
* @author Arnaud Langlade <aRn0D.dev@gmail.com>
*/
class InvalidDriverException extends \Exception
{
public function __construct($driver, $className)
{
parent::__construct(sprintf(
'Driver "%s" is not supported by %s.',
$driver,
$className
));
}
}

View File

@@ -0,0 +1,26 @@
<?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\Exception\Driver;
/**
* @author Arnaud Langlade <aRn0D.dev@gmail.com>
*/
class UnknownDriverException extends \Exception
{
public function __construct($driver)
{
parent::__construct(sprintf(
'Unknown driver "%s"',
$driver
));
}
}

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\Component\Resource\Exception;
class UnexpectedTypeException extends \InvalidArgumentException
{
/**
* @param mixed $value
* @param int $expectedType
*/
public function __construct($value, $expectedType)
{
parent::__construct(sprintf(
'Expected argument of type "%s", "%s" given.',
$expectedType,
is_object($value) ? get_class($value) : gettype($value)
));
}
}

19
vendor/sylius/resource/LICENSE vendored Normal file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2011-2015 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,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\Resource\Model;
/**
* @author Joseph Bielawski <stloyd@gmail.com>
*/
interface SlugAwareInterface
{
/**
* Get permalink/slug.
*
* @return string
*/
public function getSlug();
/**
* Set permalink/slug.
*
* @param string $slug
*/
public function setSlug($slug = null);
}

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\Component\Resource\Model;
/**
* @author Joseph Bielawski <stloyd@gmail.com>
*/
interface SoftDeletableInterface
{
/**
* Is item deleted?
*
* @return bool
*/
public function isDeleted();
/**
* Get the time of deletion.
*
* @return \DateTime
*/
public function getDeletedAt();
/**
* Set deletion time.
*
* @param \DateTime $deletedAt
*/
public function setDeletedAt(\DateTime $deletedAt);
}

View File

@@ -0,0 +1,46 @@
<?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\Model;
/**
* @author Joseph Bielawski <stloyd@gmail.com>
*/
interface TimestampableInterface
{
/**
* Get creation time.
*
* @return \DateTime
*/
public function getCreatedAt();
/**
* Get the time of last update.
*
* @return \DateTime
*/
public function getUpdatedAt();
/**
* Set creation time.
*
* @param \DateTime $createdAt
*/
public function setCreatedAt(\DateTime $createdAt);
/**
* Set the time of last update.
*
* @param \DateTime $updatedAt
*/
public function setUpdatedAt(\DateTime $updatedAt);
}

47
vendor/sylius/resource/README.md vendored Normal file
View File

@@ -0,0 +1,47 @@
Resource Component [![Build status...](https://secure.travis-ci.org/Sylius/Resource.png?branch=master)](http://travis-ci.org/Sylius/Resource)
==================
Resource management layer for Sylius and PHP apps.
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/Resource/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/Resource/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/Resource/contributors).

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\Component\Resource\Repository;
use Doctrine\Common\Persistence\ObjectRepository;
/**
* Model repository interface.
*
* @author Saša Stamenković <umpirsky@gmail.com>
*/
interface RepositoryInterface extends ObjectRepository
{
/**
* Create a new resource
*
* @return mixed
*/
public function createNew();
/**
* Get paginated collection
*
* @param array $criteria
* @param array $orderBy
*
* @return mixed
*/
public function createPaginator(array $criteria = null, array $orderBy = null);
}

View File

@@ -0,0 +1,52 @@
<?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\StateMachine;
use SM\StateMachine\StateMachine as BaseStateMachine;
/**
* Sylius State Machine
*
* @author Alexandre Bacco <alexandre.bacco@gmail.com>
*/
class StateMachine extends BaseStateMachine implements StateMachineInterface
{
/**
* @{inheritDoc}
*/
public function getTransitionFromState($fromState)
{
foreach ($this->getPossibleTransitions() as $transition) {
$config = $this->config['transitions'][$transition];
if (in_array($fromState, $config['from'])) {
return $transition;
}
}
return null;
}
/**
* @{inheritDoc}
*/
public function getTransitionToState($toState)
{
foreach ($this->getPossibleTransitions() as $transition) {
$config = $this->config['transitions'][$transition];
if ($toState === $config['to']) {
return $transition;
}
}
return null;
}
}

View File

@@ -0,0 +1,42 @@
<?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\StateMachine;
use SM\StateMachine\StateMachineInterface as BaseStateMachineInterface;
/**
* Sylius State Machine
*
* @author Alexandre Bacco <alexandre.bacco@gmail.com>
*/
interface StateMachineInterface extends BaseStateMachineInterface
{
/**
* Returns the possible transition from given state
* Returns null if no transition is possible
*
* @param string $fromState
*
* @return string|null
*/
public function getTransitionFromState($fromState);
/**
* Returns the possible transition to the given state
* Returns null if no transition is possible
*
* @param string $toState
*
* @return string|null
*/
public function getTransitionToState($toState);
}

47
vendor/sylius/resource/composer.json vendored Normal file
View File

@@ -0,0 +1,47 @@
{
"name": "sylius/resource",
"type": "library",
"description": "Basic resource interfaces for PHP applications.",
"keywords": ["shop", "ecommerce", "resource", "api", "sylius", "doctrine"],
"homepage": "http://sylius.org",
"license": "MIT",
"authors": [
{
"name": "Paweł Jędrzejewski",
"homepage": "http://pjedrzejewski.com"
},
{
"name": "Sylius project",
"homepage": "http://sylius.org"
},
{
"name": "Community contributions",
"homepage": "http://github.com/Sylius/Sylius/contributors"
}
],
"require": {
"php": ">=5.3.3",
"doctrine/collections": "~1.0",
"doctrine/common": "~2.3",
"winzou/state-machine": "~0.1",
"symfony/event-dispatcher": "~2.3"
},
"require-dev": {
"phpspec/phpspec": "~2.1"
},
"config": {
"bin-dir": "bin"
},
"autoload": {
"psr-4": { "Sylius\\Component\\Resource\\": "" }
},
"autoload-dev": {
"psr-4": { "Sylius\\Component\\Resource\\spec\\": "spec/" }
},
"extra": {
"branch-alias": {
"dev-master": "0.13-dev"
}
}
}

5
vendor/sylius/resource/phpspec.yml vendored Normal file
View File

@@ -0,0 +1,5 @@
suites:
main:
namespace: Sylius\Component\Resource
psr4_prefix: Sylius\Component\Resource
src_path: .

View File

@@ -0,0 +1,35 @@
<?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\Resource\Exception\Driver;
use PhpSpec\ObjectBehavior;
/**
* @author Arnaud Langlade <aRn0D.dev@gmail.com>
*/
class InvalidDriverExceptionSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('driver', 'className');
}
function it_is_initializable()
{
$this->shouldHaveType('Sylius\Component\Resource\Exception\Driver\InvalidDriverException');
}
function it_should_extends_exception()
{
$this->shouldHaveType('\Exception');
}
}

View File

@@ -0,0 +1,35 @@
<?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\Resource\Exception\Driver;
use PhpSpec\ObjectBehavior;
/**
* @author Arnaud Langlade <aRn0D.dev@gmail.com>
*/
class UnknownDriverExceptionSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('driver');
}
function it_is_initializable()
{
$this->shouldHaveType('Sylius\Component\Resource\Exception\Driver\UnknownDriverException');
}
function it_should_extends_exception()
{
$this->shouldHaveType('\Exception');
}
}

View File

@@ -0,0 +1,70 @@
<?php
namespace spec\Sylius\Component\Resource\Event;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Sylius\Component\Resource\Event\ResourceEvent;
class ResourceEventSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('message');
}
function it_is_initializable()
{
$this->shouldHaveType('Sylius\Component\Resource\Event\ResourceEvent');
}
function it_stops_event_propagation()
{
$this->stop('message', ResourceEvent::TYPE_SUCCESS, array('parameter'));
$this->getMessageType()->shouldReturn(ResourceEvent::TYPE_SUCCESS);
$this->getMessageParameters()->shouldReturn(array('parameter'));
$this->getMessage()->shouldReturn('message');
$this->isPropagationStopped()->shouldReturn(true);
}
function it_check_if_an_error_has_been_detected()
{
$this->isStopped()->shouldReturn(false);
$this->stop('message');
$this->isStopped()->shouldReturn(true);
}
function it_has_not_message_type_by_default()
{
$this->getMessageType()->shouldReturn('');
}
function its_message_type_is_mutable()
{
$this->setMessageType(ResourceEvent::TYPE_SUCCESS)->shouldReturn($this);
$this->getMessageType()->shouldReturn(ResourceEvent::TYPE_SUCCESS);
}
function it_has_not_message_by_default()
{
$this->getMessage()->shouldReturn('');
}
function its_message_is_mutable()
{
$this->setMessage('message')->shouldReturn($this);
$this->getMessage()->shouldReturn('message');
}
function it_has_not_message_parameter_by_default()
{
$this->getMessageParameters()->shouldReturn(array());
}
function its_message_parameter_is_mutable()
{
$this->setMessageParameters(array('parameters'))->shouldReturn($this);
$this->getMessageParameters()->shouldReturn(array('parameters'));
}
}

5
vendor/sylius/translation/.gitignore vendored Normal file
View File

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

19
vendor/sylius/translation/LICENSE vendored Normal file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2011-2015 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,206 @@
<?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\Translation\Model;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
*/
abstract class AbstractTranslatable implements TranslatableInterface
{
/**
* Translations
*
* @var TranslationInterface[]
*/
protected $translations;
/**
* Current locale
*
* @var string
*/
protected $currentLocale;
/**
* Cache current translation. Useful in Doctrine 2.4+
*
* @var string
*/
protected $currentTranslation;
/**
* Fallback locale
*
* @var string
*/
protected $fallbackLocale;
/**
* Constructor.
*/
public function __construct()
{
$this->translations = new ArrayCollection();
}
/**
* {@inheritdoc}
*/
public function getTranslations()
{
return $this->translations;
}
/**
* {@inheritdoc}
*/
public function addTranslation(TranslationInterface $translation)
{
if (!$this->translations->containsKey($translation->getLocale())) {
$this->translations->set($translation->getLocale(), $translation);
$translation->setTranslatable($this);
}
return $this;
}
/**
* {@inheritdoc}
*/
public function removeTranslation(TranslationInterface $translation)
{
if ($this->translations->removeElement($translation)) {
$translation->setTranslatable(null);
}
return $this;
}
/**
* @param TranslationInterface $translation
*
* @return bool
*/
public function hasTranslation(TranslationInterface $translation)
{
return $this->translations->containsKey($translation->getLocale());
}
/**
* @param string $currentLocale
*
* @return $this
*/
public function setCurrentLocale($currentLocale)
{
$this->currentLocale = $currentLocale;
return $this;
}
/**
* @return string
*/
public function getCurrentLocale()
{
return $this->currentLocale;
}
/**
* @param TranslationInterface $currentTranslation
*
* @return $this
*/
public function setCurrentTranslation(TranslationInterface $currentTranslation)
{
$this->currentTranslation = $currentTranslation;
return $this;
}
/**
* @return TranslationInterface
*/
public function getCurrentTranslation()
{
return $this->currentTranslation;
}
/**
* @param string $fallbackLocale
*
* @return $this
*/
public function setFallbackLocale($fallbackLocale)
{
$this->fallbackLocale = $fallbackLocale;
return $this;
}
/**
* @return string
*/
public function getFallbackLocale()
{
return $this->fallbackLocale;
}
/**
* Translation helper method
*
* @param string $locale
*
* @return TranslationInterface
*
* @throws \RuntimeException
*/
public function translate($locale = null)
{
if (null === $locale) {
$locale = $this->currentLocale;
}
if (!$locale) {
throw new \RuntimeException('No locale has been set and currentLocale is empty');
}
if ($this->currentTranslation && $this->currentTranslation->getLocale() === $locale) {
return $this->currentTranslation;
}
// TODO Throw exception? Get default translation?
if (!$translation = $this->translations->get($locale)) {
if (!$fallbackTranslation = $this->translations->get($this->getFallbackLocale())) {
$className = $this->getTranslationEntityClass();
$translation = new $className();
$translation->setLocale($locale);
$this->addTranslation($translation);
} else {
$translation = clone $fallbackTranslation;
}
}
$this->currentTranslation = $translation;
return $translation;
}
/**
* Return translation entity class
*
* @return string
*/
abstract protected function getTranslationEntityClass();
}

View File

@@ -0,0 +1,82 @@
<?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\Translation\Model;
/**
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
*/
class AbstractTranslation implements TranslationInterface
{
/**
* Locale
*
* @var string
*/
protected $locale;
/**
* Translatable object
*
* @var TranslatableInterface
*/
protected $translatable;
/**
* {@inheritdoc}
*/
public function getTranslatable()
{
return $this->translatable;
}
/**
* {@inheritdoc}
*/
public function setTranslatable(TranslatableInterface $translatable = null)
{
if ($translatable === $this->translatable) {
return $this;
}
$old = $this->translatable;
$this->translatable = $translatable;
if (null !== $old) {
$old->removeTranslation($this);
}
if (null !== $translatable) {
$translatable->addTranslation($this);
}
return $this;
}
/**
* {@inheritdoc}
*/
public function getLocale()
{
return $this->locale;
}
/**
* {@inheritdoc}
*/
public function setLocale($locale)
{
$this->locale = $locale;
return $this;
}
}

View File

@@ -0,0 +1,41 @@
<?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\Translation\Model;
/**
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
*/
interface TranslatableInterface
{
/**
* Get all translations
*
* @return TranslationInterface[]
*/
public function getTranslations();
/**
* Add a new translation
*
* @param TranslationInterface $translation
* @return self
*/
public function addTranslation(TranslationInterface $translation);
/**
* Remove a translation
*
* @param TranslationInterface $translation
* @return $this
*/
public function removeTranslation(TranslationInterface $translation);
}

View File

@@ -0,0 +1,48 @@
<?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\Translation\Model;
/**
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
*/
interface TranslationInterface
{
/**
* Get the translatable object
*
* @return TranslatableInterface
*/
public function getTranslatable();
/**
* Set the translatable object
*
* @param TranslatableInterface $translatable
* @return self
*/
public function setTranslatable(TranslatableInterface $translatable = null);
/**
* Get the locale
*
* @return string
*/
public function getLocale();
/**
* Set the locale
*
* @param string $locale
* @return $this
*/
public function setLocale($locale);
}

45
vendor/sylius/translation/README.md vendored Normal file
View File

@@ -0,0 +1,45 @@
Translation Component [![Build status...](https://secure.travis-ci.org/Sylius/Translation.png?branch=master)](http://travis-ci.org/Sylius/Translation)
===================
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/Translation/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/Translation/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/Translation/contributors).

45
vendor/sylius/translation/composer.json vendored Normal file
View File

@@ -0,0 +1,45 @@
{
"name": "sylius/translation",
"type": "library",
"description": "Translation helper.",
"keywords": ["translation"],
"homepage": "http://sylius.org",
"license": "MIT",
"authors": [
{
"name": "Paweł Jędrzejewski",
"homepage": "http://pjedrzejewski.com"
},
{
"name": "Sylius project",
"homepage": "http://sylius.org"
},
{
"name": "Community contributions",
"homepage": "http://github.com/Sylius/Sylius/contributors"
}
],
"require": {
"php": ">=5.3.3",
"doctrine/collections" : "~1.2",
"doctrine/orm" : "~2.4"
},
"require-dev": {
"phpspec/phpspec": "~2.0"
},
"config": {
"bin-dir": "bin"
},
"autoload": {
"psr-4": { "Sylius\\Component\\Translation\\": "" }
},
"autoload-dev": {
"psr-4": { "Sylius\\Component\\Translation\\spec\\": "spec/" }
},
"extra": {
"branch-alias": {
"dev-master": "0.13-dev"
}
}
}

5
vendor/sylius/translation/phpspec.yml vendored Normal file
View File

@@ -0,0 +1,5 @@
suites:
main:
namespace: Sylius\Component\Translation
psr4_prefix: Sylius\Component\Translation
src_path: .

View File

@@ -0,0 +1,108 @@
<?php
namespace spec\Sylius\Component\Translation\Model;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Translation\Model\TranslationInterface;
use Sylius\Component\Translation\Model\AbstractTranslatable;
use Sylius\Component\Translation\Model\AbstractTranslation;
class AbstractTranslatableSpec extends ObjectBehavior
{
function let()
{
$this->beAnInstanceOf('spec\Sylius\Component\Translation\Model\ConcreteTranslatable');
}
function it_is_translatable()
{
$this->shouldImplement('Sylius\Component\Translation\Model\TranslatableInterface');
}
function it_initializes_translattion_collection_by_default()
{
$this->getTranslations()->shouldHaveType('Doctrine\Common\Collections\Collection');
}
function it_adds_translation(TranslationInterface $translation)
{
$translation->getLocale()->willReturn('en');
$translation->setTranslatable($this)->shouldBeCalled();
$this->addTranslation($translation)->shouldReturn($this);
$this->hasTranslation($translation)->shouldReturn(true);
}
function it_removes_translation(TranslationInterface $translation)
{
$this->addTranslation($translation);
$this->removeTranslation($translation)->shouldReturn($this);
$this->hasTranslation($translation)->shouldReturn(false);
}
function its_current_locale_is_mutable()
{
$this->setCurrentLocale('en')->shouldReturn($this);
$this->getCurrentLocale()->shouldReturn('en');
}
function its_current_translation_is_mutable(TranslationInterface $translation)
{
$this->setCurrentTranslation($translation);
$this->getCurrentTranslation()->shouldReturn($translation);
}
function its_fallback_locale_is_mutable()
{
$this->setFallbackLocale('en');
$this->getFallbackLocale()->shouldReturn('en');
}
function it_throws_exception_if_no_locale_has_been_set()
{
$this->shouldThrow('\RuntimeException')->duringTranslate();
}
function it_translates_properly(TranslationInterface $translation)
{
$translation->getLocale()->willReturn('en');
$translation->setTranslatable($this)->shouldBeCalled();
$this->addTranslation($translation);
$this->setCurrentLocale('en');
$this->translate()->shouldReturn($translation);
}
function it_creates_new_empty_translation_properly()
{
$this->setCurrentLocale('en');
$this->translate()->shouldHaveType('spec\Sylius\Component\Translation\Model\ConcreteTranslatableTranslation');
}
function it_clones_new_translation_properly(TranslationInterface $translation)
{
$translation->getLocale()->willReturn('en');
$translation->setTranslatable($this)->shouldBeCalled();
$translation->acmeProperty = 'acmeProp';
$this->addTranslation($translation);
$this->setCurrentLocale('en');
$translation = $this->translate();
$translation->shouldImplement('Sylius\Component\Translation\Model\TranslationInterface');
$translation->acmeProperty->shouldBe('acmeProp');
}
}
class ConcreteTranslatable extends AbstractTranslatable
{
protected function getTranslationEntityClass(){
return 'spec\Sylius\Component\Translation\Model\ConcreteTranslatableTranslation';
}
}
class ConcreteTranslatableTranslation extends AbstractTranslation
{
}

View File

@@ -0,0 +1,49 @@
<?php
namespace spec\Sylius\Component\Translation\Model;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Sylius\Component\Translation\Model\TranslatableInterface;
use Sylius\Component\Translation\Model\AbstractTranslation;
class AbstractTranslationSpec extends ObjectBehavior
{
function let()
{
$this->beAnInstanceOf('spec\Sylius\Component\Translation\Model\ConcreteTranslation');
}
function it_is_a_translation()
{
$this->shouldImplement('Sylius\Component\Translation\Model\TranslationInterface');
}
function its_translatable_is_mutabale(TranslatableInterface $translatable)
{
$this->setTranslatable($translatable)->shouldReturn($this);
$this->getTranslatable()->shouldReturn($translatable);
}
function its_detaches_from_its_translatable_correctly(
TranslatableInterface $translatable1,
TranslatableInterface $translatable2
) {
$translatable1->addTranslation(Argument::type('Sylius\Component\Translation\Model\AbstractTranslation'));
$this->setTranslatable($translatable1);
$translatable1->removeTranslation(Argument::type('Sylius\Component\Translation\Model\AbstractTranslation'));
$translatable2->addTranslation(Argument::type('Sylius\Component\Translation\Model\AbstractTranslation'));
$this->setTranslatable($translatable2);
}
function its_locale_is_mutable()
{
$this->setLocale('en')->shouldReturn($this);
$this->getLocale()->shouldReturn('en');
}
}
class ConcreteTranslation extends AbstractTranslation
{
}