當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Object::canGetProperty方法代碼示例

本文整理匯總了PHP中yii\base\Object::canGetProperty方法的典型用法代碼示例。如果您正苦於以下問題:PHP Object::canGetProperty方法的具體用法?PHP Object::canGetProperty怎麽用?PHP Object::canGetProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\base\Object的用法示例。


在下文中一共展示了Object::canGetProperty方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 /**
  * @return string
  * @throws NotAcceptableHttpException
  */
 public function run()
 {
     if (!Yii::$app->request->isAjax) {
         throw new NotAcceptableHttpException('This action AJAX only!');
     }
     $post = Yii::$app->request->post();
     $keys = array_keys($post);
     $formName = $keys[0];
     if (!isset($post[$formName][$this->textFormatField])) {
         throw new InvalidParamException('Invalid POST data.');
     }
     $format = $post[$formName][$this->textFormatField];
     $text = $post[$formName][$this->textField];
     if ($this->context === null) {
         $this->context = Yii::$app->controller;
         if (!$this->context->canGetProperty('textFormats') || !$this->context->canGetProperty('textEditorWidgetOptions')) {
             $this->context = Yii::$app->controller->module;
         }
     }
     if (!$this->context->canGetProperty('textFormats') || !$this->context->canGetProperty('textEditorWidgetOptions')) {
         throw new InvalidParamException('Invalid context. Add TextFormatsBehavior to module.');
     }
     $formats = $this->context->textFormats;
     if (!isset($formats[$format])) {
         throw new InvalidParamException('Format not found.');
     }
     $params = ['fieldName' => $formName . '[' . $this->textField . ']', 'text' => $text, 'formatInfo' => $formats[$format], 'widgetOptions' => $this->context->textEditorWidgetOptions];
     if ($this->view) {
         return $this->controller->renderAjax($this->view, $params);
     } else {
         return $this->controller->renderAjax('@vendor/maddoger/yii2-textformats/views/changeFormat.php', $params);
     }
 }
開發者ID:maddoger,項目名稱:yii2-textformats,代碼行數:37,代碼來源:ChangeFormatAction.php

示例2: init

 /**
  * @throws \yii\base\InvalidConfigException
  */
 public function init()
 {
     parent::init();
     if (!$this->changeFormatMessage) {
         $this->changeFormatMessage = Yii::t('app', 'Are you sure want to change text format and load another editor?');
     }
     if (!$this->changeFormatUrl) {
         $this->changeFormatUrl = ['change-format'];
     }
     if ($this->context === null) {
         $this->context = Yii::$app->controller;
         if (!$this->context->canGetProperty('textFormats') || !$this->context->canGetProperty('textEditorWidgetOptions')) {
             $this->context = Yii::$app->controller->module;
         }
     }
     if (!$this->context->canGetProperty('textFormats') || !$this->context->canGetProperty('textEditorWidgetOptions')) {
         throw new InvalidParamException('Invalid context. Add TextFormatsBehavior to module.');
     }
 }
開發者ID:maddoger,項目名稱:yii2-textformats,代碼行數:22,代碼來源:FormatDropdown.php

示例3: init

 /**
  * @throws \yii\base\InvalidConfigException
  */
 public function init()
 {
     parent::init();
     if (!$this->format && $this->hasModel() && $this->formatAttribute) {
         $this->format = $this->model->{$this->formatAttribute};
     }
     if ($this->context === null) {
         $this->context = Yii::$app->controller;
         if (!$this->context->canGetProperty('textFormats') || !$this->context->canGetProperty('textEditorWidgetOptions')) {
             $this->context = Yii::$app->controller->module;
         }
     }
     if (!$this->context->canGetProperty('textFormats') || !$this->context->canGetProperty('textEditorWidgetOptions')) {
         throw new InvalidParamException('Invalid context. Add TextFormatsBehavior to module.');
     }
     if ($this->format && !is_array($this->format) && $this->context) {
         if (!isset($this->context->textFormats[$this->format])) {
             throw new InvalidParamException('Format not found.');
         }
         $this->format = $this->context->textFormats[$this->format];
     }
 }
開發者ID:maddoger,項目名稱:yii2-textformats,代碼行數:25,代碼來源:TextEditor.php


注:本文中的yii\base\Object::canGetProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。