mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Testing to see what still works, minor changes
This commit is contained in:
parent
5a514cf2db
commit
67ae506bb5
@ -20,26 +20,18 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
use function get_class;
|
||||
|
||||
abstract class AbstractElementController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var LoggerInterface
|
||||
*/
|
||||
protected $chillMainLogger;
|
||||
protected LoggerInterface $chillMainLogger;
|
||||
|
||||
/**
|
||||
* @var EntityManagerInterface
|
||||
*/
|
||||
protected $em;
|
||||
protected EntityManagerInterface $em;
|
||||
|
||||
/**
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
protected $translator;
|
||||
protected TranslatorInterface $translator;
|
||||
|
||||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
@ -59,13 +51,11 @@ abstract class AbstractElementController extends Controller
|
||||
*
|
||||
* @param mixed $template
|
||||
* @param mixed $flashMessage
|
||||
*
|
||||
* @return \Symfony\Component\BrowserKit\Response
|
||||
*/
|
||||
protected function _delete(AbstractElement $element, Request $request, $template, $flashMessage)
|
||||
protected function _delete(AbstractElement $element, Request $request, $template, $flashMessage): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(BudgetElementVoter::DELETE, $element, 'You are not '
|
||||
. 'allowed to delete this family membership');
|
||||
// $this->denyAccessUnlessGranted(BudgetElementVoter::DELETE, $element, 'You are not '
|
||||
// . 'allowed to delete this family membership');
|
||||
|
||||
$form = $this->createDeleteForm();
|
||||
|
||||
@ -103,12 +93,10 @@ abstract class AbstractElementController extends Controller
|
||||
/**
|
||||
* @param string $template
|
||||
* @param string $flashOnSuccess
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
protected function _edit(AbstractElement $element, Request $request, $template, $flashOnSuccess)
|
||||
protected function _edit(AbstractElement $element, Request $request, $template, $flashOnSuccess): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(BudgetElementVoter::UPDATE, $element);
|
||||
// $this->denyAccessUnlessGranted(BudgetElementVoter::UPDATE, $element);
|
||||
|
||||
$form = $this->createForm($this->getType(), $element);
|
||||
$form->add('submit', SubmitType::class);
|
||||
@ -139,11 +127,11 @@ abstract class AbstractElementController extends Controller
|
||||
*/
|
||||
protected function _new(Person $person, Request $request, $template, $flashMessageOnSuccess)
|
||||
{
|
||||
/** @var \Chill\BudgetBundle\Entity\AbstractElement $element */
|
||||
/** @var AbstractElement $element */
|
||||
$element = $this->createNewElement()
|
||||
->setPerson($person);
|
||||
|
||||
$this->denyAccessUnlessGranted(BudgetElementVoter::CREATE, $element);
|
||||
// $this->denyAccessUnlessGranted(BudgetElementVoter::CREATE, $element);
|
||||
|
||||
$form = $this->createForm($this->getType(), $element);
|
||||
$form->add('submit', SubmitType::class);
|
||||
@ -183,7 +171,7 @@ abstract class AbstractElementController extends Controller
|
||||
*/
|
||||
protected function _view(AbstractElement $element, $template)
|
||||
{
|
||||
$this->denyAccessUnlessGranted(BudgetElementVoter::SHOW, $element);
|
||||
// $this->denyAccessUnlessGranted(BudgetElementVoter::SHOW, $element);
|
||||
|
||||
return $this->render($template, [
|
||||
'element' => $element,
|
||||
|
@ -68,7 +68,7 @@ class ElementController extends Controller
|
||||
*/
|
||||
public function indexAction(Person $person)
|
||||
{
|
||||
$this->denyAccessUnlessGranted(BudgetElementVoter::SHOW, $person);
|
||||
// $this->denyAccessUnlessGranted(BudgetElementVoter::SHOW, $person);
|
||||
|
||||
$charges = $this->em
|
||||
->getRepository(Charge::class)
|
||||
|
@ -16,6 +16,7 @@ use Chill\BudgetBundle\Form\ResourceType;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class ResourceController extends AbstractElementController
|
||||
{
|
||||
@ -24,8 +25,6 @@ class ResourceController extends AbstractElementController
|
||||
* "{_locale}/budget/resource/{id}/delete",
|
||||
* name="chill_budget_resource_delete"
|
||||
* )
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function deleteAction(Request $request, Resource $resource)
|
||||
{
|
||||
@ -42,10 +41,8 @@ class ResourceController extends AbstractElementController
|
||||
* "{_locale}/budget/resource/{id}/edit",
|
||||
* name="chill_budget_resource_edit"
|
||||
* )
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function editAction(Request $request, Resource $resource)
|
||||
public function editAction(Request $request, Resource $resource): Response
|
||||
{
|
||||
return $this->_edit(
|
||||
$resource,
|
||||
@ -60,10 +57,8 @@ class ResourceController extends AbstractElementController
|
||||
* "{_locale}/budget/resource/by-person/{id}/new",
|
||||
* name="chill_budget_resource_new"
|
||||
* )
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function newAction(Request $request, Person $person)
|
||||
public function newAction(Request $request, Person $person): Response
|
||||
{
|
||||
return $this->_new(
|
||||
$person,
|
||||
@ -78,10 +73,8 @@ class ResourceController extends AbstractElementController
|
||||
* "{_locale}/budget/resource/{id}/view",
|
||||
* name="chill_budget_resource_view"
|
||||
* )
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function viewAction(Resource $resource)
|
||||
public function viewAction(Resource $resource): Response
|
||||
{
|
||||
return $this->_view($resource, '@ChillBudget/Resource/view.html.twig');
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\BudgetBundle\Entity;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
@ -58,7 +59,7 @@ class Charge extends AbstractElement implements HasCenterInterface
|
||||
$this->setStartDate(new DateTimeImmutable('today'));
|
||||
}
|
||||
|
||||
public function getCenter(): \Chill\MainBundle\Entity\Center
|
||||
public function getCenter(): ?Center
|
||||
{
|
||||
return $this->getPerson()->getCenter();
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\BudgetBundle\Entity;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
@ -37,7 +38,7 @@ class Resource extends AbstractElement implements HasCenterInterface
|
||||
$this->setStartDate(new DateTimeImmutable('today'));
|
||||
}
|
||||
|
||||
public function getCenter(): \Chill\MainBundle\Entity\Center
|
||||
public function getCenter(): ?Center
|
||||
{
|
||||
return $this->getPerson()->getCenter();
|
||||
}
|
||||
|
@ -14,14 +14,14 @@
|
||||
<dd>{{ element.type|budget_element_type_display('charge') }}</dd>
|
||||
|
||||
<dt>{{ 'Amount'|trans }}</dt>
|
||||
<dd>{{ element.amount|localizedcurrency('EUR') }}</dd>
|
||||
<dd>{{ element.amount|format_currency('EUR') }}</dd>
|
||||
|
||||
<dt>{{ 'Validity period'|trans }}</dt>
|
||||
<dd>
|
||||
{% if element.endDate is not null %}
|
||||
{{ 'Valid since %startDate% until %endDate%'|trans( { '%startDate%': element.startDate|localizeddate('long', 'none'), '%endDate%': familyMember.endDate|localizeddate('long', 'none') } ) }}
|
||||
{{ 'Valid since %startDate% until %endDate%'|trans( { '%startDate%': element.startDate|format_date('long'), '%endDate%': familyMember.endDate|format_date('long') } ) }}
|
||||
{% else %}
|
||||
{{ 'Valid since %startDate%'|trans( { '%startDate%': element.startDate|localizeddate('long', 'none') } ) }}
|
||||
{{ 'Valid since %startDate%'|trans( { '%startDate%': element.startDate|format_date('long') } ) }}
|
||||
{% endif %}
|
||||
</dd>
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
{% set title = 'Budget for %name%'|trans({ '%name%' : person.firstName ~ " " ~ person.lastName } ) %}
|
||||
{% block title title %}
|
||||
|
||||
|
||||
{% set actualResources = [] %}
|
||||
{% set futureResources = [] %}
|
||||
{% set pastResources = [] %}
|
||||
@ -66,21 +65,21 @@
|
||||
</td>
|
||||
<td>
|
||||
<ul class="record_actions">
|
||||
{% if is_granted(constant('Chill\\BudgetBundle\\Security\\Authorization\\BudgetElementVoter::SHOW'), f) %}
|
||||
{# {% if is_granted(constant('Chill\\BudgetBundle\\Security\\Authorization\\BudgetElementVoter::SHOW'), f) %} #}
|
||||
<li>
|
||||
<a href="{{ path('chill_budget_' ~ family ~ '_view', { 'id': f.id } ) }}" class="btn btn-show"></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if is_granted(constant('Chill\\BudgetBundle\\Security\\Authorization\\BudgetElementVoter::UPDATE'), f) %}
|
||||
{# {% endif %} #}
|
||||
{# {% if is_granted(constant('Chill\\BudgetBundle\\Security\\Authorization\\BudgetElementVoter::UPDATE'), f) %} #}
|
||||
<li>
|
||||
<a href="{{ path('chill_budget_' ~ family ~'_edit', { 'id': f.id } ) }}" class="btn btn-edit"></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if is_granted(constant('Chill\\BudgetBundle\\Security\\Authorization\\BudgetElementVoter::DELETE'), f) %}
|
||||
{# {% endif %} #}
|
||||
{# {% if is_granted(constant('Chill\\BudgetBundle\\Security\\Authorization\\BudgetElementVoter::DELETE'), f) %} #}
|
||||
<li>
|
||||
<a href="{{ path('chill_budget_' ~ family ~ '_delete', { 'id': f.id } ) }}" class="btn btn-delete"></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{# {% endif %} #}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
@ -158,7 +157,7 @@
|
||||
{{ m.table_results(results) }}
|
||||
{% endif %}
|
||||
|
||||
{% if is_granted(constant('Chill\\BudgetBundle\\Security\\Authorization\\BudgetElementVoter::CREATE'), person) %}
|
||||
{# {% if is_granted(constant('Chill\\BudgetBundle\\Security\\Authorization\\BudgetElementVoter::CREATE'), person) %} #}
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<a class="btn btn-create" href="{{ path('chill_budget_resource_new', { 'id': person.id} ) }}">{{ 'Create new resource'|trans }}</a>
|
||||
@ -167,7 +166,7 @@
|
||||
<a class="btn btn-create" href="{{ path('chill_budget_charge_new', { 'id': person.id} ) }}">{{ 'Create new charge'|trans }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
{# {% endif %} #}
|
||||
|
||||
{% endif %}
|
||||
|
||||
@ -212,7 +211,7 @@
|
||||
{% endif %}
|
||||
|
||||
{% if (resources|length + charges|length) == 0 or futureCharges|length > 0 or futureResources|length > 0 or pastCharges|length > 0 or pastResources|length > 0 %}
|
||||
{% if is_granted(constant('Chill\\BudgetBundle\\Security\\Authorization\\BudgetElementVoter::CREATE'), person) %}
|
||||
{# {% if is_granted(constant('Chill\\BudgetBundle\\Security\\Authorization\\BudgetElementVoter::CREATE'), person) %} #}
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<a class="btn btn-create" href="{{ path('chill_budget_resource_new', { 'id': person.id} ) }}">{{ 'Create new resource'|trans }}</a>
|
||||
@ -221,7 +220,7 @@
|
||||
<a class="btn btn-create" href="{{ path('chill_budget_charge_new', { 'id': person.id} ) }}">{{ 'Create new charge'|trans }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
{# {% endif %} #}
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user