src/Entity/AttachableEntityManager.php
public function createAttachedEntity($entityClass, $values = [], $key = null)
    {
        if (is_string($values)) {
            $key = $values;
            $values = [];
        }

        $entity = $this->repositories->getRepository($entityClass)->create($values);

        $this->addAttachedEntity($entity, $key);

        return $entity;
    }
public function createAttachedEntity($entityClass, $values = [], $key = null)
    {
        if (is_string($values)) {
            $key = $values;
            $values = [];
        }

        $entity = $this->repositories->getRepository($entityClass)->create($values);

        $this->addAttachedEntity($entity, $key);

        return $entity;
    }
Creates an entity and adds it.

@param string        $entityClass
@param array|string  $values
@param null|string   $key

@return \Core\Entity\EntityInterface
@since 0.29