| Current Path : /home/rtorresani/www/vendor/stripe/module-payments/Model/ResourceModel/ |
| Current File : //home/rtorresani/www/vendor/stripe/module-payments/Model/ResourceModel/StripeCustomer.php |
<?php
namespace StripeIntegration\Payments\Model\ResourceModel;
class StripeCustomer extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
/**
* Construct
*
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
* @param string|null $resourcePrefix
*/
public function __construct(
\Magento\Framework\Model\ResourceModel\Db\Context $context,
$resourcePrefix = null
) {
parent::__construct($context, $resourcePrefix);
}
/**
* Initialize resource model
*
* @return void
*/
protected function _construct()
{
$this->_init('stripe_customers', 'id');
}
/**
* Process post data before saving
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
{
// if ($object->isObjectNew() && !$object->hasCreationTime()) {
// $object->setCreationTime($this->_date->gmtDate());
// }
// $object->setUpdateTime($this->_date->gmtDate());
return parent::_beforeSave($object);
}
/**
* Load an object using 'stripe_id' field if there's no field specified and value is not numeric
*
* @param \Magento\Framework\Model\AbstractModel $object
* @param mixed $value
* @param string $field
* @return $this
*/
public function load(\Magento\Framework\Model\AbstractModel $object, $value, $field = null)
{
if (!is_numeric($value) && is_null($field)) {
$field = 'stripe_id';
}
return parent::load($object, $value, $field);
}
}