code-cleanup: removed unused classes, added role constants, phpcs fixes (#96)
This commit is contained in:
@@ -202,5 +202,4 @@ trait TimesheetControllerTrait
|
|||||||
* @return \Symfony\Component\Form\FormInterface
|
* @return \Symfony\Component\Form\FormInterface
|
||||||
*/
|
*/
|
||||||
abstract protected function getEditForm(Timesheet $entry, $page);
|
abstract protected function getEditForm(Timesheet $entry, $page);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai package.
|
||||||
|
*
|
||||||
|
* (c) Kevin Papst <kevin@kevinpapst.de>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace App\DependencyInjection;
|
namespace App\DependencyInjection;
|
||||||
|
|
||||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||||
@@ -8,7 +17,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
|||||||
/**
|
/**
|
||||||
* This is the class that validates and merges configuration from your app/config files
|
* This is the class that validates and merges configuration from your app/config files
|
||||||
*
|
*
|
||||||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
|
* @author Kevin Papst <kevin@kevinpapst.de>
|
||||||
*/
|
*/
|
||||||
class Configuration implements ConfigurationInterface
|
class Configuration implements ConfigurationInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Kimai package.
|
|
||||||
*
|
|
||||||
* (c) Kevin Papst <kevin@kevinpapst.de>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\DependencyInjection;
|
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
||||||
use Symfony\Component\DependencyInjection\Extension\Extension;
|
|
||||||
use \Doctrine\Common\ClassLoader;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Main extension class
|
|
||||||
*
|
|
||||||
* @author Kevin Papst <kevin@kevinpapst.de>
|
|
||||||
*/
|
|
||||||
class KimaiExtension extends Extension
|
|
||||||
{
|
|
||||||
|
|
||||||
public function load(array $configs, ContainerBuilder $container)
|
|
||||||
{
|
|
||||||
$rootDir = realpath($container->getParameter('kernel.root_dir'));
|
|
||||||
$extensionsDir = realpath($rootDir . '/../vendor/beberlei/DoctrineExtensions/src/');
|
|
||||||
|
|
||||||
$classLoader = new ClassLoader('DoctrineExtensions', $extensionsDir);
|
|
||||||
$classLoader->register();
|
|
||||||
|
|
||||||
$kimaiConfig = new Configuration();
|
|
||||||
$this->processConfiguration($kimaiConfig, $configs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Entity;
|
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration
|
|
||||||
*
|
|
||||||
* @ORM\Table(name="configuration")
|
|
||||||
* @ORM\Entity
|
|
||||||
*/
|
|
||||||
class Configuration
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*
|
|
||||||
* @ORM\Column(name="option", type="string", length=255)
|
|
||||||
* @ORM\Id
|
|
||||||
* @ORM\GeneratedValue(strategy="IDENTITY")
|
|
||||||
*/
|
|
||||||
private $option;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*
|
|
||||||
* @ORM\Column(name="value", type="string", length=255, nullable=false)
|
|
||||||
*/
|
|
||||||
private $value;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set value
|
|
||||||
*
|
|
||||||
* @param string $value
|
|
||||||
*
|
|
||||||
* @return Configuration
|
|
||||||
*/
|
|
||||||
public function setValue($value)
|
|
||||||
{
|
|
||||||
$this->value = $value;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get value
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getValue()
|
|
||||||
{
|
|
||||||
return $this->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get option
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getOption()
|
|
||||||
{
|
|
||||||
return $this->option;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -30,7 +30,12 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|||||||
class User implements UserInterface, AdvancedUserInterface
|
class User implements UserInterface, AdvancedUserInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
const DEFAULT_ROLE = 'ROLE_USER';
|
const ROLE_CUSTOMER = 'ROLE_CUSTOMER';
|
||||||
|
const ROLE_USER = 'ROLE_USER';
|
||||||
|
const ROLE_TEAMLEAD = 'ROLE_TEAMLEAD';
|
||||||
|
const ROLE_ADMIN = 'ROLE_ADMIN';
|
||||||
|
const ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN';
|
||||||
|
const DEFAULT_ROLE = self::ROLE_USER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
|
|||||||
@@ -45,12 +45,6 @@ class NavbarShowUserListener
|
|||||||
/* @var $myUser User */
|
/* @var $myUser User */
|
||||||
$myUser = $this->storage->getToken()->getUser();
|
$myUser = $this->storage->getToken()->getUser();
|
||||||
|
|
||||||
$titles = [];
|
|
||||||
$roles = $this->storage->getToken()->getRoles();
|
|
||||||
foreach ($roles as $role) {
|
|
||||||
$titles[] = ucfirst(strtolower(str_replace('ROLE_', '', $role->getRole())));
|
|
||||||
}
|
|
||||||
|
|
||||||
$user = new UserModel();
|
$user = new UserModel();
|
||||||
$user->setName($myUser->getAlias() ?: $myUser->getUsername())
|
$user->setName($myUser->getAlias() ?: $myUser->getUsername())
|
||||||
->setUsername($myUser->getUsername())
|
->setUsername($myUser->getUsername())
|
||||||
|
|||||||
@@ -36,5 +36,4 @@ class TimesheetAdminForm extends TimesheetEditForm
|
|||||||
])
|
])
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,10 @@ class CustomerRepository extends AbstractRepository
|
|||||||
{
|
{
|
||||||
$qb = $this->getEntityManager()->createQueryBuilder();
|
$qb = $this->getEntityManager()->createQueryBuilder();
|
||||||
|
|
||||||
$qb->select('COUNT(t.id) as recordAmount', 'SUM(t.duration) as recordDuration, COUNT(DISTINCT(a.id)) as activityAmount, COUNT(DISTINCT(p.id)) as projectAmount')
|
$qb->select('COUNT(t.id) as recordAmount')
|
||||||
|
->addSelect('SUM(t.duration) as recordDuration')
|
||||||
|
->addSelect('COUNT(DISTINCT(a.id)) as activityAmount')
|
||||||
|
->addSelect('COUNT(DISTINCT(p.id)) as projectAmount')
|
||||||
->from(Timesheet::class, 't')
|
->from(Timesheet::class, 't')
|
||||||
->join(Activity::class, 'a')
|
->join(Activity::class, 'a')
|
||||||
->join(Project::class, 'p')
|
->join(Project::class, 'p')
|
||||||
|
|||||||
@@ -62,7 +62,9 @@ class ProjectRepository extends AbstractRepository
|
|||||||
{
|
{
|
||||||
$qb = $this->getEntityManager()->createQueryBuilder();
|
$qb = $this->getEntityManager()->createQueryBuilder();
|
||||||
|
|
||||||
$qb->select('COUNT(t.id) as recordAmount', 'SUM(t.duration) as recordDuration, COUNT(DISTINCT(a.id)) as activityAmount')
|
$qb->select('COUNT(t.id) as recordAmount')
|
||||||
|
->addSelect('SUM(t.duration) as recordDuration')
|
||||||
|
->addSelect('COUNT(DISTINCT(a.id)) as activityAmount')
|
||||||
->from(Activity::class, 'a')
|
->from(Activity::class, 'a')
|
||||||
->join(Timesheet::class, 't')
|
->join(Timesheet::class, 't')
|
||||||
->where('a.project = :project')
|
->where('a.project = :project')
|
||||||
|
|||||||
@@ -67,5 +67,4 @@ class ActivityQuery extends VisibilityQuery
|
|||||||
$this->project = $project;
|
$this->project = $project;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,5 +168,4 @@ class BaseQuery
|
|||||||
$this->hiddenEntity = $hiddenEntity;
|
$this->hiddenEntity = $hiddenEntity;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Validator\Constraints;
|
namespace App\Validator\Constraints;
|
||||||
|
|
||||||
|
use App\Entity\User;
|
||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraint;
|
||||||
use Symfony\Component\Validator\ConstraintValidator;
|
use Symfony\Component\Validator\ConstraintValidator;
|
||||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||||
@@ -21,7 +22,16 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
|||||||
class RoleValidator extends ConstraintValidator
|
class RoleValidator extends ConstraintValidator
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $allowedRoles = ['ROLE_CUSTOMER', 'ROLE_USER', 'ROLE_TEAMLEAD', 'ROLE_ADMIN', 'ROLE_SUPER_ADMIN'];
|
/**
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $allowedRoles = [
|
||||||
|
User::ROLE_CUSTOMER,
|
||||||
|
User::ROLE_USER,
|
||||||
|
User::ROLE_TEAMLEAD,
|
||||||
|
User::ROLE_ADMIN,
|
||||||
|
User::ROLE_SUPER_ADMIN
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
|||||||
Reference in New Issue
Block a user