b374k
m1n1 1.01
Apache/2.4.41 (Ubuntu)
Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64
uid=33(www-data) gid=33(www-data) groups=33(www-data)
server ip : 62.171.164.128 | your ip : 127.0.0.1
safemode OFF
 >  / home / dev2.destoffenstraat.com / app / code / Amasty / Paction / Model /
Filename/home/dev2.destoffenstraat.com/app/code/Amasty/Paction/Model/EntityResolver.php
Size1.65 kb
Permissionrw-r--r--
Ownerroot : root
Create time17-Aug-2025 10:26
Last modified26-Jul-2025 18:05
Last accessed21-Aug-2025 20:26
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php

declare(strict_types=1);

/**
* @author Amasty Team
* @copyright Copyright (c) 2023 Amasty (https://www.amasty.com)
* @package Mass Product Actions for Magento 2
*/

namespace Amasty\Paction\Model;

use Magento\Framework\EntityManager\EntityMetadataInterface;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Adapter\AdapterInterface;

class EntityResolver
{
/**
* @var MetadataPool
*/
private $metadataPool;

/**
* @var AdapterInterface
*/
private $connection;

/**
* @var ResourceConnection
*/
private $resource;

public function __construct(
MetadataPool $metadataPool,
ResourceConnection $resource
) {
$this->metadataPool = $metadataPool;
$this->connection = $resource->getConnection();
$this->resource = $resource;
}

public function getEntityLinkField(string $entityType): string
{
return $this->getEntityMetadata($entityType)->getLinkField();
}

public function getEntityLinkIds(string $entityType, array $ids): array
{
if ($this->getEntityLinkField($entityType) === 'entity_id') {
return $ids;
}

$tableName = $this->getEntityMetadata($entityType)->getEntityTable();
$select = $this->connection->select()
->from($tableName, ['row_id'])
->where('entity_id IN (?)', $ids);

return $this->connection->fetchCol($select);
}

private function getEntityMetadata(string $entityType): EntityMetadataInterface
{
return $this->metadataPool->getMetadata($entityType);
}
}