/** * @param Varien_Object $data * @return array|null */ protected function _getLocaleRecord(Varien_Object $data) { if ($data->hasData('language') && $data->hasData('country')) { return array('language' => (string) $data->getData('language'), 'country' => (string) $data->getData('country'), 'variant' => null); } return null; }
/** * @param $key * * @return mixed */ protected function _getPayoneStateMapping($key) { if ($this->_statusMapping instanceof Varien_Object) { return $this->_statusMapping->hasData($key) ? $this->_statusMapping->getData($key) : false; } return false; }
/** * Formating date value before save * * Should set (bool, string) correct type for empty value from html form, * neccessary for farther proccess, else date string * * @param Varien_Object $object * @throws Mage_Eav_Exception * @return Mage_Eav_Model_Entity_Attribute_Backend_Datetime */ public function beforeSave($object) { $attributeName = $this->getAttribute()->getName(); $_formated = $object->getData($attributeName . '_is_formated'); if (!$_formated && $object->hasData($attributeName)) { try { if (Mage::app()->getLocale()->getLocale() == 'fa_IR') { require_once Mage::getBaseDir('lib') . '/pdate/pdate.php'; if ($object->getData($attributeName) != NULL) { list($j_y, $j_m, $j_d) = explode('/', $object->getData($attributeName)); $gregorianlArray = jalali_to_gregorian($j_y, $j_m, $j_d); $date = implode('-', $gregorianlArray); $object->setData($attributeName, $date); } } $value = $this->formatDate($object->getData($attributeName)); } catch (Exception $e) { throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Invalid date')); } if (is_null($value)) { $value = $object->getData($attributeName); } //Mage::log( "$attributeName, $value ") ; $object->setData($attributeName, $value); $object->setData($attributeName . '_is_formated', true); } return $this; }
/** * Tests Varien_Object->hasData() */ public function testHasData() { $this->assertFalse($this->_object->hasData()); $this->assertFalse($this->_object->hasData('key')); $this->_object->setData('key', 'value'); $this->assertTrue($this->_object->hasData('key')); }
public function insertInObject(Varien_Object $obj) { if (!$obj->hasData('aitunits_mark')) { $obj->setAitunitsMark($this); return $this; } return $this; }
/** * Serialize before saving * @param Varien_Object $object */ public function beforeSave($object) { // parent::beforeSave() is not called intentionally $attrCode = $this->getAttribute()->getAttributeCode(); if ($object->hasData($attrCode)) { $object->setData($attrCode, serialize($object->getData($attrCode))); } }
protected function _hasMark(Varien_Object $obj) { if ($obj->hasData('aitunits_mark')) { if ($obj->getAitunitsMark()->hasHandler(get_class($this))) { return true; } } return false; }
/** * Serialize before saving * * @param Varien_Object $object * @return Mage_Eav_Model_Entity_Attribute_Backend_Serialized */ public function beforeSave($object) { // parent::beforeSave() is not called intentionally $attrCode = $this->getAttribute()->getAttributeCode(); if ($object->hasData($attrCode)) { $object->setData($attrCode, Mage::helper('aligent_customformelements')->jsonEncodeIfRequired($object->getData($attrCode))); } return $this; }
/** * Prepare non standard fields like attributes with type integer * @param Varien_Object $_object */ protected function _prepareData(Varien_Object $_object) { foreach ($this->_preparedCallbacks as $callback => $key) { if ($_object->hasData($key)) { //only for this object call_user_func_array(array($this, $callback), array(&$_object)); } } }
/** * Before save * * @param Varien_Object $object * @return Mage_Customer_Model_Customer_Attribute_Backend_Website */ public function beforeSave($object) { if ($object->getId()) { return $this; } if (!$object->hasData('website_id')) { $object->setData('website_id', Mage::app()->getStore()->getWebsiteId()); } return $this; }
/** * Serialize array in saved_tokens field, then encrypt it and save it into saved_tokens_json attribute * * @param Varien_Object $object * @return $this|Mage_Eav_Model_Entity_Attribute_Backend_Abstract */ public function beforeSave($object) { $attrCode = $this->getAttribute()->getAttributeCode(); if ($object->hasData('saved_tokens') && ($savedTokens = $object->getData('saved_tokens'))) { /* @var Eway_Rapid31_Model_Customer_Savedtokens $savedTokens */ if ($savedTokens && $savedTokens instanceof Eway_Rapid31_Model_Customer_Savedtokens) { $object->setData($attrCode, Mage::helper('core')->encrypt($savedTokens->jsonSerialize())); } } return $this; }
/** * Before save * * @param Varien_Object $object * @return Mage_Customer_Model_Customer_Attribute_Backend_Store */ public function beforeSave($object) { if ($object->getId()) { return $this; } if (!$object->hasStoreId()) { $object->setStoreId(Mage::app()->getStore()->getId()); } if (!$object->hasData('created_in')) { $object->setData('created_in', Mage::app()->getStore($object->getStoreId())->getName()); } return $this; }
/** * Validate product attribute value for condition * * @param Varien_Object $object * @return bool */ public function validate(Varien_Object $object) { $attrCode = $this->getAttribute(); if ('category_ids' == $attrCode) { return $this->validateAttribute($object->getCategoryIds()); } if ('attribute_set_id' == $attrCode) { return $this->validateAttribute($object->getData($attrCode)); } $oldAttrValue = $object->hasData($attrCode) ? $object->getData($attrCode) : null; $object->setData($attrCode, $this->_getAttributeValue($object)); $result = $this->_validateProduct($object); $this->_restoreOldAttrValue($object, $oldAttrValue); return (bool) $result; }
/** * Formating date value before save * * Should set (bool, string) correct type for empty value from html form, * neccessary for farther proccess, else date string * * @param Varien_Object $object * @throws Mage_Eav_Exception * @return Mage_Eav_Model_Entity_Attribute_Backend_Datetime */ public function beforeSave($object) { $attributeName = $this->getAttribute()->getName(); $_formated = $object->getData($attributeName . '_is_formated'); if (!$_formated && $object->hasData($attributeName)) { try { $value = $this->formatDate($object->getData($attributeName)); } catch (Exception $e) { throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Invalid date')); } if (is_null($value)) { $value = $object->getData($attributeName); } $object->setData($attributeName, $value); $object->setData($attributeName . '_is_formated', true); } return $this; }
/** * Renders grid column * * @param Varien_Object $row * @return string */ public function render(Varien_Object $_row) { $data = $_row->getData($this->getColumn()->getIndex()); $priceAmount = 0; if ($data && $_row->getTypeId() != 'reservation') { $priceAmount = $data; } elseif ($_row->hasData('reservation_price')) { $priceAmount = $_row->getData('reservation_price'); } elseif (is_null($data) || $_row->getTypeId() == 'reservation') { $product = $_row->load($_row->getId()); if ($product->getTypeId() != ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_BUNDLE || $product->getBundlePricingtype() == ITwebexperts_Payperrentals_Model_Product_Bundlepricingtype::PRICING_BUNDLE_FORALL) { /** TODO move calculation to mysql join first record */ $priceCollection = Mage::getModel('payperrentals/reservationprices')->getCollection()->addFieldToFilter('entity_id', array('eq' => $_row->getData('entity_id'))); if (count($priceCollection)) { $firstRecord = $priceCollection->getFirstItem(); $priceAmount = $firstRecord->getPrice(); $_row->setData('reservation_number', $firstRecord->getNumberof()); $_row->setData('price_type', $firstRecord->getPtype()); } } elseif ($product->getTypeId() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_BUNDLE) { $priceAmount = 0; } } if ($priceAmount) { $data = floatval($priceAmount) * $this->_getRate($_row); $currency_code = $this->_getCurrencyCode($_row); if (!$currency_code) { return $data; } $data = sprintf("%f", $data); $data = Mage::app()->getLocale()->currency($currency_code)->toCurrency($data); if ($_row->hasData('reservation_number') && $_row->hasData('price_type')) { $periodAr = Mage::getModel('payperrentals/product_periodtype')->getOptionArray($_row->getData('reservation_number')); $data .= '/<b>' . $_row->getData('reservation_number') . ' ' . $periodAr[$_row->getData('price_type')] . '</b>'; } return $data; } return $this->getColumn()->getDefault(); }
/** * TODO Where do we use this method? * Retrieve item id * * @param Varien_Object $item * @return mixed */ protected function _getItemId(Varien_Object $item) { if ($item->hasData($this->_uniqueIdentifier)) { $identifier = $item->getData($this->_uniqueIdentifier); } else { $identifier = $item->getId(); } return $identifier; }
/** * Add total to totals XML * * @param Varien_Object $total * @param Mage_XmlConnect_Model_Simplexml_Element $totalsXml * @return null */ private function _addTotalToXml($total, Mage_XmlConnect_Model_Simplexml_Element $totalsXml) { if ($total instanceof Varien_Object && $total->getCode() && $total->getLabel() && $total->hasData('value')) { $totalsXml->addCustomChild(preg_replace('@[\\W]+@', '_', trim($total->getCode())), $this->_formatPrice($total), array('label' => strip_tags($total->getLabel()))); } }
/** * Prepare data for passed table * * @param Varien_Object $object * @param string $table * @return array */ protected function _prepareDataForTable(Varien_Object $object, $table) { $data = array(); $fields = $this->_getWriteAdapter()->describeTable($table); foreach (array_keys($fields) as $field) { if ($object->hasData($field)) { $fieldValue = $object->getData($field); if ($fieldValue instanceof Zend_Db_Expr) { $data[$field] = $fieldValue; } else { if (null !== $fieldValue) { $fieldValue = $this->_prepareTableValueForSave($fieldValue, $fields[$field]['DATA_TYPE']); $data[$field] = $this->_getWriteAdapter()->prepareColumnValue($fields[$field], $fieldValue); } else { if (!empty($fields[$field]['NULLABLE'])) { $data[$field] = null; } } } } } return $data; }
/** * Return Merge Fields mapped to Magento attributes * * @param object $customer * @param bool $includeEmail * @param integer $websiteId * @return array */ public function getMergeVars($customer, $includeEmail = FALSE, $websiteId = NULL) { $merge_vars = array(); $maps = $this->getMergeMaps($customer->getStoreId()); if (!$maps) { return; } $request = Mage::app()->getRequest(); //Add Customer data to Subscriber if is Newsletter_Subscriber is Customer if (!$customer->getDefaultShipping() && $customer->getEntityId()) { $customer->addData(Mage::getModel('customer/customer')->load($customer->getEntityId())->setStoreId($customer->getStoreId())->toArray()); } elseif ($customer->getCustomerId()) { $customer->addData(Mage::getModel('customer/customer')->load($customer->getCustomerId())->setStoreId($customer->getStoreId())->toArray()); } $merge_vars = $this->_setMaps($maps, $customer, $merge_vars, $websiteId); //GUEST if (!$customer->getId() && !$request->getPost('firstname')) { if ($customer->getSubscriberFirstname()) { $guestFirstName = $customer->getSubscriberFirstname(); } else { $guestFirstName = $this->config('guest_name', $customer->getStoreId()); } if ($guestFirstName) { $merge_vars['FNAME'] = $guestFirstName; } } if (!$customer->getId() && !$request->getPost('lastname')) { if ($customer->getSubscriberLastname()) { $guestLastName = $customer->getSubscriberLastname(); } else { $guestLastName = $this->config('guest_lastname', $customer->getStoreId()); } if ($guestLastName) { $merge_vars['LNAME'] = $guestLastName; } } //GUEST if ($includeEmail) { $merge_vars['EMAIL'] = $customer->getEmail(); } $groups = $customer->getListGroups(); $groupings = array(); if (is_array($groups) && count($groups)) { foreach ($groups as $groupId => $grupoptions) { if (is_array($grupoptions)) { $grupOptionsEscaped = array(); foreach ($grupoptions as $gopt) { $gopt = str_replace(",", "%C%", $gopt); $grupOptionsEscaped[] = $gopt; } $groupings[] = array('id' => $groupId, 'groups' => str_replace('%C%', '\\,', implode(', ', $grupOptionsEscaped))); } else { $groupings[] = array('id' => $groupId, 'groups' => str_replace(',', '\\,', $grupoptions)); } } } $merge_vars['GROUPINGS'] = $groupings; //magemonkey_mergevars_after $blank = new Varien_Object(); Mage::dispatchEvent('magemonkey_mergevars_after', array('vars' => $merge_vars, 'customer' => $customer, 'newvars' => $blank)); if ($blank->hasData()) { $merge_vars = array_merge($merge_vars, $blank->toArray()); } //magemonkey_mergevars_after return $merge_vars; }
/** * Check item filter * * @param Varien_Object $item collection item * * @return bool * @throws Exception */ public function checkFilter($item) { foreach ($this->_filters as $filter) { if (!$item->hasData($filter->getField())) { throw new Exception('Undefined filter : ' . $filter->getField()); } $callback = array($this, $filter->getCallback()); $callbackParams = array($filter->getField(), $filter->getValue(), $item); if (!call_user_func_array($callback, $callbackParams)) { return false; } } return true; }
/** * Before save method * * @param Varien_Object $object * @return Mage_Eav_Model_Entity_Attribute_Backend_Abstract */ public function beforeSave($object) { $attrCode = $this->getAttribute()->getAttributeCode(); if (!$object->hasData($attrCode) && $this->getDefaultValue()) { $object->setData($attrCode, $this->getDefaultValue()); } return $this; }
/** * Set attribute default value if value empty * * @param Varien_Object $object */ public function afterLoad($object) { if (!$object->hasData($this->getAttribute()->getAttributeCode())) { $object->setData($this->getAttribute()->getAttributeCode(), $this->getDefaultValue()); } }
protected function _myPrepareDataForTable(Varien_Object $object, $table, $full = false) { $data = array(); $fields = $this->_getWriteAdapter()->describeTable($table); foreach (array_keys($fields) as $field) { if ($object->hasData($field) || $full) { $fieldValue = $object->getData($field); if ($fieldValue instanceof Zend_Db_Expr) { $data[$field] = $fieldValue; } else { if (null !== $fieldValue) { $data[$field] = $this->_prepareValueForSave($fieldValue, $fields[$field]['DATA_TYPE']); } elseif (!empty($fields[$field]['NULLABLE'])) { $data[$field] = null; } elseif (array_key_exists('DEFAULT', $fields[$field])) { if ($fields[$field]['DEFAULT'] == 'CURRENT_TIMESTAMP') { $data[$field] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); } else { $data[$field] = $fields[$field]['DEFAULT']; } } else { $data[$field] = ''; } } } } return $data; }
public function hasData($key = '') { $this->load(); return parent::hasData($key); }
/** * Return Merge Fields mapped to Magento attributes * * @param object $customer * @param bool $includeEmail * @param integer $websiteId * @return array */ public function getMergeVars($customer, $includeEmail = FALSE, $websiteId = NULL) { $merge_vars = array(); $maps = $this->getMergeMaps($customer->getStoreId()); if (!$maps) { return; } $request = Mage::app()->getRequest(); //Add Customer data to Subscriber if is Newsletter_Subscriber is Customer if (!$customer->getDefaultShipping() && $customer->getEntityId()) { $customer->addData(Mage::getModel('customer/customer')->load($customer->getEntityId())->setStoreId($customer->getStoreId())->toArray()); } foreach ($maps as $map) { $customAtt = $map['magento']; $chimpTag = $map['mailchimp']; if ($chimpTag && $customAtt) { $key = strtoupper($chimpTag); switch ($customAtt) { case 'gender': $val = (int) $customer->getData(strtolower($customAtt)); if ($val == 1) { $merge_vars[$key] = 'Male'; } elseif ($val == 2) { $merge_vars[$key] = 'Female'; } break; case 'dob': $dob = (string) $customer->getData(strtolower($customAtt)); if ($dob) { $merge_vars[$key] = substr($dob, 5, 2) . '/' . substr($dob, 8, 2); } break; case 'billing_address': case 'shipping_address': $addr = explode('_', $customAtt); $address = $customer->{'getPrimary' . ucfirst($addr[0]) . 'Address'}(); if ($address) { $merge_vars[$key] = array('addr1' => $address->getStreet(1), 'addr2' => $address->getStreet(2), 'city' => $address->getCity(), 'state' => !$address->getRegion() ? $address->getCity() : $address->getRegion(), 'zip' => $address->getPostcode(), 'country' => $address->getCountryId()); $telephone = $address->getTelephone(); if ($telephone) { $merge_vars['TELEPHONE'] = $telephone; } $company = $address->getCompany(); if ($company) { $merge_vars['COMPANY'] = $company; } } break; case 'date_of_purchase': $last_order = Mage::getResourceModel('sales/order_collection')->addFieldToFilter('customer_email', $customer->getEmail())->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))->setOrder('created_at', 'desc')->getFirstItem(); if ($last_order->getId()) { $merge_vars[$key] = Mage::helper('core')->formatDate($last_order->getCreatedAt()); } break; case 'ee_customer_balance': $merge_vars[$key] = ''; if ($this->isEnterprise() && $customer->getId()) { $_customer = Mage::getModel('customer/customer')->load($customer->getId()); if ($_customer->getId()) { if (Mage::app()->getStore()->isAdmin()) { $websiteId = is_null($websiteId) ? Mage::app()->getStore()->getWebsiteId() : $websiteId; } $balance = Mage::getModel('enterprise_customerbalance/balance')->setWebsiteId($websiteId)->setCustomerId($_customer->getId())->loadByCustomer(); $merge_vars[$key] = $balance->getAmount(); } } break; case 'group_id': $group_id = (int) $customer->getData(strtolower($customAtt)); $customerGroup = Mage::helper('customer')->getGroups()->toOptionHash(); if ($group_id == 0) { $merge_vars[$key] = 'NOT LOGGED IN'; } else { $merge_vars[$key] = $customerGroup[$group_id]; } break; default: if ($value = (string) $customer->getData(strtolower($customAtt)) or $value = (string) $request->getPost(strtolower($customAtt))) { $merge_vars[$key] = $value; } break; } } } //GUEST if (!$customer->getId() && (!$request->getPost('firstname') || !$request->getPost('lastname'))) { $guestFirstName = $this->config('guest_name', $customer->getStoreId()); $guestLastName = $this->config('guest_lastname', $customer->getStoreId()); if ($guestFirstName) { $merge_vars['FNAME'] = $guestFirstName; } if ($guestLastName) { $merge_vars['LNAME'] = $guestLastName; } } //GUEST if ($includeEmail) { $merge_vars['EMAIL'] = $customer->getEmail(); } $groups = $customer->getListGroups(); $groupings = array(); if (is_array($groups) && count($groups)) { foreach ($groups as $groupId => $grupoptions) { $groupings[] = array('id' => $groupId, 'groups' => is_array($grupoptions) ? implode(', ', $grupoptions) : $grupoptions); } } $merge_vars['GROUPINGS'] = $groupings; //magemonkey_mergevars_after $blank = new Varien_Object(); Mage::dispatchEvent('magemonkey_mergevars_after', array('vars' => $merge_vars, 'customer' => $customer, 'newvars' => $blank)); if ($blank->hasData()) { $merge_vars = array_merge($merge_vars, $blank->toArray()); } //magemonkey_mergevars_after return $merge_vars; }
/** * Before Attribute Save Process * * @param Varien_Object $object * @return Mage_Catalog_Model_Category_Attribute_Backend_Sortby */ public function beforeSave($object) { $attributeCode = $this->getAttribute()->getName(); if ($attributeCode == 'available_sort_by') { $data = $object->getData($attributeCode); if (!is_array($data)) { $data = array(); } $object->setData($attributeCode, join(',', $data)); } if (!$object->hasData($attributeCode)) { $object->setData($attributeCode, false); } return $this; }
/** * Add total to totals XML. Api version 23. * * @param Varien_Object $total * @param Mage_XmlConnect_Model_Simplexml_Element $totalsXml * @return null */ protected function _addTotalToXmlApi23($total, Mage_XmlConnect_Model_Simplexml_Element $totalsXml) { if ($total instanceof Varien_Object && $total->getCode() && $total->getLabel() && $total->hasData('value')) { $totalsXml->addCustomChild('item', $this->_formatPrice($total), array('id' => preg_replace('@[\\W]+@', '_', trim($total->getCode())), 'label' => $totalsXml->escapeXml($total->getLabel()))); } }
/** * Extract data from model into Mongo-compatible array * * @param Varien_Object $object * @param boolean $forUpdate * @return array */ public function dehydrate(Varien_Object $object, $forUpdate = FALSE) { $rawData = array(); $converter = $this->getPhpToMongoConverter(); foreach ($this->getFieldMappings() as $field => $mapping) { if (!$object->hasData($field) && !isset($mapping->required)) { continue; } $rawValue = $object->getData($field); // Skip fields that have not changed on updates if ($forUpdate && (!$object->hasData($field) || $rawValue === $object->getOrigData($field)) && !$rawValue instanceof Cm_Mongo_Model_Abstract && !$rawValue instanceof Cm_Mongo_Model_Resource_Collection_Embedded) { continue; } if ($rawValue === NULL && isset($mapping->required) && !isset($mapping->required->null)) { $rawValue = (string) $mapping->required; } $type = isset($mapping->type) ? (string) $mapping->type : 'string'; // Embedded object if ($type == 'embedded') { if ($rawValue instanceof Cm_Mongo_Model_Abstract) { $value = $rawValue->getResource()->dehydrate($rawValue, $forUpdate); } else { $value = NULL; } if ($forUpdate && empty($value)) { continue; } } else { if ($type == 'embeddedSet') { $value = array(); if ($rawValue instanceof Cm_Mongo_Model_Resource_Collection_Embedded) { $items = $rawValue->getItems(); } else { $items = (array) $rawValue; } $index = 0; foreach ($items as $item) { if ($item instanceof Cm_Mongo_Model_Abstract) { $_value = $item->getResource()->dehydrate($item, $forUpdate); } else { if ($item instanceof Varien_Object) { $_value = $item->getData(); } else { $_value = (array) $item; } } if (!$forUpdate || $_value) { $value[$index] = $_value; } $index++; } if ($forUpdate && empty($value)) { continue; } } else { if ($forUpdate && $type == 'hash' && $object->getOrigData($field)) { $value = array(); $data = $converter->{$type}($mapping, $rawValue); $origData = $object->getOrigData($field); foreach ($data as $k => $v) { if (!isset($origData[$k]) || $v !== $origData[$k]) { $value[$k] = $v; } } } else { $value = $converter->{$type}($mapping, $rawValue); } } } $rawData[$field] = $value; } return $rawData; }
/** * Set attribute default value if value empty * * @param Varien_Object $object */ public function beforeSave($object) { if ($object->hasData($this->getAttribute()->getAttributeCode()) && $object->getData($this->getAttribute()->getAttributeCode()) == $this->getDefaultValue()) { $object->unsData($this->getAttribute()->getAttributeCode()); } }
/** * Executes the task and updates the status. * * @throws Exception on an unexpected configuration error. */ public function run() { if ($this->getStatus() != self::STATUS_RUNNING) { throw new Exception('Cannot run job when status is not \'running\'.'); } // Mark invalid if task not defined if (!$this->getTaskConfig('class')) { $this->updateStatus(self::STATUS_INVALID, 'Task not properly defined.')->save(); return; } // If task is globally disabled, put job on hold. if ($this->isTaskDisabled()) { $this->updateStatus(self::STATUS_DISABLED)->save(); return; } // Load task switch ((string) $this->getTaskConfig('type')) { case 'helper': $object = Mage::helper((string) $this->getTaskConfig('class')); break; case 'model': $object = Mage::getModel((string) $this->getTaskConfig('class')); break; case 'resource': $object = Mage::getResourceSingleton((string) $this->getTaskConfig('class')); break; case 'singleton': default: $object = Mage::getSingleton((string) $this->getTaskConfig('class')); break; } if (!$object) { $this->updateStatus(self::STATUS_INVALID, 'Could not get task model.')->save(); return; } // Confirm existence of method $method = (string) $this->getTaskConfig('method'); if (!method_exists($object, $method)) { $this->updateStatus(self::STATUS_INVALID, 'Cannot call task method.')->save(); return; } $data = new Varien_Object($this->getJobData()); // Run task try { // Load object if a load_index is specified if ($this->getTaskConfig('type') == 'model' && ($loadIndex = $this->getTaskConfig('load_index'))) { if (!$data->hasData($loadIndex)) { throw new Exception('No id in job data to load by.'); } $object->load($data->getData($loadIndex), $loadIndex); $data->unsetData($loadIndex); if (!$object->getId()) { throw new Exception('Object could not be loaded.'); } } $object->{$method}($data, $this); // If status not changed by task, assume success if ($this->getStatus() == self::STATUS_RUNNING || $this->getStatus() == self::STATUS_SUCCESS) { // Update or delete? if ($this->getTaskConfig()->is('after_success', 'keep')) { $this->updateStatus(self::STATUS_SUCCESS); } else { $this->isDeleted(true); } } } catch (Exception $e) { if ($this->getStatus() == self::STATUS_RUNNING) { $this->logError($e); // Retry if ($this->canRetry()) { $this->scheduleRetry(); } else { if ($this->getTaskConfig()->is('after_failure', 'delete')) { $this->isDeleted(true); } else { $this->updateStatus(self::STATUS_FAILED, $e->getMessage()); } } } } $this->save(); }