查看文章
@param int $id
@param string $uuid
@return string|\yii\web\Response
@throws NotFoundHttpException
351711
public function actionView($id = null, $uuid = null)
    {
        if (!is_null($id)) {
            $model = $this->findModel($id);
        } else {
            $model = $this->findModelByUUID($uuid);
        }
        if ($model && ($model->isActive || $model->isAuthor)) {
            if (!$model->isAuthor) {
                Yii::$app->queue->push(new UpdateCounterJob(['id' => $model->id, 'field' => 'views', 'counter' => 1]));
            }
            return $this->render('view', [
                'model' => $model,
            ]);
        } else {
            Yii::$app->session->setFlash('success', Yii::t('article', 'Article does not exist.'));
            return $this->redirect(['index',]);
        }
    }
214781
protected function getComment($id)
    {
        $comment = $this->commentManager->find($id);

        if (null === $comment) {
            throw new NotFoundHttpException(sprintf('Comment (%d) not found', $id));
        }

        return $comment;
    }
222376
public function patch($uuid, Request $request)
    {
        $model = static::$model::findOrFail($uuid);

        $this->authorizeUserAction('update', $model);

        $this->restfulService->validateResourceUpdate($model, $request->input());

        $this->restfulService->patch($model, $request->input());

        if ($this->shouldTransform()) {
            $response = $this->response->item($model, $this->getTransformer());
        } else {
            $response = $model;
        }

        return $response;
    }
44538
public function actionUpdate($id)
    {
        $model = $this->findModel($id);
        $ruleKeyword = new ReplyRuleKeyword();
        $ruleKeywords = $model->keywords;
        if ($model->load(Yii::$app->request->post())) {
            $model->wid = $this->getWechat()->id;
            if ($this->save($model, $ruleKeyword, $ruleKeywords)) {
                return $this->flash('修改成功!', 'success', ['update', 'id' => $model->id]);
            }
        }
        return $this->render('update', [
            'model' => $model,
            'ruleKeyword' => $ruleKeyword,
            'ruleKeywords' => $ruleKeywords
        ]);
    }
546611
public function findDocumentById($id)
    {
        $response = $this->request('GET', '/' . $id);
        if ($response->getStatusCode() !== 200) {
            return null;
        }

        return $this->documentFactory->createFromResponse($this, $id, $response);
    }
875402
public function findInvoiceOrFail(string $id)
    {
        $invoice = $this->findInvoice($id);

        if (is_null($invoice)) {
            throw new NotFoundHttpException('The requested page does not exist.');
        }

        return $invoice;
    }
1031555
protected function getCategory($id)
    {
        $category = $this->categoryManager->find($id);

        if (null === $category) {
            throw new NotFoundHttpException(sprintf('Category (%d) not found', $id));
        }

        return $category;
    }
69504
public function openEditorAction($id)
    {
        $media = $this->getMedia($id);

        if (!$this->isEditable($media)) {
            throw new NotFoundHttpException('The media is not editable');
        }

        return new Response($this->templating->render('@SonataMedia/Extra/pixlr_editor.html.twig', [
            'media' => $media,
            'admin_pool' => $this->container->get('sonata.admin.pool'),
        ]));
    }
999870
public function show($uuid)
    {
        $response = $this->httpClient->get($this->getResourceUrl($uuid));

        return ContainerResponse::createFromHttpResponse($response);
    }
308099
public function findListByUuid($listUuid)
    {
        $sql = 'SELECT 
                    `uuid`,
                    `list`,
                    `body`
                    FROM `'.self::LIST_ELEMENT_TABLE_NAME.'` 
                    WHERE `list` = :list';
        $stmt = $this->pdo->prepare($sql);
        $stmt->bindParam('list', $listUuid);
        $stmt->execute();

        $list = $stmt->fetchAll(
            \PDO::FETCH_ASSOC
        );

        if (count($list) === 0) {
            return [];
        }

        foreach ($list as $item) {
            $items[$item['uuid']] = unserialize($item['body']);
        }

        return $items;
    }
53325
protected function findModel($id)
    {
        //$model = News::findOne($id);
        $model = $this->module->model('News')->findOne($id);
        if ($model !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException(Yii::t($this->tc,'The requested news does not exist'));
        }
    }
1274014
public function actionView($id)
    {
        try{

            $request = \Yii::$app->request;
            if ($request->getIsOptions()) {
                return $this->ResponseOptions($this->verbs()['view']);
            }
            $model = $this->findModel($id);
            if($model!=null){
                $result= ['success'=>true,'rules'=>$model];
            } else {
                $result= ['success'=>false,'message'=>'没有对应规则'];
            }

            return $result;
        }catch(Exception $e){
            throw new Exception($e);
        }
        //return $this->render('view', ['model' => $model]);
    }
1076057
public function getContent(UuidInterface $uuid)
    {
        $formatter = self::$formatters[$uuid->getVersion()];

        return $formatter->getContent($uuid);
    }
1013434
public function findModel($id)
    {
        if (($model = Category::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException (Yii::t('system', 'The requested page does not exist.'));
        }
    }
1016162
public function actionFrontend ($id)
		{
			$page = Page::find()->where([ 'guid' => $id ])->one();

			if ($page === null)
			{
				throw new \yii\web\HttpException(404);
			}
			$this->setTitle($page->title);
			$this->data('page', $page);
			$this->_tpl = '@pageViews/page';
		}
44731
protected function findModel($id)
    {
        $item = Yii::$app->authManager->getRule($id);
        if ($item) {
            return new BizRule($item);
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }
434829
protected function getPage($id)
    {
        $page = $this->pageManager->findOneBy(['id' => $id]);

        if (null === $page) {
            throw new NotFoundHttpException(sprintf('Page (%d) not found', $id));
        }

        return $page;
    }