Inheritance: extends Object
 public function triggerComponentEvent($name, Event $event, Component $component)
 {
     if ($component === null) {
         return;
     }
     $component->trigger($name, $event);
 }
Exemple #2
0
 /**
  * @param Component $component
  * @return \skeeks\sx\validate\Result
  */
 public function validate($component)
 {
     if (!$component instanceof ActiveRecord) {
         return $this->_bad(\Yii::t('app', "Object: {class} must be inherited from: {parent}", ['class' => $component->className(), 'parent' => ActiveRecord::className()]));
     }
     return !$component->isNewRecord ? $this->_ok() : $this->_bad(\Yii::t('app', "The object must already be saved"));
 }
 /**
  * Getting behavior object from given model
  *
  * @param Component $model
  * @return SeoBehavior
  * @throws InvalidConfigException if model don't have our SeoBehavior
  */
 protected static function behavior(Component $model)
 {
     foreach ($model->getBehaviors() as $b) {
         if ($b instanceof SeoBehavior) {
             return $b;
         }
     }
     throw new InvalidConfigException('Model ' . $model->className() . ' must have SeoBehavior');
 }
 protected function attachSupportBehaviors(Component $owner)
 {
     $rangeAttributes = [];
     foreach ($this->attributes as $attribute => $dbAttribute) {
         $rangeAttributes[] = $attribute . '_start';
         $rangeAttributes[] = $attribute . '_end';
         $owner->attachBehavior(0, ['class' => DateTimeRangeBehavior::class, 'startAttribute' => $attribute . '_start_local', 'endAttribute' => $attribute . '_end_local', 'targetAttribute' => $attribute . '_range']);
     }
     $owner->attachBehavior(0, ['class' => DateTimeBehavior::class, 'originalFormat' => ['date', 'yyyy-MM-dd'], 'targetFormat' => ['date', 'dd.MM.yyyy'], 'attributes' => $rangeAttributes]);
 }
Exemple #5
0
 public function init()
 {
     parent::init();
     if (!$this->executePath) {
         $this->executePath = \Yii::getAlias('@app');
     }
 }
Exemple #6
0
 public function init()
 {
     parent::init();
     //Merge main extension config with local extension config
     $config = (include dirname(__FILE__) . '/config/main.php');
     foreach ($config as $key => $value) {
         if (is_array($value)) {
             $this->{$key} = ArrayHelper::merge($value, $this->{$key});
         } elseif (null === $this->{$key}) {
             $this->{$key} = $value;
         }
     }
     if (Yii::$app instanceof Application) {
         //Merge commands map
         Yii::$app->controllerMap = ArrayHelper::merge($this->commandMap, Yii::$app->controllerMap);
         Yii::$app->controllerMap = array_filter(Yii::$app->controllerMap);
     }
     Yii::$app->setComponents($this->components);
     //Set components
     if (count($this->components)) {
         $exists = Yii::$app->getComponents(false);
         foreach ($this->components as $component => $params) {
             if (isset($exists[$component]) && is_object($exists[$component])) {
                 unset($this->components[$component]);
             } elseif (isset($exists[$component])) {
                 $this->components[$component] = ArrayHelper::merge($params, $exists[$component]);
             }
         }
         Yii::$app->setComponents($this->components, false);
     }
     Yii::setAlias('@yiicod', realpath(dirname(__FILE__) . '/..'));
 }
Exemple #7
0
 public function init()
 {
     parent::init();
     if (Yii::$app->view !== null) {
         Yii::$app->view->on(yii\web\View::EVENT_BEGIN_PAGE, [$this, 'eventSetMeta']);
     }
 }
Exemple #8
0
 public function init()
 {
     parent::init();
     $this->module = \kepco\Module::getInstance();
     $this->client = new \GuzzleHttp\Client(['base_uri' => 'http://srm.kepco.net/', 'cookies' => true, 'allow_redirects' => false, 'headers' => ['User-Agent' => 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36', 'Cookie' => $this->cookie, 'X-CSRF-TOKEN' => $this->token]]);
     $this->sub = \Yii::createObject(['class' => \kepco\Redis::className(), 'hostname' => $this->module->redis_server]);
 }
 /**
  * Connection constructor.
  *
  * @param XmlRpcClient $client
  * @param array        $config
  */
 public function __construct(XmlRpcClient $client, array $config = [])
 {
     parent::__construct($config);
     $this->_connection = $client;
     $this->_initConnection();
     $this->checkConnection();
 }
Exemple #10
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (!empty($this->preLoad)) {
         $this->load($this->preLoad);
     }
 }
Exemple #11
0
 public function init()
 {
     parent::init();
     if ($this->storeInSession) {
         $this->loadFromSession();
     }
 }
 public function init()
 {
     parent::init();
     $this->_api = new \Clickatell\Api\ClickatellHttp($this->username, $this->password, $this->apiID);
     $this->_api->secure($this->secure);
     $this->setExtraParameters();
 }
Exemple #13
0
 /**
  * Initializes the application component.
  */
 public function init()
 {
     parent::init();
     if ($this->identityClass === null) {
         throw new InvalidConfigException('User::identityClass must be set.');
     }
 }
Exemple #14
0
 /**
  * Init
  */
 public function init()
 {
     if ($this->path === null) {
         $this->setPath();
     }
     parent::init();
 }
Exemple #15
0
 public function init()
 {
     parent::init();
     if (!$this->time instanceof \DateTime) {
         throw new \yii\base\InvalidConfigException('AbstractTask::$time must be an instance of \\DateTime.');
     }
 }
Exemple #16
0
 /**
  * Initializes this component.
  */
 public function init()
 {
     parent::init();
     if ($this->sourceLanguage === null) {
         $this->sourceLanguage = Yii::$app->sourceLanguage;
     }
 }
 public function init()
 {
     parent::init();
     if (!isset($this->imagine)) {
         $this->imagine = $this->createImagine();
     }
 }
Exemple #18
0
 /**
  * Initializes the object
  */
 public function init()
 {
     parent::init();
     if (substr($this->iniDirectory, 0, 1) === '@') {
         $this->iniDirectory = Yii::getAlias($this->iniDirectory);
     }
 }
Exemple #19
0
 public function init()
 {
     parent::init();
     $this->module = \ebidlh\Module::getInstance();
     $this->pub = \Yii::createObject(['class' => \ebidlh\Redis::className(), 'hostname' => $this->module->redis_server]);
     $this->sub = \Yii::createObject(['class' => \ebidlh\Redis::className(), 'hostname' => $this->module->redis_server]);
 }
Exemple #20
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (Yii::$app->user->isGuest) {
         throw new ErrorException('is guest');
     }
 }
 public function init()
 {
     parent::init();
     $this->types = yii\helpers\ArrayHelper::merge($this->defaultTypes, $this->types);
     // pre-init string
     $this->types['string'] = Yii::createObject($this->types['string']);
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (!isset(Yii::$app->params['languages'])) {
         throw new \yii\base\InvalidConfigException("You must define Yii::\$app->params['languages'] array");
     }
     foreach (Yii::$app->params['languages'] as $code => $language) {
         if (is_array($language)) {
             $this->_languages[$code] = $language;
         } else {
             $this->_languages[$code] = ['queryValue' => $language, 'cookieValue' => $language, 'sessionValue' => $language];
         }
     }
     $queryValue = Yii::$app->request->get($this->queryParam);
     $cookieValue = Yii::$app->request->cookies->getValue($this->cookieParam);
     $sessionValue = Yii::$app->session->get($this->sessionParam);
     if ($queryValue !== null) {
         $code = $this->getCode('queryValue', $queryValue);
         $config = ['name' => $this->cookieParam, 'value' => $this->_languages[$code]['cookieValue'], 'expire' => time() + 365 * 24 * 60 * 60];
         $config = array_merge($config, $this->cookieParams);
         Yii::$app->response->cookies->add(new Cookie($config));
         Yii::$app->session->set($this->sessionParam, $this->_languages[$code]['sessionValue']);
         Yii::$app->language = $code;
     } elseif ($cookieValue !== null && $cookieValue !== $sessionValue) {
         $code = $this->getCode('cookieValue', $cookieValue);
         Yii::$app->session->set($this->sessionParam, $this->_languages[$code]['sessionValue']);
         Yii::$app->language = $code;
     } elseif ($sessionValue !== null) {
         $code = $this->getCode('sessionValue', $sessionValue);
         Yii::$app->language = $code;
     }
 }
 public function __construct($config = array())
 {
     self::$plugins = array_diff(scandir(__DIR__ . '/plugins/'), array('..', '.'));
     $provider = ArrayHelper::getValue($config, 'config.provider');
     if (isset($provider)) {
         if (ArrayHelper::isIn($provider . '.php', self::$plugins)) {
             require __DIR__ . '/plugins/' . $provider . '.php';
             $format = ArrayHelper::getValue($config, 'config.return_formats');
             if (isset($format)) {
                 if (ArrayHelper::isIn($format, ArrayHelper::getValue($plugin, 'accepted_formats'))) {
                     self::$return_formats = $format;
                 } else {
                     self::$return_formats = ArrayHelper::getValue($plugin, 'default_accepted_format');
                 }
             }
             self::$provider = $plugin;
             self::$api_key = ArrayHelper::getValue($config, 'config.api_key', NULL);
         } else {
             throw new HttpException(404, 'The requested Item could not be found.');
         }
     } else {
         require __DIR__ . '/plugins/geoplugin.php';
         self::$provider = $plugin;
         self::$return_formats = $plugin['default_accepted_format'];
     }
     return parent::__construct($config);
 }
 public function init()
 {
     parent::init();
     if ($this->modulename == null) {
         throw new InvalidParamException('modulename parameter for plathir\\settings\\components cannot set.');
     }
 }
Exemple #25
0
 public function init()
 {
     parent::init();
     if (!in_array($this->defaultLocale, $this->enableLocales)) {
         throw new \yii\base\InvalidParamException('Default locale must be contained in the enable locales list.');
     }
 }
 /**
  * Initializes a new event tracker object.
  *
  * @throws InvalidConfigException If invalid configurations are set.
  */
 public function init()
 {
     parent::init();
     if (null === $this->types_config || null === $this->keys_config) {
         throw new InvalidConfigException('Both $types_config and $keys_config should be set for the EventTracker');
     }
     $event_types_instance = Yii::createObject($this->types_config);
     if (!$event_types_instance instanceof BaseEventTypes) {
         throw new InvalidConfigException('$types_config should indicate a class subclassing BaseEventTypes to specify the event types.');
     }
     $state_keys_instance = Yii::createObject($this->keys_config);
     if (!$state_keys_instance instanceof BaseStateKeys) {
         throw new InvalidConfigException('$keys_config should indicate a class subclassing BaseStateKeys to specify the state keys.');
     }
     $this->_state_keys = $state_keys_instance;
     $this->_event_types = $event_types_instance;
     $this->db = Instance::ensure($this->db, Connection::className());
     if (null !== $this->post_event_handler) {
         $handler = Yii::createObject($this->post_event_handler);
         if (!$handler instanceof PostEventInterface) {
             throw new InvalidConfigException('$post_event_handler should indicate a class implementing the PostEventInterface.');
         }
         $this->_post_event_handler = $handler;
     }
     EventTrackerEvent::$db = $this->db;
     EventTrackerEvent::$table = $this->event_table;
 }
Exemple #27
0
 /**
  * @inheritDoc
  */
 public function init()
 {
     parent::init();
     if (!$this->client) {
         throw new InvalidConfigException(\Yii::t('yii', 'AMQP client should be specified'));
     }
     if ($this->name) {
         $this->queueName = $this->queueName ?: $this->name;
         $this->exchangeName = $this->exchangeName ?: $this->name;
     }
     if (!$this->exchangeName) {
         throw new InvalidConfigException(\Yii::t('yii', 'Exchange name should be specified'));
     }
     if (!$this->queueName) {
         throw new InvalidConfigException(\Yii::t('yii', 'Queue name should be specified'));
     }
     if (!$this->client->isConnected()) {
         $this->client->connect();
     }
     $this->channel = $this->client->newChannel();
     $this->exchange = $this->client->newExchange($this->channel, $this->messageType);
     $this->queue = $this->client->newQueue($this->channel, $this->messageType);
     $this->exchange->setName($this->exchangeName);
     $this->exchange->setFlags($this->exchangeFlags);
     $this->exchange->setType($this->exchangeType);
     $this->exchange->declareExchange();
     $this->queue->setName($this->queueName);
     $this->queue->setFlags($this->queueFlags);
     $this->queue->declareQueue();
     $this->queue->bind($this->exchange, $this->routingKey, $this->queueBindArguments);
 }
 public function init()
 {
     parent::init();
     if (empty($this->_list)) {
         $this->_list = ['@nullref/cms/views/layouts/clear' => Yii::t('cms', 'Base layout')];
     }
 }
Exemple #29
0
 /**
  * Initialize the component
  *
  * @throws \yii\base\InvalidConfigException
  */
 public function init()
 {
     parent::init();
     if (is_string($this->cache)) {
         $this->cache = Yii::$app->get($this->cache, false);
     }
 }
Exemple #30
0
 public function __isset($name)
 {
     if ($name == 'jsVar') {
         return isset($this->_jsVar);
     }
     return parent::__isset($name);
 }