Server IP : 192.158.238.246 / Your IP : 52.15.179.198 Web Server : LiteSpeed System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64 User : jenniferflocom ( 1321) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/7779/root/proc/7779/cwd/plugins/give/src/Session/SessionDonation/ |
Upload File : |
<?php namespace Give\Session\SessionDonation; use DateTime; use Give\Session\Accessor; use Give\Session\SessionDonation\SessionObjects\Donation as DonationObject; use Give\Session\SessionDonation\SessionObjects\FormEntry; /** * Class Donation * * This class provide way to access donation session data. * * @package Give\Session\Access * * @method DonationObject get */ class DonationAccessor extends Accessor { /** * Session Id * * @since 2.7.0 * @var string */ protected $sessionKey = 'give_purchase'; /** * Donation object. * * Since 2.7.0 * * @var DonationObject */ protected $dataObj; /** * property vs session key array. * It is useful to map array keys to class properties. * * @var array */ private $renameTo = [ 'user_email' => 'donorEmail', 'user_info' => 'donorInfo', 'post_data' => 'formEntry', 'donation_id' => 'id', 'price' => 'totalAmount', 'gateway' => 'paymentGateway', 'date' => 'createdAt', ]; /** * Map array keys to class properties * * @since 2.7.0 * * @param array $data * * @return DonationObject */ protected function convertToObject($data) { if ( ! $data) { return null; } // Cast date string to DateTime object. $data['date'] = DateTime::createFromFormat('Y-m-d H:i:s', $data['date']); // Rename key if property name exist for them. foreach ($data as $key => $value) { if (array_key_exists($key, $this->renameTo)) { $data[$this->renameTo[$key]] = $value; unset($data[$key]); } } // Rename unknown keys. $data = $this->renameArrayKeysToPropertyNames($data); return DonationObject::fromArray($data); } /** * Get donation id. * * @since 2.7.0 * @return int * */ public function getDonationId() { if ($donationId = $this->getByKey('id')) { return absint($donationId); } return null; } /** * Get donation id. * * @since 2.7.0 * @return int * */ public function getFormId() { /* @var FormEntry $data */ if ($data = $this->getByKey('formEntry')) { return absint($data->formId); } return null; } }