获取淘宝客商品链接转换(需要拥有此权限)
@param $id
@param $adzone_id
@return mixed
@throws Exception
481361
public function convert($id, $adzone_id) {
        $res = $this->getConvert()->parameters([
            'num_iids' => $id,
            'adzone_id' => $adzone_id,
        ])->text();
        return $res['results']['n_tbk_item'];
    }
549910
public function actionAppendReward($id)
    {
        /** @var Question $model */
        $model = $this->findModel($id);
        if ($model->isAuthor()) {
            $coins = Yii::$app->request->post('coins', 0);
            //此处开始扣钱
            $transaction = Question::getDb()->beginTransaction();
            try {
                if (function_exists('credit')) {
                    credit($model->user_id, 'answer_adopted', -$coins, $model->id, $model->title);
                }

                $model->updateCounters(['price' => $coins]);
                $model->save();
                if (function_exists('doing')) {
                    doing($model->user_id, 'append_reward', get_class($model), $model->id, $model->title, "追加了 " . $coins . " 个积分");
                }
                Yii::$app->session->setFlash('success', 'question Submitted');
                $transaction->commit();
            } catch (\Exception $e) {
                $transaction->rollBack();
                Yii::$app->session->setFlash('error', 'question Submitted');
            }
            return $this->redirect(['view', 'id' => $model->id]);
        } else {
            Yii::$app->session->setFlash('danger', Yii::t('yii', 'You are not allowed to perform this action.'));
            return $this->redirect(['/question/question/view', 'id' => $model->id]);
        }
    }
803007
public function toModelAttribute($id)
	{
		if ($id === null) {
			$id = self::VALUE_NULL;
		}

		if (! array_key_exists($id,	$this->_map) ) {
			throw new Exception('Conversion from SimpleWorkflow failed : no key found for id = '.$id);
		}
		$value = $this->_map[$id];
		return ($value === self::VALUE_NULL ? null : $value);
	}
1302466
public function delZoneRecord($zone, $recordid)
    {
        if (!$recordid) {
            throw new \Exception('missing record id');
        }
        // Make sure we know what zone to target
        if (!isset($this->zones[$zone])) {
            throw new \Exception("unknown zone {$zone} did you call getZones()?");
        }
        $zoneid = $this->zones[$zone]['id'];
        if (!$zoneid) {
            throw new \Exception("could not determine zone id for {$zone}");
        }
        $uri = $this->baseuri.'/zones/'.$zoneid.'/dns_records/'.$recordid;
        $result = $this->httpDelete($uri);

        return $result;
    }
1206187
public function getById($id, $srid = null)
    {
        $rows = $this->getSelectQueryBuilder($srid)
            ->where($this->getUniqueId() . " = :id")
            ->setParameter('id', $id)
            ->execute()
            ->fetchAll();
        $this->prepareResults($rows, $srid);
        return reset($rows);
    }
537096
public function getComponent($id)
    {
        if (isset($this->_components[$id])) {
            return $this->_components[$id];
        }
        if (!isset($this->_componentConfig[$id])) {
            return null;
        }
        $config = $this->_componentConfig[$id];
        if (!isset($config['class'])) {
            throw new Exception('应用组件必须设置"class"');
        }
        $className = $config['class'];
        unset($config['class']);
        /* @var Component $className */
        return $this->_components[$id] = $className::getInstance($config);
    }
1231511
public static function setId($id)
    {
        if (!self::$_unitTestEnabled && defined('SID')) {
            /** @see Zend_Session_Exception */
            // require_once 'Zend/Session/Exception.php';
            throw new Zend_Session_Exception('The session has already been started.  The session id must be set first.');
        }

        if (!self::$_unitTestEnabled && headers_sent($filename, $linenum)) {
            /** @see Zend_Session_Exception */
            // require_once 'Zend/Session/Exception.php';
            throw new Zend_Session_Exception("You must call ".__CLASS__.'::'.__FUNCTION__.
                "() before any output has been sent to the browser; output started in {$filename}/{$linenum}");
        }

        if (!is_string($id) || $id === '') {
            /** @see Zend_Session_Exception */
            // require_once 'Zend/Session/Exception.php';
            throw new Zend_Session_Exception('You must provide a non-empty string as a session identifier.');
        }

        session_id($id);
    }
1331371
public function get($id, $params = null)
    {
        $id = (int)$id;
        if ($id <= 0) {
            throw new Exception('Invalid param id');
        }
        return $this->rest->get("$this->action/$id", $params);
    }
390851
public function findById($id)
    {
        $businessEntity = $this->reader->findById($id);
        if ($businessEntity === null) {
            throw new \Exception('"'.$id.'" does not seems to be a valid BusinessEntity');
        }

        return $businessEntity;
    }
374571
public function get($id)
    {
        if (isset($this->services[$id]) && $this->shareds[$id]) {
            return $this->services[$id];
        }
        
        if (!$this->has($id)) {
            throw new Exception('not exists id: ' . $id);
        }

        // 实例创建的参数
        $args = $this->params[$id];

        $definition = $this->definitions[$id];
        if ($definition instanceof \Closure || (is_string($definition) && function_exists($definition))) {
            // 执行闭包/函数
            $object = $definition(...$args);
        } elseif (is_string($definition)) {
            // 创建类实例
            $object = new $definition(...$args);
        } else {
            throw new Exception('definition error: ' . $id);
        }
        
        if ($this->shareds[$id]) {
            $this->services[$id] = $object;
        }
        
        return $object;
    }
50843
public function edit($id): Response
    {
        if ($objectInfo = $this->model->findFirst($id)) {
            $request = $this->request->getPut();

            if (empty($request)) {
                $request = $this->request->getJsonRawBody(true);
            }
            //update
            if ($objectInfo->update($request, $this->updateFields)) {
                return $this->response($objectInfo->toArray());
            } else {
                //didnt work
                throw new Exception($objectInfo->getMessages()[0]);
            }
        } else {
            throw new Exception('Record not found');
        }
    }
1192333
public function getByID($id)
    {
        $pkey = $this->getPrimaryKey();
        if ($pkey === null)
            throw new DAOException("A primary key is required to select a record by ID");

        // If there's a unary primary key, the value can be specified as a
        // single scalar, rather than an array
        if (count($pkey) === 1 && is_scalar($id))
            foreach ($pkey as $colname => $def)
                $id = [$colname => $id];


        $condition = $this->getSelector($pkey, $id);
        $rec = $this->fetchSingle(QB::where($condition));
        if (empty($rec))
            throw new DAOEXception("Object not found with " . WF::str($id));

        $model = new $this->model_class;
        $model->assignRecord($rec, $this->db);
        return $model;
    }
284287
public function renderZoneView($id)
    {
        if (($model = (new Zone())->find()->joinWith('records')->where(['id' => $id])->one()) === null) {
            throw new NotFoundHttpException('DNS zone does not exist');
        }
        $recordsDataProvider = new ArrayDataProvider(['allModels' => $model->records, 'pagination' => false]);

        return $this->render('/zone/view', [
            'model' => $model,
            'recordsDataProvider' => $recordsDataProvider,
        ]);
    }
207175
public function delCategory($id)
    {
        $where = [];
        if (is_array($id)) {
            $where[] = ['id', 'IN', $id];
        } else {
            $id = (int)$id;
            if (is_numeric($id) && $id > 0) {
                $where[] = ['id', '=', $id];
            } else {
                throw new Exception('删除条件错误');
            }
        }

        if ($this->where($where)->delete() === false) {
            throw new Exception('删除权限分组出错');
        }
        return true;
    }
98816
public function delPermission($id = 0)
    {
        $model = new Permission($this->db);
        try {
            return $model->delPermission($id);
        } catch (Exception $e) {
            throw new Exception($e->getMessage());
        }
    }
1245781
public function getFormattedOffsetById($id)
    {
        switch ($id) {
            case self::DF_ISO_8601_BASIC:
            case self::DF_ISO_8601_EXTENDED:
            case self::DF_RFC_2822:
                $offset = $this->getOffset();
                $offset = intval(floor($offset / 60)); // minutes

                if ($offset === 0) {
                    $offset = 'Z';
                } else {
                    $offset_hours = floor($offset / 60);
                    $offset_minutes = abs($offset % 60);

                    $offset = sprintf(
                        '%+03.0d:%02.0d',
                        $offset_hours,
                        $offset_minutes
                    );
                }

                return $offset;
            default:
                throw new Exception("Unknown offset format for id '$id'.");
        }
    }
104040
public function lock($id)
    {
        $id = (int) $id;
        if ($id <= 0) {
            throw new Exception('Invalid param id');
        }
        return $this->rest->put("$this->action/$id/lock");
    }