Exemplo n.º 1
0
 public function init()
 {
     $path = dirname(__FILE__) . '/lib/google-api-php-client/src';
     set_include_path(get_include_path() . PATH_SEPARATOR . $path);
     require_once 'Google_Client.php';
     parent::init();
 }
Exemplo n.º 2
0
 public function __call($name, $parameters)
 {
     if (method_exists($this->_api, $name)) {
         return call_user_func_array(array($this->_api, $name), $parameters);
     }
     return parent::__call($name, $parameters);
 }
Exemplo n.º 3
0
 /**
  * Panel initialization.
  * Generate unique tag for page. Attach panels, log watcher. Register scripts for printing debug panel.
  */
 public function init()
 {
     parent::init();
     if (!$this->enabled) {
         return;
     }
     Yii::setPathOfAlias('yii2-debug', dirname(__FILE__));
     Yii::app()->setImport(array('yii2-debug.*', 'yii2-debug.panels.*'));
     if ($this->logPath === null) {
         $this->logPath = Yii::app()->getRuntimePath() . '/debug';
     }
     $panels = array();
     foreach (CMap::mergeArray($this->corePanels(), $this->panels) as $id => $config) {
         if (!isset($config['highlightCode'])) {
             $config['highlightCode'] = $this->highlightCode;
         }
         $panels[$id] = Yii::createComponent($config, $this, $id);
     }
     $this->panels = $panels;
     Yii::app()->setModules(array($this->moduleId => array('class' => 'Yii2DebugModule', 'owner' => $this)));
     if ($this->internalUrls && Yii::app()->getUrlManager()->urlFormat == 'path') {
         $rules = array();
         foreach ($this->coreUrlRules() as $key => $value) {
             $rules[$this->moduleId . '/' . $key] = $this->moduleId . '/' . $value;
         }
         Yii::app()->getUrlManager()->addRules($rules, false);
     }
     Yii::app()->attachEventHandler('onEndRequest', array($this, 'onEndRequest'));
     $this->initToolbar();
 }
Exemplo n.º 4
0
 /**
  * Init
  * 
  * @throws CException
  */
 public function init()
 {
     if (!function_exists('curl_init')) {
         throw new CException('Для работы расширения требуется cURL');
     }
     parent::init();
 }
Exemplo n.º 5
0
 public function init()
 {
     if (!function_exists("imagecreatetruecolor")) {
         throw new Exception("使用这个类,需要启用GD库", 500);
     }
     parent::init();
 }
Exemplo n.º 6
0
 /**
  * Set default gateway from config
  */
 public function init()
 {
     if ($this->activeGateway === null && $this->defaultGateway !== null) {
         $this->setGateway($this->defaultGateway);
     }
     parent::init();
 }
Exemplo n.º 7
0
 /**
  * Initializes the application component.
  *
  * @throws CException
  */
 public function init()
 {
     parent::init();
     // adding LessPhp library directory to include path
     Yii::import($this->lessphpDir . '.*');
     // including LessPhp class
     require_once 'lessc.inc.php';
     if ($this->basePath === null) {
         $this->basePath = Yii::getPathOfAlias('webroot');
     }
     if (!is_array($this->files)) {
         throw new CException('Failed to compile LESS. Property files must be an array.');
     }
     foreach ($this->files as $fileLess => $fileCss) {
         $pathLess = $this->basePath . '/' . $fileLess;
         $pathCss = $this->basePath . '/' . $fileCss;
         try {
             if (file_exists($pathLess)) {
                 if ($this->forceCompile === true) {
                     $this->getLessphp()->compileFile($pathLess, $pathCss);
                 } else {
                     $this->getLessphp()->checkedCompile($pathLess, $pathCss);
                 }
             }
         } catch (Exception $e) {
             throw new CException(__CLASS__ . ': ' . Yii::t('less', 'Failed to compile less file with message: `{message}`.', array('{message}' => $e->getMessage())));
         }
     }
 }
Exemplo n.º 8
0
 /**
  * Initializes this component.
  */
 public function init()
 {
     parent::init();
     if ($this->bootstrapPath === null) {
         $this->bootstrapPath = Yii::getPathOfAlias('bootstrap');
     }
 }
Exemplo n.º 9
0
 public function init()
 {
     parent::init();
     Yii::import('ext.imageapi.Toolkit');
     Yii::import('ext.imageapi.GDToolkit');
     $this->toolkit = new GDToolkit();
 }
 /**
  * Magic accessor for image collections.
  */
 public function __get($name)
 {
     if (!isset($this->collections[$name])) {
         return parent::__get($name);
     }
     return $this->getCollection($name);
 }
Exemplo n.º 11
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     $this->preInit();
     Yii::import('bootstrap.widgets.*');
     parent::init();
     $this->setScriptMap();
 }
Exemplo n.º 12
0
 /**
  * Initializes this component.
  */
 public function init()
 {
     parent::init();
     if ($this->bootstrapPath === null) {
         $this->bootstrapPath = Yii::getPathOfAlias('vendor.twbs.bootstrap.dist');
     }
 }
 /**
  * Initialize the component
  */
 public function init()
 {
     $this->initAutoloader($this->swiftBasePath);
     $this->transport = Swift_SmtpTransport::newInstance($this->host, $this->port, $this->security);
     $this->transport->setUsername($this->username)->setPassword($this->password);
     parent::init();
 }
 public function __call($name, $parameters)
 {
     if (\method_exists($this->_imageHandler, $name)) {
         return \call_user_func_array(array($this->_imageHandler, $name), $parameters);
     }
     return parent::__call($name, $parameters);
 }
Exemplo n.º 15
0
 public function init()
 {
     parent::init();
     require Yii::getPathOfAlias('ext.PHPMailer') . '/PHPMailerAutoload.php';
     $this->PHPMailer = new PHPMailer();
     $this->settings();
 }
Exemplo n.º 16
0
 /**
  * Initializes the application component.
  * This method overrides the parent implementation by preprocessing
  * the user request data.
  */
 public function init()
 {
     parent::init();
     if ($this->sanitizePost && count($_POST) > 0 || $this->sanitizeGet && count($_GET) > 0 || $this->sanitizePost && count($_COOKIE) > 0) {
         $this->sanitizeRequest();
     }
 }
Exemplo n.º 17
0
 /**
  *
  */
 public function init()
 {
     parent::init();
     $this->setHasher(Yii::createComponent($this->hasher));
     $this->setTokenStorage(Yii::createComponent($this->tokenStorage));
     $this->userModule = Yii::app()->getModule('user');
 }
Exemplo n.º 18
0
 public function init()
 {
     parent::init();
     Yii::setPathOfAlias('PhpAmqpLib', Yii::getPathOfAlias('vendor.yiiext.AMQP.PhpAmqpLib'));
     $this->_connect = new PhpAmqpLib\Connection\AMQPConnection($this->host, $this->port, $this->login, $this->password, $this->vhost);
     $this->_channel = $this->_connect->channel();
 }
Exemplo n.º 19
0
 /**
  * handles the initialization parameters of the components
  */
 function init()
 {
     if (!count($this->acceptedLanguages)) {
         $this->getAcceptedLanguages();
     }
     return parent::init();
 }
Exemplo n.º 20
0
 /**
  * CmsInput::init()
  * 
  * @return
  */
 public function init()
 {
     $this->originalPost = $_POST;
     $this->originalGet = $_GET;
     parent::init();
     Yii::app()->attachEventHandler('onBeginRequest', array($this, 'cleanGlobals'));
 }
 /**
  *
  */
 public function init()
 {
     parent::init();
     Yii::app()->getModule('email');
     $this->registerSwiftMailerAutoloader();
     $this->registerMustacheAutoloader();
 }
Exemplo n.º 22
0
 /**
  * Initializes the component.
  * This method is required by {@link IApplicationComponent} and is invoked by application
  * when the EFtpComponent is used as an application component.
  * If you override this method, make sure to call the parent implementation
  * so that the component can be marked as initialized.
  */
 public function init()
 {
     parent::init();
     if ($this->autoConnect) {
         $this->setActive(true);
     }
 }
Exemplo n.º 23
0
 /**
  * Registers Analytics.js and initializes the tracking code
  */
 public function init()
 {
     $sapi = php_sapi_name();
     if ($sapi == 'cli') {
         return;
     }
     // Set the alias path
     if (Yii::getPathOfAlias('analytics') === false) {
         Yii::setPathOfAlias('analytics', realpath(dirname(__FILE__) . '/..'));
     }
     parent::init();
     // Don't load up the analytics.js if we don't have any data
     $providers = $this->getProviders();
     if (empty($providers)) {
         return;
     }
     // Conver options into json
     $json = CJSON::encode($providers);
     // Load up the asset manager
     $asset = Yii::app()->assetManager->publish(__DIR__ . DS . 'assets' . DS . 'js', true, -1, YII_DEBUG);
     $cs = Yii::app()->getClientScript();
     // Register the appropriate script file
     $cs->registerScriptFile($asset . (YII_DEBUG ? '/analytics.js' : '/analytics.min.js'));
     // Initialize
     $cs->registerScript('analytics.js', "analytics.initialize({$json}); analytics.page();");
     if ($this->lowerBounceRate) {
         $cs->registerScript('analytics.js-bounce-rate-15', 'setTimeout(function() { analytics.track("_trackEvent", "15 Seconds"); }, 15000 );');
         $cs->registerScript('analytics.js-bounce-rate-30', 'setTimeout(function() { analytics.track("_trackEvent", "30 Seconds"); }, 30000 );');
         $cs->registerScript('analytics.js-bounce-rate-60', 'setTimeout(function() { analytics.track("_trackEvent", "60 Seconds"); }, 60000 );');
     }
 }
Exemplo n.º 24
0
 public function init()
 {
     parent::init();
     if ($this->driver != 'GD' && $this->driver != 'ImageMagick') {
         throw new CException('driver must be GD or ImageMagick');
     }
 }
Exemplo n.º 25
0
 public function init()
 {
     parent::init();
     if (!$this->isComponentActive()) {
         return;
     }
     try {
         $this->userInfo = call_user_func($this->userInfoCallable);
         $this->setUser($this->userInfo);
         $memcacheServerName = $this->cacheServer['host'];
         $memcacheServerPort = $this->cacheServer['port'];
         if ($memcacheServerName && $memcacheServerPort) {
             $memcached = new \Memcached();
             $memcached->addServer($memcacheServerName, $memcacheServerPort);
             $cacheDriver = new \Doctrine\Common\Cache\MemcachedCache();
             $cacheDriver->setMemcached($memcached);
             $cacheStorage = new \Kevinrob\GuzzleCache\Storage\DoctrineCacheStorage($cacheDriver);
         } else {
             $cacheStorage = new \Kevinrob\GuzzleCache\Storage\DoctrineCacheStorage(new \Doctrine\Common\Cache\FilesystemCache('/tmp/'));
         }
         $this->client = new \LaunchDarkly\LDClient($this->apiKey, array("cache" => $cacheStorage));
         $this->featureToggleUser = (new \LaunchDarkly\LDUserBuilder($this->user->key))->secondary($this->user->secondary)->ip($this->user->ip)->country($this->user->country)->email($this->user->email)->name($this->user->name)->avatar($this->user->avatar)->firstName($this->user->firstName)->lastName($this->user->lastName)->anonymous($this->user->anonymous)->custom(array('type' => $this->user->type, 'parentCompanyId' => $this->user->parentId, 'referredAccountId' => $this->user->referredAccountId, 'channel' => $this->user->channel, 'payoutMethod' => isset($this->user->payoutMethod) ? $this->user->payoutMethod : null))->build();
     } catch (\Exception $ex) {
         $this->componentActive = false;
         \Yii::log("Cannot initiate Feature Toggles: {$ex->getMessage()}", \CLogger::LEVEL_WARNING, 'system.featureToggle');
     }
 }
Exemplo n.º 26
0
 /**
  * Initializes the application component.
  * This method overrides the parent implementation by setting default cache key prefix.
  */
 public function init()
 {
     parent::init();
     if ($this->keyPrefix === null) {
         $this->keyPrefix = Yii::app()->getId();
     }
 }
Exemplo n.º 27
0
 public function init()
 {
     parent::init();
     if (isset(Yii::app()->user->userId)) {
         $this->data = UserState::model()->findByPk(Yii::app()->user->userId)->attributes;
     }
 }
Exemplo n.º 28
0
 /**
  *
  */
 public function init()
 {
     parent::init();
     if (null === $this->mutexFile) {
         $this->mutexFile = Yii::app()->getRuntimePath() . '/mutex.bin';
     }
 }
Exemplo n.º 29
0
 /**
  * Initializes the application component.
  * This method is required by IApplicationComponent and is invoked by application.
  */
 public function init()
 {
     parent::init();
     if ($this->autoStart) {
         $this->open();
     }
     register_shutdown_function(array($this, 'close'));
 }
Exemplo n.º 30
0
 /**
  * Инициализирует компонент приложения.
  */
 public function init()
 {
     parent::init();
     if ($this->basePath === null) {
         $this->basePath = Yii::getPathOfAlias('application.tests.fixtures');
     }
     $this->prepare();
 }