post 1.3 fixes (#1106)
This commit is contained in:
@@ -73,11 +73,13 @@ class TimesheetFixtures extends Fixture implements DependentFixtureInterface
|
||||
// by using array_pop we make sure that at least one activity has NO entry!
|
||||
array_pop($activities);
|
||||
|
||||
$all = 0;
|
||||
|
||||
foreach ($allUser as $user) {
|
||||
// random amount of timesheet entries for every user
|
||||
$timesheetForUser = rand(self::MIN_TIMESHEETS_PER_USER, self::MAX_TIMESHEETS_PER_USER);
|
||||
for ($i = 1; $i <= $timesheetForUser; $i++) {
|
||||
if ($i > self::MAX_TIMESHEETS_TOTAL) {
|
||||
if ($all > self::MAX_TIMESHEETS_TOTAL) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -96,6 +98,8 @@ class TimesheetFixtures extends Fixture implements DependentFixtureInterface
|
||||
true
|
||||
);
|
||||
|
||||
$all++;
|
||||
|
||||
$manager->persist($entry);
|
||||
|
||||
if ($i % self::BATCH_SIZE == 0) {
|
||||
|
||||
@@ -133,4 +133,19 @@ interface MetaTableTypeInterface
|
||||
* @return MetaTableTypeInterface
|
||||
*/
|
||||
public function setConstraints(array $constraints): MetaTableTypeInterface;
|
||||
|
||||
/**
|
||||
* Returns the label shown to the end-user.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel(): ?string;
|
||||
|
||||
/**
|
||||
* Sets the label shown to the end-user.
|
||||
*
|
||||
* @param string $label
|
||||
* @return MetaTableTypeInterface
|
||||
*/
|
||||
public function setLabel(string $label): MetaTableTypeInterface;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Form\Type\YesNoType;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
@@ -49,6 +50,11 @@ trait MetaTableTypeTrait
|
||||
*/
|
||||
private $visible = false;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $label;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -66,7 +72,11 @@ trait MetaTableTypeTrait
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
if (null === $this->name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return strtolower($this->name);
|
||||
}
|
||||
|
||||
public function setName(string $name): MetaTableTypeInterface
|
||||
@@ -82,6 +92,7 @@ trait MetaTableTypeTrait
|
||||
public function getValue()
|
||||
{
|
||||
switch ($this->type) {
|
||||
case YesNoType::class:
|
||||
case CheckboxType::class:
|
||||
return (bool) $this->value;
|
||||
case IntegerType::class:
|
||||
@@ -176,4 +187,20 @@ trait MetaTableTypeTrait
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLabel(): ?string
|
||||
{
|
||||
if (null === $this->label) {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
public function setLabel(string $label): MetaTableTypeInterface
|
||||
{
|
||||
$this->label = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class EntityMetaDefinitionType extends AbstractType
|
||||
}
|
||||
|
||||
$event->getForm()->add('value', $definition->getType(), [
|
||||
'label' => $definition->getName(),
|
||||
'label' => $definition->getLabel(),
|
||||
'constraints' => $definition->getConstraints(),
|
||||
'required' => $definition->isRequired(),
|
||||
]);
|
||||
|
||||
24
src/Repository/Loader/DefaultLoader.php
Normal file
24
src/Repository/Loader/DefaultLoader.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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\Repository\Loader;
|
||||
|
||||
final class DefaultLoader implements LoaderInterface
|
||||
{
|
||||
/**
|
||||
* @param array $results
|
||||
*/
|
||||
public function loadResults(array $results): void
|
||||
{
|
||||
// nothing to do here, the results are already fully populated
|
||||
|
||||
// if your entities have lazy collections or other data that needs population,
|
||||
// consider to create a custom loader!
|
||||
}
|
||||
}
|
||||
62
src/Repository/Paginator/QueryBuilderPaginator.php
Normal file
62
src/Repository/Paginator/QueryBuilderPaginator.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?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\Repository\Paginator;
|
||||
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
|
||||
final class QueryBuilderPaginator implements PaginatorInterface
|
||||
{
|
||||
/**
|
||||
* @var QueryBuilder
|
||||
*/
|
||||
private $query;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $results = 0;
|
||||
|
||||
public function __construct(QueryBuilder $query, int $results)
|
||||
{
|
||||
$this->query = $query;
|
||||
$this->results = $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getNbResults()
|
||||
{
|
||||
return $this->results;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSlice($offset, $length)
|
||||
{
|
||||
$query = $this->query
|
||||
->getQuery()
|
||||
->setFirstResult($offset)
|
||||
->setMaxResults($length);
|
||||
|
||||
return $this->getResults($query);
|
||||
}
|
||||
|
||||
private function getResults(Query $query)
|
||||
{
|
||||
return $query->execute();
|
||||
}
|
||||
|
||||
public function getAll(): iterable
|
||||
{
|
||||
return $this->getResults($this->query->getQuery());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user