added tags for timesheets (#604)

This commit is contained in:
Mathias
2019-05-12 01:40:04 +02:00
committed by Kevin Papst
parent f31118292c
commit e29e183e84
84 changed files with 2132 additions and 158 deletions

View File

@@ -0,0 +1,68 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\DataFixtures;
use App\Entity\Tag;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
/**
* Defines the sample data to load in during controller tests.
*/
class TagFixtures extends Fixture
{
/**
* @var string[]
*/
protected $tagArray = [];
/**
* @return string[]
*/
public function getTagArray()
{
return $this->tagArray;
}
/**
* @param string[] $tagArray
* @return TagFixtures
*/
public function setTagArray(array $tagArray)
{
$this->tagArray = $tagArray;
return $this;
}
/**
* {@inheritdoc}
*/
public function load(ObjectManager $manager)
{
foreach ($this->getTagArray() as $tagName) {
$entry = $this->createTagEntry($tagName);
$manager->persist($entry);
}
$manager->flush();
}
/**
* @param $tagName
* @return Tag
*/
protected function createTagEntry($tagName)
{
$tagObject = new Tag();
$tagObject->setName($tagName);
return $tagObject;
}
}