Esempio n. 1
0
 /**
  * Initializes this component.
  */
 public function init()
 {
     parent::init();
     if ($this->sourceLanguage === null) {
         $this->sourceLanguage = Leaps::$app->sourceLanguage;
     }
 }
Esempio n. 2
0
 /**
  * Initializes the component by configuring the default message categories.
  */
 public function init()
 {
     parent::init();
     if (!isset($this->translations['leaps']) && !isset($this->translations['leaps*'])) {
         $this->translations['leaps'] = ['className' => 'Leaps\\I18n\\PhpMessageSource', 'sourceLanguage' => 'en-US', 'basePath' => '@Leaps/Message'];
     }
     if (!isset($this->translations['app']) && !isset($this->translations['app*'])) {
         $this->translations['app'] = ['className' => 'Leaps\\I18n\\PhpMessageSource', 'sourceLanguage' => Leaps::$app->sourceLanguage, 'basePath' => '@app/Message'];
     }
 }
Esempio n. 3
0
 /**
  * Initializes the application component.
  * This method is required by IApplicationComponent and is invoked by application.
  */
 public function init()
 {
     parent::init();
     register_shutdown_function([$this, 'close']);
 }
Esempio n. 4
0
 /**
  * 初始化
  *
  * @throws InvalidConfigException if [[basePath]] is invalid
  */
 public function init()
 {
     parent::init();
     $this->basePath = Leaps::getAlias($this->basePath);
     if (!is_dir($this->basePath)) {
         throw new InvalidConfigException("The directory does not exist: {$this->basePath}");
     } elseif (!is_writable($this->basePath)) {
         throw new InvalidConfigException("The directory is not writable by the Web process: {$this->basePath}");
     } else {
         $this->basePath = realpath($this->basePath);
     }
     $this->baseUrl = rtrim(Leaps::getAlias($this->baseUrl), '/');
 }
Esempio n. 5
0
 /**
  * Initializes the migration.
  * This method will set [[db]] to be the 'db' application component, if it is `null`.
  */
 public function init()
 {
     parent::init();
     $this->db = Instance::ensure($this->db, Connection::className());
     $this->db->getSchema()->refresh();
 }
Esempio n. 6
0
 /**
  * Initializes UrlManager.
  */
 public function init()
 {
     parent::init();
     if (!$this->enablePrettyUrl || empty($this->rules)) {
         return;
     }
     if (is_string($this->cache)) {
         $this->cache = Leaps::$app->get($this->cache, false);
     }
     if ($this->cache instanceof Cache) {
         $cacheKey = __CLASS__;
         $hash = md5(json_encode($this->rules));
         if (($data = $this->cache->get($cacheKey)) !== false && isset($data[1]) && $data[1] === $hash) {
             $this->rules = $data[0];
         } else {
             $this->rules = $this->buildRules($this->rules);
             $this->cache->set($cacheKey, [$this->rules, $hash]);
         }
     } else {
         $this->rules = $this->buildRules($this->rules);
     }
 }
Esempio n. 7
0
 /**
  * 初始化
  */
 public function init()
 {
     parent::init();
     if ($this->identityClass === null) {
         throw new InvalidConfigException('User::identityClass must be set.');
     }
     if ($this->enableAutoLogin && !isset($this->identityCookie['name'])) {
         throw new InvalidConfigException('User::identityCookie must contain the "name" element.');
     }
 }
Esempio n. 8
0
 /**
  *
  * @param string $id the ID of this controller.
  * @param Module $module the module that this controller belongs to.
  * @param array $config name-value pairs that will be used to initialize the object properties.
  */
 public function __construct($id, $module, $config = [])
 {
     $this->id = $id;
     $this->module = $module;
     parent::__construct($config);
 }
Esempio n. 9
0
 /**
  * Checks if a property value is null.
  * This method overrides the parent implementation by checking if the named component is loaded.
  *
  * @param string $name the property name or the event name
  * @return boolean whether the property value is null
  */
 public function __isset($name)
 {
     if ($this->has($name, true)) {
         return true;
     } else {
         return parent::__isset($name);
     }
 }
Esempio n. 10
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     foreach ($this->targets as $name => $target) {
         if (!$target instanceof Target) {
             $this->targets[$name] = Leaps::createObject($target);
         }
     }
 }
Esempio n. 11
0
 /**
  * Constructor.
  *
  * @param string $id the ID of this action
  * @param Controller $controller the controller that owns this action
  * @param array $config name-value pairs that will be used to initialize the object properties
  */
 public function __construct($id, $controller, $config = [])
 {
     $this->id = $id;
     $this->controller = $controller;
     parent::__construct($config);
 }
Esempio n. 12
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $this->attributes = (array) $this->attributes;
     $this->on = (array) $this->on;
     $this->except = (array) $this->except;
 }
Esempio n. 13
0
 /**
  * Initializes the logger by registering [[flush()]] as a shutdown function.
  */
 public function init()
 {
     parent::init();
     register_shutdown_function(function () {
         // make regular flush before other shutdown functions, which allows session data collection and so on
         $this->flush();
         // make sure log entries written by shutdown functions are also flushed
         // ensure "flush()" is called last when there are multiple shutdown functions
         register_shutdown_function([$this, 'flush'], true);
     });
 }
Esempio n. 14
0
 /**
  * 构造方法
  *
  * @param array $config name-value pairs that will be used to initialize the object properties.
  *        Note that the configuration must contain both [[id]] and [[basePath]].
  * @throws InvalidConfigException if either [[id]] or [[basePath]] configuration is missing.
  */
 public function __construct($config = [])
 {
     Leaps::$app = $this;
     $this->setInstance($this);
     $this->state = self::STATE_BEGIN;
     $this->preInit($config);
     $this->registerErrorHandler($config);
     Service::__construct($config);
 }
Esempio n. 15
0
 /**
  * Initializes the view component.
  */
 public function init()
 {
     parent::init();
     if (is_array($this->theme)) {
         if (!isset($this->theme['className'])) {
             $this->theme['className'] = 'Leaps\\Base\\Theme';
         }
         $this->theme = Leaps::createObject($this->theme);
     } elseif (is_string($this->theme)) {
         $this->theme = Leaps::createObject($this->theme);
     }
 }