Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- declare(strict_types=1);
- namespace App\Import\Tab\Converter;
- use App\Entity\Dictionary\DocumentType;
- use App\Entity\Dictionary\TaskGroup;
- use App\Repository\Dictionary\TaskGroupRepository;
- use Doctrine\ORM\NonUniqueResultException;
- class TaskGroupConverter extends ObjectConverter implements ContextAwareInterface
- {
- use ContextTrait;
- private const COLUMN_CASE_TYPE = 'caseType';
- private const COLUMN_CONTRACT = 'coPartnership';
- private const COLUMN_UTILITY_TYPE = 'utilityType';
- /**
- * @param null|string $value
- *
- * @throws NonUniqueResultException
- * @throws \App\Exception\ConvertingFailedException
- *
- * @return null|object|TaskGroup
- */
- public function convert(?string $value)
- {
- if(
- $this->context[self::COLUMN_CASE_TYPE]->getName() === DocumentType::NAME_SWITCH_SELLER_INFORMATION ||
- $this->context[self::COLUMN_CASE_TYPE]->getName() === DocumentType::NAME_RELEASE
- ) {
- return parent::convert('IZZ');
- }
- if(
- $this->context[self::COLUMN_CASE_TYPE]->getName() === DocumentType::NAME_SWITCH_SELLER_INTERRUPT ||
- $this->context[self::COLUMN_CASE_TYPE]->getName() === DocumentType::NAME_INTERRUPT
- ) {
- return parent::convert('IoW');
- }
- /** @var TaskGroupRepository $repo */
- $repo = $this->registry
- ->getManagerForClass(TaskGroup::class)
- ->getRepository(TaskGroup::class);
- $taskGroup = $repo->findTaskGroup(
- $this->context[self::COLUMN_CONTRACT],
- $this->context[self::COLUMN_CASE_TYPE],
- $this->context[self::COLUMN_UTILITY_TYPE]
- );
- if ($taskGroup) {
- return $taskGroup;
- }
- return parent::convert('INNE');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement