Inheritance: implements Configurable
 /**
  * @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
0
 public function __get($name)
 {
     if (isset($this->_user[$name])) {
         return $this->_user[$name];
     }
     return parent::__get($name);
 }
 public function init()
 {
     parent::init();
     if (!empty($this->fileHash)) {
         $this->fileInfo = FileInfo::findOne(['hash' => $this->fileHash]);
     }
 }
示例#4
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->href === null) {
         throw new InvalidConfigException('The href attribute can not be empty and must be set trough configuration array.');
     }
 }
示例#5
0
 /**
  * @param \phpDocumentor\Reflection\BaseReflector $reflector
  * @param Context $context
  * @param array $config
  */
 public function __construct($reflector = null, $context = null, $config = [])
 {
     parent::__construct($config);
     if ($reflector === null) {
         return;
     }
     // base properties
     $this->name = ltrim($reflector->getName(), '\\');
     $this->startLine = $reflector->getNode()->getAttribute('startLine');
     $this->endLine = $reflector->getNode()->getAttribute('endLine');
     $docblock = $reflector->getDocBlock();
     if ($docblock !== null) {
         $this->shortDescription = ucfirst($docblock->getShortDescription());
         if (empty($this->shortDescription) && !$this instanceof PropertyDoc && $context !== null && $docblock->getTagsByName('inheritdoc') === null) {
             $context->errors[] = ['line' => $this->startLine, 'file' => $this->sourceFile, 'message' => "No short description for " . substr(StringHelper::basename(get_class($this)), 0, -3) . " '{$this->name}'"];
         }
         $this->description = $docblock->getLongDescription()->getContents();
         $this->phpDocContext = $docblock->getContext();
         $this->tags = $docblock->getTags();
         foreach ($this->tags as $i => $tag) {
             if ($tag instanceof SinceTag) {
                 $this->since = $tag->getVersion();
                 unset($this->tags[$i]);
             } elseif ($tag instanceof DeprecatedTag) {
                 $this->deprecatedSince = $tag->getVersion();
                 $this->deprecatedReason = $tag->getDescription();
                 unset($this->tags[$i]);
             }
         }
     } elseif ($context !== null) {
         $context->errors[] = ['line' => $this->startLine, 'file' => $this->sourceFile, 'message' => "No docblock for element '{$this->name}'"];
     }
 }
示例#6
0
 /**
  * @inheritdoc
  * @throws \yii\base\InvalidConfigException
  */
 public function init()
 {
     if ($this->name === null) {
         throw new InvalidConfigException("'name' cannot be null.");
     }
     parent::init();
 }
示例#7
0
文件: Tab.php 项目: itzj86/yii2-dwz
 public function init()
 {
     parent::init();
     if (!(!empty($this->url) xor !empty($this->content))) {
         throw new \yii\base\InvalidConfigException("Url or Content must be exsit one");
     }
 }
示例#8
0
文件: Pubu.php 项目: lxpgw/logger
 /**
  * {@inheritdoc}
  */
 public function init()
 {
     parent::init();
     if (is_null($this->remote)) {
         throw new InvalidConfigException('$remote must be set.');
     }
 }
示例#9
0
 public function __get($property)
 {
     if ($this->isNestedProperty($property)) {
         return $this->getNestedProperty($property);
     }
     return parent::__get($property);
 }
示例#10
0
 public function init()
 {
     $this->_error = true;
     $this->_message = [];
     $this->_format = \yii\web\Response::FORMAT_JSON;
     return parent::init();
 }
 public function init()
 {
     if (!yii::$app->user->isGuest) {
         $this->_userId = yii::$app->user->id;
     }
     return parent::init();
 }
示例#12
0
 public function init()
 {
     parent::init();
     $configFile = Yii::getAlias($this->configFileName);
     $this->config = (require $configFile);
     $this->instance = new \OneLogin_Saml2_Auth($this->config);
 }
示例#13
0
 public function init()
 {
     parent::init();
     if (!isset($this->key)) {
         throw new InvalidConfigException('JWPlayer: License key missing!');
     }
 }
 /**
  *
  */
 public function init()
 {
     parent::init();
     if ($this->placeholder) {
         $this->placeholder = Yii::createObject($this->placeholder);
     }
 }
示例#15
0
 /**
  * @param string|mixed[] $config the configuration of [[\romkaChev\yii2\swiper\Slide]]
  *                               You can create slide just from string
  *                               For example:
  *
  *                               ~~~
  *                                 $slide = new \romkaChev\yii2\swiper\Slide('slide content');
  *                               ~~~
  *
  *
  *                               Also you can create slide from array or strings and
  *                               they will be merged into one string
  *                               For example:
  *
  *                               ~~~
  *                                $slide = new \romkaChev\yii2\swiper\Slide([
  *                                    'content' => [
  *                                        '<h1>Title</h1>',
  *                                        '<h3>Subtitle</h3>',
  *                                        '<p>Main content</p>'
  *                                    ]
  *                                ]);
  *                               ~~~
  *
  * @see \romkaChev\yii2\swiper\Slide::$background
  * @see \romkaChev\yii2\swiper\Slide::$hash
  * @see \romkaChev\yii2\swiper\Slide::$content
  */
 public function __construct($config = [])
 {
     $config = is_string($config) ? [self::CONTENT => $config] : $config;
     $config[self::CONTENT] = ArrayHelper::getValue($config, self::CONTENT, null);
     $config[self::CONTENT] = is_array($config[self::CONTENT]) ? implode('', $config[self::CONTENT]) : $config[self::CONTENT];
     parent::__construct($config);
 }
示例#16
0
 /**
  * @inheritdoc
  * @throws \BadMethodCallException
  */
 public function init()
 {
     parent::init();
     if (exec('command -v java >/dev/null && echo "yes" || echo "no"') == 'no') {
         throw new \BadMethodCallException('Java Not Installed');
     }
 }
示例#17
0
 public function init()
 {
     parent::init();
     if ($this->childOf === null || $this->title === null || $this->alias === null) {
         throw new Exception("The properties childOf, title and alias must be defined to inject a new Item.");
     }
 }
示例#18
0
 public function init()
 {
     parent::init();
     if ($this->properties === TRUE && \Yii::$container->has('jarekkozak\\sys\\IProperties')) {
         $this->setProperties(\Yii::$container->get('jarekkozak\\sys\\IProperties'));
     }
 }
示例#19
0
 public function __construct(\luya\web\Request $request, \luya\web\UrlManager $urlManager, array $config = [])
 {
     $this->request = $request;
     $this->urlManager = $urlManager;
     // parent object
     parent::__construct($config);
 }
示例#20
0
 /**
  * Costruisce una nuova istanza della classe e imposta le proprietà fondamentali.
  * @param type $id Id applicazione
  * @param type $basePath Cartella root dell'applicazione
  * @param type $filesSubfolder Sottocartella per i files di configurazione
  */
 public function __construct($id, $basePath, $filesSubfolder = null)
 {
     $this->_id = $id;
     $this->_basePath = $basePath;
     $this->_configFolder = dirname(__FILE__) . '/../../../config/' . ($filesSubfolder ? $filesSubfolder . '/' : '');
     parent::__construct();
 }
示例#21
0
 public function init()
 {
     parent::init();
     if (!$this->masker instanceof NumeratorMasker || !$this->template instanceof NumeratorTemplate || !($this->template->mask === $this->masker->mask)) {
         throw new InvalidConfigException("Properties masker and template need to be set and their properties mask must be equal.");
     }
 }
 /**
  * Check whether we have a plugin installed with that name previous firing up the call
  *
  * @param string $name
  *
  * @return mixed|void
  */
 public function __get($name)
 {
     if (ArrayHelper::keyExists($name, $this->getInstalledPlugins())) {
         return $this->getPlugin($name);
     }
     return parent::__get($name);
 }
示例#23
0
 /**
  * @throws \yii\base\InvalidConfigException
  */
 public function init()
 {
     foreach ($this->locators as $k => $config) {
         $this->locators[$k] = Instance::ensure($config, 'trntv\\bus\\interfaces\\HandlerLocator');
     }
     parent::init();
 }
示例#24
0
 /**
  * (non-PHPdoc)
  * @see \yii\base\Object::__get()
  */
 public function __get($name)
 {
     if (in_array($name, $this->options)) {
         return $this->config->{$name};
     }
     return parent::__get($name);
 }
示例#25
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (!$this->id) {
         $this->id = Inflector::slug($this->label);
     }
 }
示例#26
0
 /**
  * Initializes the application component
  *
  * @throws InvalidConfigException
  */
 public function init()
 {
     parent::init();
     if (!class_exists('\\AmoCRM\\Client')) {
         throw new InvalidConfigException('AmoCRM not found. Try to install it via composer require dotzero/amocrm');
     }
 }
示例#27
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->module === null) {
         throw new Exception('The ActiveWindow property \'module\' of ' . get_called_class() . ' can not be null. You have to defined the module in where the ActiveWindow is defined. For example `public $module = \'@admin\';`');
     }
 }
示例#28
0
 /**
  * @param string $name
  * @param mixed $value
  */
 public function __set($name, $value)
 {
     try {
         parent::__set($name, $value);
     } catch (UnknownPropertyException $e) {
     }
 }
 public function init()
 {
     if (yii::$app->user->isGuest) {
         throw new \yii\web\HttpException(500, sprintf('Not available to guest users'));
     }
     return parent::init();
 }
 public function init()
 {
     parent::init();
     $this->isGlobal = $this->name === 'global';
     $this->isCustomization = $this->name === 'custom';
     $this->isInternal = $this->name === 'internal';
 }