<commit_before><?php
/**
 * User: <NAME> <<EMAIL>>
 */
namespace Praxigento\Downline\Observer;

use Magento\Framework\Event\ObserverInterface;

/**
 * Register downline on new customer create event.
 */
class CustomerSaveAfterDataObject implements ObserverInterface
{
    const A_CUST_MLM_ID = 'prxgtCustMlmId';
    const A_PARENT_MAGE_ID = 'prxgtParentMageId';

    /** @var \Praxigento\Downline\Service\ICustomer */
    private $callCustomer;

    public function __construct(
        \Praxigento\Downline\Service\ICustomer $callCustomer
    ) {
        $this->callCustomer = $callCustomer;
    }

    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        /** @var \Magento\Customer\Model\Data\Customer $beforeSave */
        $beforeSave = $observer->getData('orig_customer_data_object');
        /** @var \Magento\Customer\Model\Data\Customer $afterSave */
        $afterSave = $observer->getData('customer_data_object');
        $idBefore = $beforeSave->getId();
        $idAfter = $afterSave->getId();
        if ($idBefore != $idAfter) {
            /* this is newly saved customer, register it into downline */
            $mlmId = $beforeSave->{self::A_CUST_MLM_ID};
            $parentId = $beforeSave->{self::A_PARENT_MAGE_ID};
            $req = new \Praxigento\Downline\Service\Customer\Request\Add();
            $req->setCustomerId($idAfter);
            $req->setParentId($parentId);
            if ($mlmId) {
                $req->setReference($mlmId);
            } else {
                /* TODO: reference should be generated */
                $req->setReference($idAfter);
            }
            $this->callCustomer->add($req);
        }
        return;
    }
}<commit_msg>MOBI-945 - Switch dvlp & test Generic projects to new deployment scheme<commit_after><?php
/**
 * User: <NAME> <<EMAIL>>
 */

namespace Praxigento\Downline\Observer;

use Magento\Framework\Event\ObserverInterface;

/**
 * Register downline on new customer create event.
 */
class CustomerSaveAfterDataObject implements ObserverInterface
{
    const A_CUST_MLM_ID = 'prxgtCustMlmId';
    const A_PARENT_MAGE_ID = 'prxgtParentMageId';

    /** @var \Praxigento\Downline\Service\ICustomer */
    private $callCustomer;

    public function __construct(
        \Praxigento\Downline\Service\ICustomer $callCustomer
    )
    {
        $this->callCustomer = $callCustomer;
    }

    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        /** @var \Magento\Customer\Model\Data\Customer $beforeSave */
        $beforeSave = $observer->getData('orig_customer_data_object');
        /** @var \Magento\Customer\Model\Data\Customer $afterSave */
        $afterSave = $observer->getData('customer_data_object');
        $idBefore = $beforeSave->getId();
        $idAfter = $afterSave->getId();
        if ($idBefore != $idAfter) {
            /* this is newly saved customer, register it into downline */
            $mlmId = $beforeSave->{self::A_CUST_MLM_ID} ?? null;
            $parentId = $beforeSave->{self::A_PARENT_MAGE_ID} ?? null;
            $req = new \Praxigento\Downline\Service\Customer\Request\Add();
            $req->setCustomerId($idAfter);
            $req->setParentId($parentId);
            if ($mlmId) {
                $req->setReference($mlmId);
            } else {
                /* TODO: reference should be generated */
                $req->setReference($idAfter);
            }
            $this->callCustomer->add($req);
        }
        return;
    }
}
{'fraction_non_alphanumeric': 0.13338997451146983, 'fraction_numerical': 0.0008496176720475786, 'mean_word_length': 2.5074478649453824, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6021097', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1058, 'n_words': 185}