. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ namespace Espo\ORM; use Espo\ORM\Query\Select; /** * Creates collections. */ class CollectionFactory { public function __construct(protected EntityManager $entityManager) {} /** * Create. * * @param array> $dataList * @return EntityCollection */ public function create(?string $entityType = null, array $dataList = []): EntityCollection { return new EntityCollection($dataList, $entityType, $this->entityManager->getEntityFactory()); } /** * Create from an SQL. * * @return SthCollection */ public function createFromSql(string $entityType, string $sql): SthCollection { return SthCollection::fromSql($entityType, $sql, $this->entityManager); } /** * Create from a query. * * @return SthCollection */ public function createFromQuery(Select $query): SthCollection { return SthCollection::fromQuery($query, $this->entityManager); } /** * Create EntityCollection from SthCollection. * * @template TEntity of Entity * @param SthCollection $sthCollection * @return EntityCollection */ public function createFromSthCollection(SthCollection $sthCollection): EntityCollection { /** @var EntityCollection */ return EntityCollection::fromSthCollection($sthCollection); } }