当前位置: 首页>>代码示例>>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;未经允许,请勿转载。