refactored search with free search term support (#1064)
This commit is contained in:
@@ -19,47 +19,53 @@ use Faker\Factory;
|
||||
/**
|
||||
* Defines the sample data to load in during controller tests.
|
||||
*/
|
||||
class ProjectFixtures extends Fixture
|
||||
final class ProjectFixtures extends Fixture
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $amount = 0;
|
||||
private $amount = 0;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $isVisible = null;
|
||||
|
||||
private $isVisible = null;
|
||||
/**
|
||||
* @return int
|
||||
* @var callable
|
||||
*/
|
||||
private $callback;
|
||||
|
||||
public function getAmount(): int
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $amount
|
||||
* @return ProjectFixtures
|
||||
*/
|
||||
public function setAmount(int $amount)
|
||||
public function setAmount(int $amount): ProjectFixtures
|
||||
{
|
||||
$this->amount = $amount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $visible
|
||||
* @return $this
|
||||
*/
|
||||
public function setIsVisible(bool $visible)
|
||||
public function setIsVisible(bool $visible): ProjectFixtures
|
||||
{
|
||||
$this->isVisible = $visible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will be called prior to persisting the object.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return ProjectFixtures
|
||||
*/
|
||||
public function setCallback(callable $callback): ProjectFixtures
|
||||
{
|
||||
$this->callback = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -73,8 +79,8 @@ class ProjectFixtures extends Fixture
|
||||
if (null !== $this->isVisible) {
|
||||
$visible = $this->isVisible;
|
||||
}
|
||||
$entity = new Project();
|
||||
$entity
|
||||
$project = new Project();
|
||||
$project
|
||||
->setName($faker->catchPhrase . ($visible ? '' : ' (x)'))
|
||||
->setBudget(rand(0, 10000))
|
||||
->setComment($faker->text)
|
||||
@@ -82,7 +88,10 @@ class ProjectFixtures extends Fixture
|
||||
->setVisible($visible)
|
||||
;
|
||||
|
||||
$manager->persist($entity);
|
||||
if (null !== $this->callback) {
|
||||
call_user_func($this->callback, $project);
|
||||
}
|
||||
$manager->persist($project);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
|
||||
Reference in New Issue
Block a user