Answer the question
In order to leave comments, you need to log in
"message": "Unable to get a property on a non-object."?
* @ParamConverter("importLegalEntity", converter="import_legal_entity")
* @Security("user.getId() === legalEntity.getOwnerIdValue()")
App\Infrastructure\Service\ParamConverter\ImportLegalEntityParamConverter:
arguments:
- '@infra.repo.import_legal_entity'
tags:
- { name: request.param_converter, converter: import_legal_entity }
infra.repo.import_legal_entity:
alias: 'App\Infrastructure\Repository\LegalEntityRepository'
public: true
<?php
namespace App\Infrastructure\Service\ParamConverter;
use App\Domain\Entity\LegalEntity;
use App\Domain\Repository\LegalEntityRepositoryInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
final class ImportLegalEntityParamConverter implements ParamConverterInterface
{
/**
* @var LegalEntityRepositoryInterface
*/
private $legalEntityRepository;
/**
* LegalEntityParamConverter constructor.
*
* @param LegalEntityRepositoryInterface $legalEntityRepository
*/
public function __construct(LegalEntityRepositoryInterface $legalEntityRepository)
{
$this->legalEntityRepository = $legalEntityRepository;
}
/**
* @param Request $request
* @param ParamConverter $configuration
*
* @return bool|void
*
* @throws NotFoundHttpException
*/
public function apply(Request $request, ParamConverter $configuration): bool
{
$legalEntity = null;
$legalEntityId = null;
if ($request->attributes->has('id')) {
$legalEntityId = (int) $request->attributes->get('id');
} elseif ($request->attributes->has('legalEntityId')) {
$legalEntityId = (int) $request->attributes->get('legalEntityId');
} elseif ($request->request->has('legalEntityId')) {
$legalEntityId = (int) $request->request->get('legalEntityId');
} elseif ($request->query->has('legalEntityId')) {
$legalEntityId = (int) $request->query->get('legalEntityId');
}
if (null !== $legalEntityId) {
$legalEntity = $this->legalEntityRepository->findById($legalEntityId);
if (null === $legalEntity) {
throw new NotFoundHttpException('generic.exception.legal_entity.not_exists');
}
}
$request->attributes->set($configuration->getName(), $legalEntity);
return true;
}
/**
* @param ParamConverter $configuration
*
* @return bool
*/
public function supports(ParamConverter $configuration)
{
return LegalEntity::class === $configuration->getClass();
}
}
* @ParamConverter("legalEntity", converter="legal_entity")
*
* @Security("(user.getGroupId() === legalEntity.getGroupIdValue() && legalEntity.isAlterable()) || user.getId() === legalEntity.getOwnerIdValue()")
* @Security("null !== user.getPrivilege()")
*
* @param Request $request
* @param LegalEntity $legalEntity
*
* @return JsonResponse
*
* @throws BirthdayInvalidException
* @throws CivilityInvalidException
* @throws DateInvalidException
* @throws EmailInvalidException
* @throws FeelingInvalidException
* @throws GeoPointInvalidException
* @throws LanguageInvalidException
* @throws ModelException
* @throws NotValidFormException
* @throws OpportunityInvalidException
* @throws PermissionInvalidException
* @throws PhoneNumberInvalidException
* @throws RoleInvalidException
* @throws SituationInvalidException
* @throws TypeInvalidException
* @throws UserTokenInvalidException
* @throws \App\Domain\Exception\Property\MainPictureInvalidException
*/
public function importLegalEntityCreateAction(Request $request, LegalEntity $legalEntity): JsonResponse
{
"message": "Unable to get a property on a non-object."
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question