本文整理汇总了PHP中Mage::exception方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage::exception方法的具体用法?PHP Mage::exception怎么用?PHP Mage::exception使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage
的用法示例。
在下文中一共展示了Mage::exception方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generatePackageXml
public function generatePackageXml()
{
Mage::getSingleton('adminhtml/session')->setLocalExtensionPackageFormData($this->getData());
Varien_Pear::$reloadOnRegistryUpdate = false;
$pkg = new Varien_Pear_Package();
#$pkg->getPear()->runHtmlConsole(array('command'=>'list-channels'));
$pfm = $pkg->getPfm();
$pfm->setOptions(array('packagedirectory' => '.', 'baseinstalldir' => '.', 'simpleoutput' => true));
$this->_setPackage($pfm);
$this->_setRelease($pfm);
$this->_setMaintainers($pfm);
$this->_setDependencies($pfm);
$this->_setContents($pfm);
#echo "<pre>".print_r($pfm,1)."</pre>";
if (!$pfm->validate(PEAR_VALIDATE_NORMAL)) {
//echo "<pre>".print_r($this->getData(),1)."</pre>";
//echo "TEST:";
//echo "<pre>".print_r($pfm->getValidationWarnings(), 1)."</pre>";
$message = $pfm->getValidationWarnings();
//$message = $message[0]['message'];
throw Mage::exception('Mage_Adminhtml', Mage::helper('adminhtml')->__($message[0]['message']));
return $this;
}
$this->setPackageXml($pfm->getDefaultGenerator()->toXml(PEAR_VALIDATE_NORMAL));
return $this;
}
示例2: setData
/**
* @param array|string $key
* @param null $value
*
* @return $this
* @throws Mage_Core_Exception
*/
public function setData($key, $value = null)
{
if (is_string($key) && !array_key_exists($key, $this->getStaticData()) && !in_array($key, $this->getApprovedKeys())) {
throw Mage::exception('Mageplace_Backup', Mage::helper('mpbackup')->__('Wrong object key: %s', $key));
}
return parent::setData($key, $value);
}
示例3: getNextId
public function getNextId()
{
$lastId = $this->getLastId();
if (strpos($lastId, $this->getPrefix()) === 0) {
$lastId = substr($lastId, strlen($this->getPrefix()));
}
$lastId = str_pad((string) $lastId, $this->getPadLength(), $this->getPadChar(), STR_PAD_LEFT);
$nextId = '';
$bumpNextChar = true;
$chars = $this->getAllowedChars();
$lchars = strlen($chars);
$lid = strlen($lastId) - 1;
for ($i = $lid; $i >= 0; $i--) {
$p = strpos($chars, $lastId[$i]);
if (false === $p) {
throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Invalid character encountered in increment ID: %s', $lastId));
}
if ($bumpNextChar) {
$p++;
$bumpNextChar = false;
}
if ($p === $lchars) {
$p = 0;
$bumpNextChar = true;
}
$nextId = $chars[$p] . $nextId;
}
return $this->format($nextId);
}
示例4: _validateLanguageCode
/**
* Check that the language code value is a valid language code. If it
* is not, throw an exception.
*
* @param string
* @return self
* @throws EbayeEnterprise_Eb2cCore_Exception If value is not a valid language code.
*/
protected function _validateLanguageCode($langCode)
{
if (!$this->_langHelper->validateLanguageCode($langCode)) {
throw Mage::exception('EbayEnterprise_Eb2cCore', $this->_coreHelper->__(self::INVALID_LANGUAGE_CODE_MESSAGE));
}
return $this;
}
示例5: load
/**
* Load layout updates by handles
*
* @param array|string $handles
* @return Mage_Core_Model_Layout_Update
*/
public function load($handles = array())
{
if (is_string($handles)) {
$handles = array($handles);
} elseif (!is_array($handles)) {
throw Mage::exception('Mage_Core', Mage::helper('core')->__('Invalid layout update handle'));
}
foreach ($handles as $handle) {
$this->addHandle($handle);
}
if ($this->loadCache()) {
return $this;
}
$specificTime = null;
$storeTimeStamp = Mage::app()->getLocale()->storeTimeStamp();
foreach ($this->getHandles() as $handle) {
$this->merge($handle);
/* Set cache lifetime based on layout active to date*/
if (Mage::app()->useCache('layout')) {
if ($layoutActiveTo = Mage::getResourceModel('core/layout')->fetchLayoutActiveToByHandle($handle)) {
$endDate = Mage::app()->getLocale()->date()->setDate($layoutActiveTo, 'Y-M-d')->setTime('23:59:59')->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$timeDiff = strtotime($endDate) - $storeTimeStamp;
if ($timeDiff > 0) {
$specificTime = is_null($specificTime) ? $timeDiff : ($specificTime > $timeDiff ? $timeDiff : $specificTime);
}
}
}
}
$this->saveCache($specificTime);
return $this;
}
示例6: _beforeSave
/**
* Check customer scope, email and confirmation key before saving
*
* @param Mage_Customer_Model_Customer $customer
* @throws Mage_Customer_Exception
* @return Mage_Customer_Model_Resource_Customer
*/
protected function _beforeSave(Varien_Object $customer)
{
parent::_beforeSave($customer);
if (!$customer->getEmail()) {
throw Mage::exception('Mage_Customer', Mage::helper('Mage_Customer_Helper_Data')->__('Customer email is required'));
}
$adapter = $this->_getWriteAdapter();
$bind = array('email' => $customer->getEmail());
$select = $adapter->select()->from($this->getEntityTable(), array($this->getEntityIdField()))->where('email = :email');
if ($customer->getSharingConfig()->isWebsiteScope()) {
$bind['website_id'] = (int) $customer->getWebsiteId();
$select->where('website_id = :website_id');
}
if ($customer->getId()) {
$bind['entity_id'] = (int) $customer->getId();
$select->where('entity_id != :entity_id');
}
$result = $adapter->fetchOne($select, $bind);
if ($result) {
throw Mage::exception('Mage_Customer', Mage::helper('Mage_Customer_Helper_Data')->__('This customer email already exists'), Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS);
}
// set confirmation key logic
if ($customer->getForceConfirmed()) {
$customer->setConfirmation(null);
} elseif (!$customer->getId() && $customer->isConfirmationRequired()) {
$customer->setConfirmation($customer->getRandomConfirmationKey());
}
// remove customer confirmation key from database, if empty
if (!$customer->getConfirmation()) {
$customer->setConfirmation(null);
}
return $this;
}
示例7: _construct
/**
* Initialize the class
* @throws Mage_Core_Exception
*/
public function _construct()
{
list($this->config) = $this->checkTypes($this->nullCoalesce($this->getArgs(), 'config', Mage::helper('membersonly/config')));
if (!$this instanceof Mage_Core_Block_Template) {
throw Mage::exception('Mage_Core', 'Invalid use of trait ' . get_class());
}
}
示例8: _validateGiftCardForStorate
protected function _validateGiftCardForStorate(EbayEnterprise_GiftCard_Model_IGiftcard $card)
{
if ($card->getCardNumber()) {
return $this;
}
throw Mage::exception('EbayEnterprise_GiftCard', 'Invalid gift card.');
}
示例9: authenticate
public function authenticate($login, $password)
{
// We need to websiteId value before load By Email
$subAccountMode = false;
$websiteId = $this->getWebsiteId();
$useSubAccount = Mage::helper('cminds_multiuseraccounts')->isEnabled();
$this->loadByEmail($login);
$account = $this;
if (!$account->getId() && $useSubAccount) {
// No Main Account found try with SubAccount
$account = Mage::getModel('cminds_multiuseraccounts/subAccount')->setWebsiteId($websiteId);
$account->loadByEmail($login);
$subAccountMode = true;
}
if ($account->getConfirmation() && $account->isConfirmationRequired()) {
throw Mage::exception('Mage_Core', Mage::helper('customer')->__('This account is not confirmed.'), self::EXCEPTION_EMAIL_NOT_CONFIRMED);
}
if (!$account->validatePassword($password)) {
throw Mage::exception('Mage_Core', Mage::helper('customer')->__('Invalid login or password.'), self::EXCEPTION_INVALID_EMAIL_OR_PASSWORD);
}
if ($subAccountMode) {
$this->load($account->getParentCustomerId());
$customerSession = Mage::getSingleton('customer/session');
$customerSession->setSubAccount($account);
$beforeUrl = $customerSession->getBeforeAuthUrl();
if (strpos($beforeUrl, 'customer/account/subAccount') !== false) {
$customerSession->setBeforeAuthUrl(Mage::helper('customer')->getAccountUrl());
}
}
Mage::dispatchEvent('customer_customer_authenticated', array('model' => $this, 'password' => $password));
return true;
}
示例10: beforeSave
/**
* 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;
}
示例11: process
/**
* Process single job
*
* @return Xcom_Initializer_Model_Job
* @throws Mage_Core_Exception
*/
public function process()
{
/** @var $message Xcom_Xfabric_Model_Message_Request */
$message = Mage::helper('xcom_xfabric')->getMessage($this->getTopic());
if (!$message) {
throw Mage::exception('Xcom_Xfabric', Mage::helper('xcom_xfabric')->__("Message for topic %s should be created", $this->getTopic()));
}
$data = json_decode($this->getMessageParams(), true);
$message->process(new Varien_Object($data));
// we set the flag to make requests slower since it adds a timeout to wait for responce
$message->setIsWaitResponse();
// Save correlationId to get stub scenario working
Mage::getModel('xcom_initializer/job')->load($this->getJobId())->setCorrelationId($message->getCorrelationId())->save();
try {
Mage::helper('xcom_xfabric')->getTransport()->setMessage($message)->send();
} catch (Exception $ex) {
Mage::logException($ex);
}
/*
Update only jobs in pending status since we could get responses from the stub
and some jobs are already set to saved status at the moment
*/
Mage::getResourceModel('xcom_initializer/job')->updateStatusByCorrelationId(Xcom_Initializer_Model_Job::STATUS_SENT, $message->getCorrelationId(), array('status = ?' => Xcom_Initializer_Model_Job::STATUS_PENDING));
return $this;
}
示例12: import
/**
* @$forceCreation true overwrites existing entities with the new values
*/
public function import($forceCreation = false)
{
if (is_null($this->_entity)) {
throw Mage::exception('Please specify a valid entity.');
}
if (!file_exists($this->_importFile)) {
throw Mage::exception('Please specify a valid csv file.');
}
if (is_null($this->_storeId)) {
throw Mage::exception('Please specify a valid store.');
}
$io = new Varien_Io_File();
$io->streamOpen($this->_importFile, 'r');
$io->streamLock(true);
$firstLine = true;
while (false !== ($line = $io->streamReadCsv())) {
if ($firstLine) {
$firstLine = false;
$this->_headerColumns = $line;
continue;
}
$data = array();
foreach ($this->_headerColumns as $key => $val) {
$data[$val] = $line[$key];
}
$this->_importEntity($data, $forceCreation);
}
}
示例13: sendTransactional
/**
* Send transactional email to recipient
*
* @param int $templateId
* @param string|array $sender sneder informatio, can be declared as part of config path
* @param string $email recipient email
* @param string $name recipient name
* @param array $vars varianles which can be used in template
* @param int|null $storeId
* @return Mage_Core_Model_Email_Template
*/
public function sendTransactional($templateId, $sender, $email, $name, $vars = array(), $storeId = null)
{
$this->setSentSuccess(false);
if ($storeId === null && $this->getDesignConfig()->getStore()) {
$storeId = $this->getDesignConfig()->getStore();
}
if (is_numeric($templateId)) {
$this->load($templateId);
} else {
$localeCode = Mage::getStoreConfig('general/locale/code', $storeId);
$this->loadDefault($templateId, $localeCode);
}
if (!$this->getId()) {
throw Mage::exception('Mage_Core', Mage::helper('core')->__('Invalid transactional email code: ' . $templateId));
}
if (!is_array($sender)) {
$this->setSenderName(Mage::getStoreConfig('trans_email/ident_' . $sender . '/name', $storeId));
$this->setSenderEmail(Mage::getStoreConfig('trans_email/ident_' . $sender . '/email', $storeId));
} else {
$this->setSenderName($sender['name']);
$this->setSenderEmail($sender['email']);
}
if (!isset($vars['store'])) {
$vars['store'] = Mage::app()->getStore($storeId);
}
if (Mage::getStoreConfig("gemgento_email/settings/enabled")) {
$this->setSentSuccess($this->gemgentoSend($email, $name, $vars));
} else {
$this->setSentSuccess($this->send($email, $name, $vars));
}
return $this;
}
示例14: checkOrderCreationAuth
public function checkOrderCreationAuth($observer)
{
$helper = Mage::helper('cminds_multiuseraccounts');
if (!$helper->hasCreateOrderPermission()) {
throw Mage::exception('Mage_Core', $helper->__('No Order creation permission for this account'));
}
return;
}
示例15: getTenderTypeForCcType
/**
* Get the ROM Tender Type for the Magento CC Type.
* @param string $creditCardType
* @return string
*/
public function getTenderTypeForCcType($creditCardType)
{
$types = $this->getConfigModel()->tenderTypes;
if (isset($types[$creditCardType])) {
return $types[$creditCardType];
}
throw Mage::exception('EbayEnterprise_CreditCard', self::UNKNOWN_CARD_TYPE);
}