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/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'));
}
}