2010-06-24 09:40:05 +01:00
|
|
|
<?php
|
|
|
|
|
2012-04-02 04:52:14 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2012-03-28 14:43:52 +01:00
|
|
|
namespace Symfony\Component\Validator\Tests\Fixtures;
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2011-05-01 13:50:28 +01:00
|
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
2013-09-26 10:03:13 +01:00
|
|
|
use Symfony\Component\Validator\ExecutionContextInterface;
|
2011-05-01 13:50:28 +01:00
|
|
|
|
2010-06-24 09:40:05 +01:00
|
|
|
/**
|
2012-03-28 14:43:52 +01:00
|
|
|
* @Symfony\Component\Validator\Tests\Fixtures\ConstraintA
|
2011-05-01 13:50:28 +01:00
|
|
|
* @Assert\GroupSequence({"Foo", "Entity"})
|
2013-09-26 10:03:13 +01:00
|
|
|
* @Assert\Callback({"Symfony\Component\Validator\Tests\Fixtures\CallbackClass", "callback"})
|
2010-06-24 09:40:05 +01:00
|
|
|
*/
|
|
|
|
class Entity extends EntityParent implements EntityInterface
|
|
|
|
{
|
2010-06-24 10:24:08 +01:00
|
|
|
/**
|
2011-05-01 13:50:28 +01:00
|
|
|
* @Assert\NotNull
|
2013-01-24 09:48:29 +00:00
|
|
|
* @Assert\Range(min=3)
|
|
|
|
* @Assert\All({@Assert\NotNull, @Assert\Range(min=3)}),
|
|
|
|
* @Assert\All(constraints={@Assert\NotNull, @Assert\Range(min=3)})
|
2011-05-01 13:50:28 +01:00
|
|
|
* @Assert\Collection(fields={
|
2013-01-24 09:48:29 +00:00
|
|
|
* "foo" = {@Assert\NotNull, @Assert\Range(min=3)},
|
|
|
|
* "bar" = @Assert\Range(min=5)
|
2011-01-19 14:30:43 +00:00
|
|
|
* })
|
2011-05-01 13:50:28 +01:00
|
|
|
* @Assert\Choice(choices={"A", "B"}, message="Must be one of %choices%")
|
2010-06-24 10:24:08 +01:00
|
|
|
*/
|
2014-02-12 11:38:50 +00:00
|
|
|
public $firstName;
|
2010-06-24 10:24:08 +01:00
|
|
|
protected $lastName;
|
2010-11-16 23:51:45 +00:00
|
|
|
public $reference;
|
2014-02-12 11:38:50 +00:00
|
|
|
public $reference2;
|
2010-06-24 10:24:08 +01:00
|
|
|
private $internal;
|
2013-03-05 15:41:51 +00:00
|
|
|
public $data = 'Overridden data';
|
2014-07-17 15:35:52 +01:00
|
|
|
public $initialized = false;
|
2010-06-24 10:24:08 +01:00
|
|
|
|
|
|
|
public function __construct($internal = null)
|
|
|
|
{
|
|
|
|
$this->internal = $internal;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getInternal()
|
|
|
|
{
|
2013-04-02 10:39:57 +01:00
|
|
|
return $this->internal.' from getter';
|
2010-06-24 10:24:08 +01:00
|
|
|
}
|
|
|
|
|
2014-02-12 11:38:50 +00:00
|
|
|
public function setLastName($lastName)
|
|
|
|
{
|
|
|
|
$this->lastName = $lastName;
|
|
|
|
}
|
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
/**
|
2011-05-01 13:50:28 +01:00
|
|
|
* @Assert\NotNull
|
2010-06-24 10:24:08 +01:00
|
|
|
*/
|
|
|
|
public function getLastName()
|
|
|
|
{
|
|
|
|
return $this->lastName;
|
|
|
|
}
|
2013-03-05 15:41:51 +00:00
|
|
|
|
2013-09-21 13:29:04 +01:00
|
|
|
/**
|
|
|
|
* @Assert\True
|
|
|
|
*/
|
|
|
|
public function isValid()
|
|
|
|
{
|
|
|
|
return 'valid';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Assert\True
|
|
|
|
*/
|
|
|
|
public function hasPermissions()
|
|
|
|
{
|
|
|
|
return 'permissions';
|
|
|
|
}
|
|
|
|
|
2013-03-05 15:41:51 +00:00
|
|
|
public function getData()
|
|
|
|
{
|
|
|
|
return 'Overridden data';
|
|
|
|
}
|
2013-09-26 10:03:13 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @Assert\Callback
|
|
|
|
*/
|
|
|
|
public function validateMe(ExecutionContextInterface $context)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Assert\Callback
|
|
|
|
*/
|
|
|
|
public static function validateMeStatic($object, ExecutionContextInterface $context)
|
|
|
|
{
|
|
|
|
}
|
2010-10-02 13:42:01 +01:00
|
|
|
}
|