@param FamilyInterface        $family
@param mixed                  $data
@param NameConverterInterface $nameConverter

@throws SerializerExceptionInterface

@return DataInterface|null
509661
public function getEntity(FamilyInterface $family, $data, NameConverterInterface $nameConverter = null)
    {
        /** @var DataRepository $repository */
        $entityManager = $this->doctrine->getManagerForClass($family->getDataClass());
        if (!$entityManager instanceof EntityManagerInterface) {
            throw new UnexpectedValueException("No manager found for class {$family->getDataClass()}");
        }
        $repository = $entityManager->getRepository($family->getDataClass());

        if ($family->isSingleton()) {
            try {
                return $repository->getInstance($family);
            } catch (\Exception $e) {
                throw new UnexpectedValueException("Unable to get singleton for family {$family->getCode()}", 0, $e);
            }
        }

        // In case we are trying to resolve a simple reference
        if (is_scalar($data)) {
            try {
                $entity = $repository->findByIdentifier($family, $data, true);
            } catch (\Exception $e) {
                throw new UnexpectedValueException(
                    "Unable to resolve id/identifier {$data} for family {$family->getCode()}",
                    0,
                    $e
                );
            }
            if (!$entity) {
                throw new UnexpectedValueException(
                    "No entity found for {$family->getCode()} with identifier '{$data}'"
                );
            }

            return $entity;
        }

        if (!\is_array($data) && !$data instanceof \ArrayAccess) {
            throw new UnexpectedValueException('Unable to denormalize data from unknown format');
        }

        // If the id is set (and not null), don't even look for the identifier
        if (isset($data['id'])) {
            /** @noinspection PhpIncompatibleReturnTypeInspection */

            return $repository->find($data['id']);
        }

        // Try to resolve the identifier
        $reference = $this->resolveIdentifier($data, $family, $nameConverter);

        if (null !== $reference) {
            try {
                $entity = $repository->findByIdentifier($family, $reference);
                if ($entity) {
                    return $entity;
                }
            } catch (NonUniqueResultException $e) {
                throw new UnexpectedValueException(
                    "Non unique result for identifier {$reference} for family {$family->getCode()}",
                    0,
                    $e
                );
            } catch (\Exception $e) {
                throw new UnexpectedValueException(
                    "Unable to resolve identifier {$reference} for family {$family->getCode()}",
                    0,
                    $e
                );
            }
        }

        // Maybe the entity already exists but is not yet persisted
        if (null !== $reference && $this->hasCreatedEntity($family, $reference)) {
            return $this->getCreatedEntity($family, $reference);
        }

        $entity = $family->createData();

        // If we can, store the created entity for later
        if (null !== $reference) {
            $this->addCreatedEntity($entity, $reference);
        }

        return $entity;
    }
563955
private function convertCompositeToPg($data, TypeInterface $type)
    {
        $mapping = $this->getMapping($type);

        if ($normalizer = $this->getNormalizer($type)) {
            $data = $normalizer->toPg($data, [
                'mapping' => $mapping,
            ]);
        }

        $fragments = [];

        foreach ($mapping as $field => $fieldType) {
            if (!isset($data[$field])) {
                $fragments[$field] = $fieldType instanceof ArrayType ? new Set([], $fieldType) : new Value('null');

                continue;
            }

            $fragments[$field] = $this->toPg($data[$field], $fieldType);
        }

        return new Row($fragments, $type);
    }
915506
protected function getQueryBuilderByFamily(Request $request, FamilyInterface $family)
    {
        $term = '%'.trim($request->get('term'), '%').'%';

        return $this->dataManager->getQbForFamiliesAndLabel([$family], $term);
    }
638968
protected function serialize(ResourceInterface $resource, $data)
    {
        // Get the serializer from the resource, or use the default.
        $serializer = $resource->getSerializer() ?? $this->getSerializer();
        
        if ($serializer instanceof SerializerInterface) {
            if ($resource instanceof Collection) {
                if ($data === null) {
                    return $serializer->nullCollection();
                }
                $data = $serializer->collection($resource->getResourceKey(), $data);
                if ($resource->hasPaginator()) {
                    $data = array_merge($data, $serializer->paginator($resource->getPaginator()));
                }
            } elseif ($resource instanceof Item) {
                if ($data === null) {
                    return $serializer->nullItem();
                }
                $data = $serializer->item($resource->getResourceKey(), $data);
            }
        } elseif (\is_callable($serializer)) {
            // Serialize via a callable/closure
            $data = $serializer($resource->getResourceKey(), $data);
        }
       
        return $data;
    }
1068458
public function getASynchronizer($family)
    {
        if(!array_key_exists($family, $this->synchronizersA))
        {
            throw new CoreException('Синхронизатор агрегатных(A) типов пакета '.$family.' не найдена в медиаторе!');
        }

        return $this->synchronizersA[$family];
    }
1338651
protected function copyFromFamily(FamilyInterface $parent)
    {
        foreach ($parent->getAttributes() as $attribute) {
            $this->addAttribute(clone $attribute);
        }
        if ($parent->getAttributeAsLabel()) {
            $this->attributeAsLabel = $this->getAttribute($parent->getAttributeAsLabel()->getCode());
        }
        if ($parent->getAttributeAsIdentifier()) {
            $this->attributeAsIdentifier = $this->getAttribute($parent->getAttributeAsIdentifier()->getCode());
        }
        $this->valueClass = $parent->getValueClass();
        $this->dataClass = $parent->getDataClass();
    }
478269
public function readAction(Request $request, DataInterface $data, FamilyInterface $family = null)
    {
        $this->initDataFamily($data, $family);
        $form = $this->getForm($request, $data, ['disabled' => true]);

        return $this->renderAction($this->getViewParameters($request, $form, $data));
    }
803122
private function convertToPg($data, TypeInterface $type)
    {
        if ($data === null) {
            return new Value('null');
        }

        if ($type instanceof ArrayType) {
            return $this->convertArrayToPg($data, $type);
        }

        if (isset($this->mappings[(string) $type])) {
            return $this->convertCompositeToPg($data, $type);
        }

        return $this->convertScalarToPg($data, $type);
    }
1156193
public function convertObjectParents(array $data = null)
    {
        return array_filter(
            array_map(
                [$this, 'convertObjectParentData'],
                (array) ($data ?? [])
            ),
            function ($item) {
                return !empty($item);
                // @TODO once a logger is available we should log an INFO message if the parent data could not be converted
            }
        );
    }
917402
public function exportAction(Request $request, FamilyInterface $family)
    {
        $this->setFamily($family);

        $exportConfig = $this->getExportConfig($request);
        $defaultFormOptions = $this->getDefaultFormOptions($request, 'export');
        $attr = $defaultFormOptions['attr'] ?? [];
        $attr['data-target-element'] = null; // Deep merge hell
        $form = $this->getForm(
            $request,
            $exportConfig,
            [
                'family' => $family,
                'attr' => $attr,
            ]
        );

        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            return $this->generateExport($form->getData());
        }

        return $this->renderAction($this->getViewParameters($request, $form));
    }
1358058
protected function getFamilyConfig($family)
    {
        if (!isset($this->config[$family])) {
            throw new \InvalidArgumentException(
                sprintf('Undefined measure family "%s"', $family)
            );
        }

        return $this->config[$family];
    }
595009
public function getFamilyLi(Family $family, Individual $person, $generations = 0): string
    {
        $spouse = $family->spouse($person);
        if ($spouse) {
            $spouse_name = $spouse->getSexImage() . $spouse->fullName();
            $spouse_link = '<a href="' . e($person->url()) . '" title="' . strip_tags($person->fullName()) . '">' . view('icons/individual') . '</a>';
        } else {
            $spouse_name = '';
            $spouse_link = '';
        }

        $family_link = '<a href="' . e($family->url()) . '" title="' . strip_tags($family->fullName()) . '">' . view('icons/family') . '</a>';

        $marryear = $family->getMarriageYear();
        $marr     = $marryear ? '<i class="icon-rings"></i>' . $marryear : '';

        return
            '<li class="sb_desc_indi_li">' .
            '<a class="sb_desc_indi" href="#"><i class="plusminus icon-minus"></i>' .
            $spouse_name .
            $marr .
            '</a>' .
            $spouse_link .
            $family_link .
            '<div>' . $this->loadChildren($family, $generations) . '</div>' .
            '</li>';
    }
1369367
private function descendantsFamilies(Tree $tree, Collection $families): ResponseInterface
    {
        $this->layout = 'layouts/ajax';

        return $this->viewResponse('lists/families-table', [
            'families' => $families,
            'tree'     => $tree,
        ]);
    }
1197225
protected function updateEntity($data)
    {
        if (!$data instanceof DataInterface) {
            return;
        }
        $family = $data->getFamily();

        if (!array_key_exists($data->getFamilyCode(), $this->familyMap)) {
            return;
        }
        $resource = $data->get($this->familyMap[$data->getFamilyCode()]);
        if (!$resource instanceof Document) {
            // Maybe we should reset the values to null
            return;
        }
        $data->setFileSize($resource->getFileSize());
        $this->valuesToPersist[] = $data->getValue($family->getAttribute('fileSize'));

        $data->setMimeType($resource->getMimeType());
        $this->valuesToPersist[] = $data->getValue($family->getAttribute('mimeType'));

        $data->setFileName($resource->getOriginalFileName());
        $this->valuesToPersist[] = $data->getValue($family->getAttribute('fileName'));
    }
196946
protected function convertObjectToSimpleType($data)
    {
        /** @var null|TypeConverterInterface $converterClassName */
        $converterClassName = null;
        if (class_exists($this->buildConverterClassName(get_class($data)))) {
            $converterClassName = $this->buildConverterClassName(get_class($data));
        } else {
            $classInterfaces = class_implements($data);
            foreach ((array) $classInterfaces as $classInterface) {
                if (class_exists($this->buildConverterClassName($classInterface))) {
                    $converterClassName = $this->buildConverterClassName($classInterface);
                    break;
                }
            }
            if ($converterClassName === null) {
                $classParents = class_parents($data);
                foreach ((array) $classParents as $classParent) {
                    if (class_exists($this->buildConverterClassName($classParent))) {
                        $converterClassName = $this->buildConverterClassName($classParent);
                        break;
                    }
                }
            }
        }

        if ($converterClassName === null) {
            throw new CmisRuntimeException(
                'Could not find a converter that converts "' . get_class($data) . '" to a simple type.'
            );
        }

        return $converterClassName::convertToSimpleType($data);
    }
620836
public function createFromImportedData($name, $data)
    {
        $class = new GroupClass($name);
        foreach ($data as $parameterName => $parameterData) {
            $class->addParameter($this->getGroupParameterFactory()->createFromImportedData($parameterName, $parameterData));
        }
        return $class;
    }
422533
protected function denormalizeProperty($data, $class, $name, $format = null, array $context = array())
    {
        if (!($_class = $this->getClassFromArray($data))) {
            return parent::denormalizeProperty($data, $class, $name, $format, $context);
        }

        $class = $_class;
        if (!$this->serializer instanceof DenormalizerInterface) {
            $message = 'Cannot denormalize attribute "%s" because injected serializer is not a denormalizer';
            throw new RuntimeException(sprintf($message, $name));
        }

        return $this->serializer->denormalize($data, $class, $format, $context);
    }