Пример #1
0
/**
 * 2016-01-11
 * Первая реализация была наивной:
 * return df_sales_seq_m()->getSequence($entityTypeCode, df_store_id($store))->getNextValue();
 * Она неправильна тем, что метод
 * @see \Magento\SalesSequence\Model\Sequence::getNextValue()
 * @see \Magento\Framework\DB\Sequence\SequenceInterface::getNextValue()
 * не только возвращает результат, но и обладает сторонним эффектом,
 * добавляя в таблицу новую строку:
 * $this->connection->insert($this->meta->getSequenceTable(), []);
 * https://github.com/magento/magento2/blob/d50ee54/app/code/Magento/SalesSequence/Model/Sequence.php#L82
 * Наша функция не имеет сторонних эффектов.
 *
 * @param string $entityTypeCode
 * @param int|string|null|bool|StoreInterface $store [optional]
 * @return string
 */
function df_sales_seq_next($entityTypeCode, $store = null)
{
    /**
     * 2016-01-11
     * https://github.com/magento/magento2/blob/d50ee54/app/code/Magento/SalesSequence/Model/Sequence.php#L83
     * https://github.com/magento/magento2/blob/d50ee54/app/code/Magento/SalesSequence/Setup/InstallSchema.php#L123-L129
     */
    return df_next_increment(df_sales_seq_meta($entityTypeCode, $store)->getSequenceTable());
}
Пример #2
0
 /**
  * 2016-06-04
  * @used-by mc()
  * @used-by register()
  * @return array(string => mixed)
  */
 protected function customerData()
 {
     return dfc($this, function () {
         return df_clean(['firstname' => $this->c()->nameFirst(), 'lastname' => $this->c()->nameLast(), 'middlename' => $this->c()->nameMiddle(), 'dob' => $this->c()->dob(), 'email' => $this->c()->email() ?: df_next_increment('customer_entity') . '@none.com', 'force_confirmed' => true, 'gender' => $this->c()->gender(), 'password' => $this->c()->password(), 'taxvat' => df_is_customer_attribute_required('taxvat') ? '000000000000' : '', $this->fId() => $this->c()->id()]);
     });
 }