本文整理汇总了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);
}
}
示例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.');
}
}
示例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];
}
}