本文整理汇总了PHP中AO::exception方法的典型用法代码示例。如果您正苦于以下问题:PHP AO::exception方法的具体用法?PHP AO::exception怎么用?PHP AO::exception使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AO
的用法示例。
在下文中一共展示了AO::exception方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 AO::exception('Mage_Eav', AO::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);
}
示例2: generatePackageXml
public function generatePackageXml()
{
AO::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 AO::exception('Mage_Adminhtml', AO::helper('adminhtml')->__($message[0]['message']));
return $this;
}
$this->setPackageXml($pfm->getDefaultGenerator()->toXml(PEAR_VALIDATE_NORMAL));
return $this;
}
示例3: getDir
public function getDir($type)
{
$method = 'get' . ucwords($type) . 'Dir';
$dir = $this->{$method}();
if (!$dir) {
throw AO::exception('Mage_Core', 'Invalid dir type requested: ' . $type);
}
return $dir;
}
示例4: _toHtml
protected function _toHtml()
{
if (!$this->_beforeToHtml()) {
return '';
}
ob_implicit_flush();
foreach ($this->getSortedChildren() as $name) {
$block = $this->getLayout()->getBlock($name);
if (!$block) {
AO::exception(AO::helper('core')->__('Invalid block: %s', $name));
}
echo $block->toHtml();
}
}
示例5: getCode
public function getCode($type, $code = '')
{
$codes = array('condition_name' => array('package_weight' => AO::helper('shipping')->__('Weight vs. Destination'), 'package_value' => AO::helper('shipping')->__('Price vs. Destination'), 'package_qty' => AO::helper('shipping')->__('# of Items vs. Destination')), 'condition_name_short' => array('package_weight' => AO::helper('shipping')->__('Weight (and above)'), 'package_value' => AO::helper('shipping')->__('Order Subtotal (and above)'), 'package_qty' => AO::helper('shipping')->__('# of Items (and above)')));
if (!isset($codes[$type])) {
throw AO::exception('Mage_Shipping', AO::helper('shipping')->__('Invalid Table Rate code type: %s', $type));
}
if ('' === $code) {
return $codes[$type];
}
if (!isset($codes[$type][$code])) {
throw AO::exception('Mage_Shipping', AO::helper('shipping')->__('Invalid Table Rate code for type %s: %s', $type, $code));
}
return $codes[$type][$code];
}
示例6: getChildHtmlList
public function getChildHtmlList()
{
if (is_null($this->_list)) {
$this->_list = array();
foreach ($this->getSortedChildren() as $name) {
$block = $this->getLayout()->getBlock($name);
if (!$block) {
AO::exception(AO::helper('catalog')->__('Invalid block: %s', $name));
}
$this->_list[] = $block->toHtml();
}
}
return $this->_list;
}
示例7: _getCarrier
protected function _getCarrier($code, $config, $store = null)
{
/*
if (isset(self::$_carriers[$code])) {
return self::$_carriers[$code];
}
*/
if (!isset($config['model'])) {
throw AO::exception('Mage_Shipping', 'Invalid model for shipping method: ' . $code);
}
$modelName = $config['model'];
$carrier = AO::getModel($modelName);
$carrier->setId($code)->setStore($store);
self::$_carriers[$code] = $carrier;
return self::$_carriers[$code];
}
示例8: getAllOptions
/**
* Retrieve all options for the source from configuration
*
* @return array
*/
public function getAllOptions()
{
if (is_null($this->_options)) {
$this->_options = array();
if ($this->_configNodePath) {
$rootNode = AO::getConfig()->getNode($this->_configNodePath);
}
if (!$rootNode) {
throw AO::exception('Mage_Eav', AO::helper('eav')->__('Failed to load node %s from config.', $this->_configNodePath));
}
$options = $rootNode->children();
if (empty($options)) {
throw AO::exception('Mage_Eav', AO::helper('eav')->__('No options found in config node %s', $this->_configNodePath));
}
foreach ($options as $option) {
$this->_options[] = array('value' => (string) $option->value, 'label' => (string) $option->label);
}
}
return $this->_options;
}
示例9: getRate
/**
* Get currency rate
*
* @param string $toCurrency
* @return double
*/
public function getRate($toCurrency)
{
if (is_string($toCurrency)) {
$code = $toCurrency;
} elseif ($toCurrency instanceof Mage_Directory_Model_Currency) {
$code = $toCurrency->getCurrencyCode();
} else {
throw AO::exception('Mage_Directory', AO::helper('directory')->__('Invalid target currency'));
}
$rates = $this->getRates();
if (!isset($rates[$code])) {
$rates[$code] = $this->_getResource()->getRate($this->getCode(), $toCurrency);
$this->setRates($rates);
}
return $rates[$code];
}
示例10: _collectSaveData
/**
* Prepare entity object data for save
*
* result array structure:
* array (
* 'newObject', 'entityRow', 'insert', 'update', 'delete'
* )
*
* @param Varien_Object $newObject
* @return array
*/
protected function _collectSaveData($newObject)
{
$newData = $newObject->getData();
$entityId = $newObject->getData($this->getEntityIdField());
if (!empty($entityId)) {
/**
* get current data in db for this entity
*/
/*$className = get_class($newObject);
$origObject = new $className();
$origObject->setData(array());
$this->load($origObject, $entityId);
$origData = $origObject->getOrigData();*/
$origData = $this->_getOrigObject($newObject)->getOrigData();
/**
* drop attributes that are unknown in new data
* not needed after introduction of partial entity loading
*/
foreach ($origData as $k => $v) {
if (!array_key_exists($k, $newData)) {
unset($origData[$k]);
}
}
}
foreach ($newData as $k => $v) {
/**
* Check attribute information
*/
if (is_numeric($k) || is_array($v)) {
continue;
throw AO::exception('Mage_Eav', AO::helper('eav')->__('Invalid data object key'));
}
$attribute = $this->getAttribute($k);
if (empty($attribute)) {
continue;
}
$attrId = $attribute->getAttributeId();
/**
* if attribute is static add to entity row and continue
*/
if ($this->isAttributeStatic($k)) {
$entityRow[$k] = $this->_prepareStaticValue($k, $v);
continue;
}
/**
* Check comparability for attribute value
*/
if (isset($origData[$k])) {
if ($attribute->isValueEmpty($v)) {
$delete[$attribute->getBackend()->getTable()][] = array('attribute_id' => $attrId, 'value_id' => $attribute->getBackend()->getValueId());
} elseif ($v !== $origData[$k]) {
$update[$attrId] = array('value_id' => $attribute->getBackend()->getValueId(), 'value' => $v);
}
} elseif (!$attribute->isValueEmpty($v)) {
$insert[$attrId] = $v;
}
}
$result = compact('newObject', 'entityRow', 'insert', 'update', 'delete');
return $result;
}
示例11: _addAttributeJoin
/**
* Add attribute value table to the join if it wasn't added previously
*
* @param string $attributeCode
* @param string $joinType inner|left
* @return Mage_Eav_Model_Entity_Collection_Abstract
*/
protected function _addAttributeJoin($attributeCode, $joinType = 'inner')
{
if (!empty($this->_filterAttributes[$attributeCode])) {
return $this;
}
$attrTable = $this->_getAttributeTableAlias($attributeCode);
if (isset($this->_joinAttributes[$attributeCode])) {
$attribute = $this->_joinAttributes[$attributeCode]['attribute'];
$entity = $attribute->getEntity();
$entityIdField = $entity->getEntityIdField();
$fkName = $this->_joinAttributes[$attributeCode]['bind'];
$fkAttribute = $this->_joinAttributes[$attributeCode]['bindAttribute'];
$fkTable = $this->_getAttributeTableAlias($fkName);
if ($fkAttribute->getBackend()->isStatic()) {
if (isset($this->_joinAttributes[$fkName])) {
$fk = $fkTable . "." . $fkAttribute->getAttributeCode();
} else {
$fk = "e." . $fkAttribute->getAttributeCode();
}
} else {
$this->_addAttributeJoin($fkAttribute->getAttributeCode(), $joinType);
$fk = "{$fkTable}.value";
}
$pk = $attrTable . '.' . $this->_joinAttributes[$attributeCode]['filter'];
} else {
$entity = $this->getEntity();
$entityIdField = $entity->getEntityIdField();
$attribute = $entity->getAttribute($attributeCode);
$fk = "e.{$entityIdField}";
$pk = "{$attrTable}.{$entityIdField}";
}
if (!$attribute) {
throw AO::exception('Mage_Eav', AO::helper('eav')->__('Invalid attribute name: %s', $attributeCode));
}
if ($attribute->getBackend()->isStatic()) {
$attrFieldName = "{$attrTable}." . $attribute->getAttributeCode();
} else {
$attrFieldName = "{$attrTable}.value";
}
$condArr = array("{$pk} = {$fk}");
if (!$attribute->getBackend()->isStatic()) {
$condArr[] = $this->getConnection()->quoteInto("{$attrTable}.attribute_id=?", $attribute->getId());
}
/**
* process join type
*/
$joinMethod = $joinType == 'left' ? 'joinLeft' : 'join';
$this->_joinAttributeToSelect($joinMethod, $attribute, $attrTable, $condArr, $attributeCode, $attrFieldName);
$this->removeAttributeToSelect($attributeCode);
$this->_filterAttributes[$attributeCode] = $attribute->getId();
/**
* Fix double join for using same as filter
*/
$this->_joinFields[$attributeCode] = array('table' => '', 'field' => $attrFieldName);
return $this;
}
示例12: getBackend
/**
* Retrieve backend instance
*
* @return Mage_Eav_Model_Entity_Attribute_Backend_Abstract
*/
public function getBackend()
{
if (empty($this->_backend)) {
if (!$this->getBackendModel()) {
$this->setBackendModel($this->_getDefaultBackendModel());
}
$backend = AO::getModel($this->getBackendModel());
if (!$backend) {
throw AO::exception('Mage_Eav', 'Invalid backend model specified: ' . $this->getBackendModel());
}
$this->_backend = $backend->setAttribute($this);
}
return $this->_backend;
}
示例13: _inludeControllerClass
/**
* Including controller class if checking of existense class before include
*
* @param string $controllerFileName
* @param string $controllerClassName
* @return bool
*/
protected function _inludeControllerClass($controllerFileName, $controllerClassName)
{
if (!class_exists($controllerClassName, false)) {
if (!file_exists($controllerFileName)) {
return false;
}
include $controllerFileName;
if (!class_exists($controllerClassName, false)) {
throw AO::exception('Mage_Core', AO::helper('core')->__('Controller file was loaded but class does not exist'));
}
}
return true;
}
示例14: getGroup
/**
* Retrieve application store group object
*
* @return Mage_Core_Model_Store_Group
*/
public function getGroup($id = null)
{
if (is_null($id)) {
$id = $this->getStore()->getGroup()->getId();
} elseif ($id instanceof Mage_Core_Model_Store_Group) {
return $id;
}
if (empty($this->_groups[$id])) {
$group = AO::getModel('core/store_group');
if (is_numeric($id)) {
$group->load($id);
if (!$group->hasGroupId()) {
throw AO::exception('Mage_Core', 'Invalid store group id requested.');
}
}
$this->_groups[$group->getGroupId()] = $group;
}
return $this->_groups[$id];
}
示例15: 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 AO::exception('Mage_Core', AO::helper('core')->__('Invalid layout update handle'));
}
foreach ($handles as $handle) {
$this->addHandle($handle);
}
if ($this->loadCache()) {
return $this;
}
foreach ($this->getHandles() as $handle) {
$this->merge($handle);
}
$this->saveCache();
return $this;
}