/** * Get the specified configuration value. * * @param string $key Name of the key * @param mixed $default Default value * @param bool $dbLookup If false, do not access the database table * @return mixed */ public static function get($key, $default = null, $dbLookup = true) { if (installed() and $dbLookup) { $dbChecked = Cache::has(self::CACHE_IN_DB_PREFIX . $key); if ($dbChecked) { $inDb = Cache::get(self::CACHE_IN_DB_PREFIX . $key); if ($inDb) { return Cache::get(self::CACHE_VALUES_PREFIX . $key); } } else { $result = DB::table('config')->whereName($key)->first(); if (is_null($result)) { Cache::put(self::CACHE_IN_DB_PREFIX . $key, false, self::CACHE_TIME); } else { Cache::put(self::CACHE_IN_DB_PREFIX . $key, true, self::CACHE_TIME); Cache::put(self::CACHE_VALUES_PREFIX . $key, $result->value, self::CACHE_TIME); return $result->value; } } } if ((strpos($key, '.') !== false or strpos($key, '::') !== false) and LaravelConfig::has($key)) { return LaravelConfig::get($key, $default); } return $default; }
function __construct() { // Get default locale string in laravel project // and set it as default dictionary $locale_dict = Config::has('app.locale') ? Config::get('app.locale') : 'en'; $this->setDictionary($locale_dict); }
/** * Execute the console command. * * @return mixed */ public function fire() { $section = $this->argument('section'); if (!empty($section)) { if (!Config::has($section)) { $this->error($section . ' does not exist in your configuration.'); return; } // If the requested string is a string, and not something that can be displayed in a table, then just print // it out in the console. $config = Config::get($section); if (!is_array($config)) { $this->line('<comment>' . $config . '</comment>'); return; } $configs = [$section => $config]; } else { $configs = Config::all(); ksort($configs); } foreach ($configs as $section => $config) { $depth = $this->getConfigDepth($config); $tree = $this->generateTree($config, $depth); $this->line('<info>Configuration:</info> <comment>' . $section . '</comment>'); $this->table([], $tree, 'default'); } }
public function __construct() { $_conf = array('DOMPDF_TEMP_DIR', 'DOMPDF_UNICODE_ENABLED', 'DOMPDF_PDF_BACKEND', 'DOMPDF_DEFAULT_MEDIA_TYPE', 'DOMPDF_DEFAULT_PAPER_SIZE', 'DOMPDF_DEFAULT_FONT', 'DOMPDF_DPI', 'DOMPDF_ENABLE_PHP', 'DOMPDF_ENABLE_REMOTE', 'DOMPDF_ENABLE_CSS_FLOAT', 'DOMPDF_ENABLE_JAVASCRIPT', 'DEBUGPNG', 'DEBUGKEEPTEMP', 'DEBUGCSS', 'DEBUG_LAYOUT', 'DEBUG_LAYOUT_LINES', 'DEBUG_LAYOUT_BLOCKS', 'DEBUG_LAYOUT_INLINE', 'DOMPDF_FONT_HEIGHT_RATIO', 'DEBUG_LAYOUT_PADDINGBOX', 'DOMPDF_ENABLE_HTML5PARSER', 'DOMPDF_ENABLE_FONTSUBSETTING', 'DOMPDF_ADMIN_USERNAME', 'DOMPDF_ADMIN_PASSWORD'); foreach ($_conf as $conf) { if ((Config::has('pdf::' . $conf) || Config::get('pdf::' . $conf)) && !defined($conf)) { define($conf, Config::get('pdf::' . $conf)); } } require_once 'dompdf/dompdf_config.inc.php'; $this->dompdf = new \DOMPDF(); }
/** * Get the active user. * * @return int User ID * @throws \Exception */ protected function activeUser() { if (!Config::has('culpa.users.active_user')) { return Auth::check() ? Auth::user()->id : null; } $fn = Config::get('culpa.users.active_user'); if (!is_callable($fn)) { throw new \Exception('culpa.users.active_user should be a closure'); } return $fn(); }
/** * Grab variables from config * * @param Document $document * * @return \Adamgoose\PrismicIo\Model */ public function __construct(Document $document = null) { if (Config::has('prismic.endpoint') && !isset($this->endpoint)) { $this->endpoint = Config::get('prismic.endpoint'); } if (Config::has('prismic.token') && !isset($this->token)) { $this->token = Config::get('prismic.token'); } if ($document instanceof Document) { $this->document = $document; } }
public function register() { /*-------------------------------------------------------------------------- | Bind in IOC |--------------------------------------------------------------------------*/ $this->app->bindShared('igaster.themes', function () { return new Themes(); }); /*-------------------------------------------------------------------------- | Is package enabled? |--------------------------------------------------------------------------*/ if (!Config::get('themes.enabled', true)) { return; } /*-------------------------------------------------------------------------- | Extend FileViewFinder |--------------------------------------------------------------------------*/ $this->app->bindShared('view.finder', function ($app) { $paths = $app['config']['view.paths']; return new \igaster\laravelTheme\themeViewFinder($app['files'], $paths); }); /*-------------------------------------------------------------------------- | Initialize Themes |--------------------------------------------------------------------------*/ $Themes = $this->app->make('igaster.themes'); /*-------------------------------------------------------------------------- | Load Themes from theme.php configuration file |--------------------------------------------------------------------------*/ if (Config::has('themes') && !empty(Config::get('themes'))) { foreach (Config::get('themes.themes') as $themeName => $options) { $assetPath = null; $viewsPath = null; $extends = null; if (is_array($options)) { if (array_key_exists('asset-path', $options)) { $assetPath = $options['asset-path']; } if (array_key_exists('views-path', $options)) { $viewsPath = $options['views-path']; } if (array_key_exists('extends', $options)) { $extends = $options['extends']; } } else { $themeName = $options; } $Themes->add(new Theme($themeName, $assetPath, $viewsPath), $extends); } if (!$Themes->activeTheme) { $Themes->set(Config::get('themes.active')); } } }
public function __call($method, $parameters) { $class_name = class_basename($this); #i: Convert array to dot notation $config = implode('.', ['relations', $class_name, $method]); #i: Relation method resolver if (Config::has($config)) { $function = Config::get($config); return $function($this); } #i: No relation found, return the call to parent (Eloquent) to handle it. return parent::__call($method, $parameters); }
/** * Register the service provider. * * @return void */ public function register() { $this->mergeConfigFrom(__DIR__ . '/../config/pdf.php', 'pdf'); $this->app->bind('mpdf.wrapper', function ($app, $cfg) { if (Config::has('pdf.custom_font_path') && Config::has('pdf.custom_font_data')) { define(_MPDF_SYSTEM_TTFONTS_CONFIG, __DIR__ . '/../mpdf_ttfonts_config.php'); } $mpdf = new \mPDF(Config::get('pdf.mode'), Config::get('pdf.format'), Config::get('pdf.default_font_size'), Config::get('pdf.default_font'), Config::get('pdf.margin_left'), Config::get('pdf.margin_right'), Config::get('pdf.margin_top'), Config::get('pdf.margin_bottom'), Config::get('pdf.margin_header'), Config::get('pdf.margin_footer'), Config::get('pdf.orientation')); $mpdf->SetTitle(Config::get('pdf.title')); $mpdf->SetAuthor(Config::get('pdf.author')); $mpdf->SetWatermarkText(Config::get('pdf.watermark')); $mpdf->SetDisplayMode(Config::get('pdf.display_mode')); $mpdf->showWatermarkText = Config::get('pdf.show_watermark'); $mpdf->watermark_font = Config::get('pdf.watermark_font'); $mpdf->watermarkTextAlpha = Config::get('pdf.watermark_text_alpha'); return new PdfWrapper($mpdf); }); }
/** * Execute the console command. * * @return mixed */ public function fire() { $section = $this->argument('section'); if (!empty($section)) { if (!Config::has($section)) { $this->error($section . ' does not exist in your configuration.'); return; } $configs = [$section => Config::get($section)]; } else { $configs = Config::all(); ksort($configs); } foreach ($configs as $section => $config) { $depth = $this->getConfigDepth($config); $tree = $this->generateTree($config, $depth); $this->line('<info>Configuration:</info> <comment>' . $section . '</comment>'); $this->table([], $tree, 'default'); } }
/** * Get the configuration setting for the prefix used to determine if a string is encrypted. * * @return string */ protected function getElocryptPrefix() { return Config::has('elocrypt.prefix') ? Config::get('elocrypt.prefix') : '__ELOCRYPT__:'; }
/** * Fetch the locale instance. * * @throws \Ngocnh\Translator\TranslatorException * * @return mixed */ private function getLocaleInstance() { if (!Config::has('translator.locale')) { throw new TranslatableException('Please set the \'locale\' property in the configuration to your Locale model path.'); } return App::make(Config::get('translator.locale')); }
public function menu() { if (Config::has('admin.menu')) { return Config::get('admin.menu'); } }
/** * Checks if the app has the transformers package configuration. * * @return mixed */ public static function isConfigPublished() { return Config::has('transformers.transformers'); }
<?php use Illuminate\Support\Facades\Config; /* |-------------------------------------------------------------------------- | Package Routes |-------------------------------------------------------------------------- | */ $options = ['prefix' => Config::get('api.prefix', 'api')]; if (Config::has('api.middleware')) { $options['middleware'] = Config::get('api.middleware'); } Route::group($options, function () { // These routes are using the api.php config file to map {resource} and {relation} to Models Route::get('/{resource}', 'DefaultRestController@index'); Route::get('/{resource}/{id}', 'DefaultRestController@show'); Route::post('/{resource}', 'DefaultRestController@store'); Route::put('/{resource}/{id}', 'DefaultRestController@update'); Route::delete('/{resource}/{id}', 'DefaultRestController@destroy'); Route::get('/{resource}/{id}/{relation}', 'DefaultRestController@indexRelation'); });
public function _before() { // We have a problem here in that foreach fixture, // from the traitsProvider() method, the _before() // and _after() method are invoked. This is painfully // slow. // Avoid traditional startup... //parent::_before(); // Create faker if needed if (!isset($this->faker)) { $this->faker = FakerFactory::create(); } // Start Laravel app. if (!$this->hasApplicationBeenStarted()) { $this->startApplication(); } // Before we obtain it - we need to make a small configuration // because the test-fixtures in Orchestra doesn't contain it. // We are generating it here, more or less just like Laravel ConfigFacade::set('app.key', Str::random(32)); // HOTFIX, see https://github.com/orchestral/testbench/pull/128 // This can be removed again, when fixed by author if (!ConfigFacade::has('broadcasting.connections.null')) { ConfigFacade::set('broadcasting.connections.null', ['driver' => 'null']); } // HOTFIX, see https://github.com/orchestral/testbench/pull/129 // This can be removed again, when fixed by author $providers = ConfigFacade::get('app.providers'); if (!in_array(\Illuminate\Notifications\NotificationServiceProvider::class, $providers)) { App::register(\Illuminate\Notifications\NotificationServiceProvider::class); } }