Okay, after a while I found a solution in case someone else needs it..
Magento uses another approach to instantiate objects, the traditional way to instantiate objects in Magento 1.x was using "Mage::getModel(..)", this have changed in Magento 2. Now Magento uses an object manager to instantiate objets, I won't enter in details about how it works.. so, the equivalent code for creating customers in Magento 2 would look like this:
<?php
namespace ModuleNamespace\Module_Name\Controller\Index;
class Index extends \Magento\Framework\App\Action\Action
{
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $storeManager;
/**
* @var \Magento\Customer\Model\CustomerFactory
*/
protected $customerFactory;
/**
* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Customer\Model\CustomerFactory $customerFactory
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Customer\Model\CustomerFactory $customerFactory
) {
$this->storeManager = $storeManager;
$this->customerFactory = $customerFactory;
parent::__construct($context);
}
public function execute()
{
// Get Website ID
$websiteId = $this->storeManager->getWebsite()->getWebsiteId();
// Instantiate object (this is the most important part)
$customer = $this->customerFactory->create();
$customer->setWebsiteId($websiteId);
// Preparing data for new customer
$customer->setEmail("email@domain.com");
$customer->setFirstname("First Name");
$customer->setLastname("Last name");
$customer->setPassword("password");
// Save data
$customer->save();
$customer->sendNewAccountEmail();
}
}
Hope this snippet of code help someone else..