/**
  * Guess the assignment names.
  *
  * @param Migration $migration
  */
 public function guess(Migration $migration)
 {
     /**
      * If we don't have any addon then
      * we can't automate anything.
      *
      * @var Addon $addon
      */
     if (!($addon = $migration->getAddon())) {
         return;
     }
     $stream = $migration->getStream();
     $stream = $this->streams->findBySlugAndNamespace(array_get($stream, 'slug'), array_get($stream, 'namespace'));
     if (!$stream) {
         return;
     }
     $locale = $this->config->get('app.fallback_locale');
     $assignments = $migration->getAssignments();
     foreach ($assignments as &$assignment) {
         foreach (['label', 'warning', 'instructions', 'placeholder'] as $key) {
             if (is_null(array_get($assignment, $locale . '.' . $key))) {
                 $assignment = array_add($assignment, $locale . '.' . $key, $addon->getNamespace('field.' . array_get($assignment, 'field') . '.' . $key . '.' . $stream->getSlug()));
             }
         }
     }
     $migration->setAssignments($assignments);
 }
示例#2
0
 /**
  * Return the currency symbol.
  *
  * @param null $currency
  * @return string
  */
 public function symbol($currency = null)
 {
     if (!$currency) {
         $currency = $this->config->get('streams::currencies.default');
     }
     return $this->config->get('streams::currencies.supported.' . strtoupper($currency) . '.symbol');
 }
 /**
  * Normalize the assignments input.
  *
  * @param Migration $migration
  */
 public function normalize(Migration $migration)
 {
     $locale = $this->config->get('app.fallback_locale');
     $stream = $migration->getStream();
     $assignments = $migration->getAssignments();
     foreach ($assignments as $field => &$assignment) {
         /*
          * If the assignment is a simple string
          * then the assignment is the field slug.
          */
         if (is_string($assignment)) {
             $assignment = ['field' => $assignment];
         }
         /*
          * Generally the field will be the
          * array key. Make sure we have one.
          */
         if (!isset($assignment['field'])) {
             $assignment['field'] = $field;
         }
         /*
          * If any of the translatable items exist
          * in the base array then move them up into
          * the translation array.
          */
         foreach (['label', 'warning', 'instructions', 'placeholder'] as $key) {
             if ($value = array_pull($assignment, $key)) {
                 $assignment = array_add($assignment, $locale . '.' . $key, $value);
             }
         }
     }
     $migration->setAssignments($assignments);
 }
 /**
  * Normalize the fields input.
  *
  * @param Migration $migration
  */
 public function normalize(Migration $migration)
 {
     $locale = $this->config->get('app.fallback_locale');
     $fields = $migration->getFields();
     foreach ($fields as $slug => &$field) {
         /*
          * If the field is a simple string then
          * the $slug is used as is and the field
          * must be the field type.
          */
         if (is_string($field)) {
             $field = ['type' => $field];
         }
         if (!isset($field['type'])) {
             throw new \Exception("The [type] parameter must be defined in fields.");
         }
         $field['slug'] = array_get($field, 'slug', $slug);
         $field['namespace'] = array_get($field, 'namespace', $migration->contextualNamespace());
         /*
          * If any of the translatable items exist
          * in the base array then move them up into
          * the translation array.
          */
         foreach (['name', 'instructions', 'placeholder', 'warning'] as $key) {
             if ($value = array_pull($field, $key)) {
                 $field = array_add($field, $locale . '.' . $key, $value);
             }
         }
     }
     $migration->setFields($fields);
 }
示例#5
0
 public function menu($items)
 {
     if (!is_array($items)) {
         $items = $this->config->get($items, array());
     }
     return $this->view->make('partials/menu', compact('items'));
 }
示例#6
0
 /**
  * Start processes
  */
 protected function start()
 {
     foreach ($this->config->get('gitter.rooms') as $key => $id) {
         shell_exec('nohup php artisan gitter:listen ' . $key . ' > /dev/null 2>&1 &');
         $this->line('Starting ' . $key . ' => ' . $id . ' listener.');
     }
 }
示例#7
0
 /**
  * Say it loud.
  *
  * @param  Request  $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     /* @var \Illuminate\Http\Response $response */
     $response = $next($request);
     $response->headers->set('X-Streams-Distribution', $this->config->get('streams::distribution.name') . '-' . $this->config->get('streams::distribution.version'));
     return $response;
 }
示例#8
0
 /**
  * Set Browser Width
  * @param int $width
  */
 public function setWidth($width)
 {
     if (is_null($width)) {
         $width = $this->config->get('screeenly.core.screenshot_width');
     }
     return $this->width = $width;
 }
 /**
  * @param $name
  *
  * @return Sidebar
  */
 public function resolve($name)
 {
     $duration = $this->config->get('sidebar.cache.duration');
     return $this->cache->remember(CacheKey::get($name), $duration, function () use($name) {
         return $this->resolver->resolve($name);
     });
 }
 /**
  * Map additional routes.
  *
  * @param Router     $router
  * @param Repository $config
  */
 public function map(Router $router, Repository $config)
 {
     $tag = $config->get('anomaly.module.posts::paths.tag');
     $module = $config->get('anomaly.module.posts::paths.module');
     $category = $config->get('anomaly.module.posts::paths.category');
     $permalink = $config->get('anomaly.module.posts::paths.route');
     /**
      * Map the RSS methods.
      */
     $router->any("{$module}/rss/category/{category}.xml", ['uses' => 'Anomaly\\PostsModule\\Http\\Controller\\RssController@category', 'streams::addon' => 'anomaly.module.posts']);
     $router->any("{$module}/rss/tag/{tag}.xml", ['uses' => 'Anomaly\\PostsModule\\Http\\Controller\\RssController@tag', 'streams::addon' => 'anomaly.module.posts']);
     $router->any("{$module}/rss.xml", ['uses' => 'Anomaly\\PostsModule\\Http\\Controller\\RssController@recent', 'streams::addon' => 'anomaly.module.posts']);
     /**
      * Map other public routes.
      * Mind the order. Routes are
      * handled first come first serve.
      */
     $router->any("{$module}/{type}", ['uses' => 'Anomaly\\PostsModule\\Http\\Controller\\TypesController@index', 'streams::addon' => 'anomaly.module.posts']);
     $router->any($module, ['uses' => 'Anomaly\\PostsModule\\Http\\Controller\\PostsController@index', 'streams::addon' => 'anomaly.module.posts']);
     $router->any("{$module}/preview/{id}", ['uses' => 'Anomaly\\PostsModule\\Http\\Controller\\PostsController@preview', 'streams::addon' => 'anomaly.module.posts']);
     $router->any("{$module}/{$tag}/{tag}", ['uses' => 'Anomaly\\PostsModule\\Http\\Controller\\TagsController@index', 'streams::addon' => 'anomaly.module.posts']);
     $router->any("{$module}/{$category}/{category}", ['uses' => 'Anomaly\\PostsModule\\Http\\Controller\\CategoriesController@index', 'streams::addon' => 'anomaly.module.posts']);
     $router->any("{$module}/archive/{year}/{month?}", ['uses' => 'Anomaly\\PostsModule\\Http\\Controller\\ArchiveController@index', 'streams::addon' => 'anomaly.module.posts']);
     $router->any("{$module}/{$permalink}", ['uses' => 'Anomaly\\PostsModule\\Http\\Controller\\PostsController@view', 'streams::addon' => 'anomaly.module.posts']);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->config->get('app.debug', false)) {
         return $next($request);
     }
     if (!$request instanceof Request) {
         return $next($request);
     }
     $route = $request->route();
     if (!$route instanceof Route) {
         return $next($request);
     }
     $class = explode('@', $route->getActionName())[0];
     if (!is_subclass_of($class, HalApiControllerContract::class)) {
         return $next($request);
     }
     /** @var HalApiControllerContract $class */
     $cache = $class::getCache($this->cacheFactory);
     if ($request->isMethodSafe()) {
         $key = $this->generateKey($cache, $request);
         return $cache->persist($key, function () use($next, $request) {
             return $next($request);
         });
     }
     $cache->purge();
     foreach ($class::getRelatedCaches($this->cacheFactory) as $relatedCache) {
         $relatedCache->purge();
     }
     return $next($request);
 }
示例#12
0
 /**
  * Constructor
  *
  * @param Repository $config
  */
 public function __construct(Repository $config)
 {
     $this->config = $config;
     $this->mediaTypes = $this->config->get('files.media_types', ['audio' => ['audio/aac', 'audio/mp4', 'audio/mpeg', 'audio/ogg', 'audio/wav', 'audio/webm'], 'document' => ['text/plain', 'application/pdf', 'application/msword', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'], 'image' => ['image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/svg+xml'], 'video' => ['video/mp4', 'video/ogg', 'video/webm']]);
     $this->modelTypes = $this->config->get('files.model_types', ['audio' => 'Kenarkose\\Files\\Media\\Audio', 'document' => 'Kenarkose\\Files\\Media\\Document', 'image' => 'Kenarkose\\Files\\Media\\Image', 'video' => 'Kenarkose\\Files\\Media\\Video']);
     $this->defaultMediaModel = $this->config->get('files.media_model', 'Kenarkose\\Files\\Media\\Media');
 }
示例#13
0
 /**
  * Return the tag links.
  *
  * @param array $attributes
  * @return string
  */
 public function tagLinks(array $attributes = [])
 {
     array_set($attributes, 'class', array_get($attributes, 'class', 'label label-default'));
     return array_map(function ($label) use($attributes) {
         return $this->html->link(implode('/', [$this->config->get('anomaly.module.posts::paths.module'), $this->config->get('anomaly.module.posts::paths.tag'), $label]), $label, $attributes);
     }, (array) $this->object->getTags());
 }
 /**
  * Retrieve the default project hook.
  *
  * @return string
  */
 protected function getDefaultProjectHook()
 {
     // Get default project handle.
     $default = $this->config->get(self::CONFIG_DEFAULT);
     // Return project hook value.
     return $this->config->get(sprintf(self::CONFIG_PROJECT, $default));
 }
示例#15
0
 /**
  * Guess the sections title.
  *
  * @param ControlPanelBuilder $builder
  */
 public function guess(ControlPanelBuilder $builder)
 {
     $sections = $builder->getSections();
     foreach ($sections as &$section) {
         // If title is set then skip it.
         if (isset($section['title'])) {
             continue;
         }
         $module = $this->modules->active();
         $title = $module->getNamespace('section.' . $section['slug'] . '.title');
         if (!isset($section['title']) && $this->translator->has($title)) {
             $section['title'] = $title;
         }
         $title = $module->getNamespace('addon.section.' . $section['slug']);
         if (!isset($section['title']) && $this->translator->has($title)) {
             $section['title'] = $title;
         }
         if (!isset($section['title']) && $this->config->get('streams::system.lazy_translations')) {
             $section['title'] = ucwords($this->string->humanize($section['slug']));
         }
         if (!isset($section['title'])) {
             $section['title'] = $title;
         }
     }
     $builder->setSections($sections);
 }
示例#16
0
 /**
  * Get the metrics table name.
  *
  * @return string
  */
 protected function getTableName()
 {
     $driver = $this->config->get('database.default');
     $connection = $this->config->get('database.connections.' . $driver);
     $prefix = $connection['prefix'];
     return $prefix . 'metrics';
 }
示例#17
0
文件: Backup.php 项目: vinkla/backup
 /**
  * Get the backup profile.
  *
  * @return string
  */
 public function getProfile() : string
 {
     if ($this->profile) {
         return $this->profile;
     }
     return $this->config->get('backup.default');
 }
 /**
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$this->authenticator->isAuthenticated()) {
         return $this->redirector->to($this->config->get('littlegatekeeper.authRoute'));
     }
     return $next($request);
 }
 /**
  * @param EventManager           $manager
  * @param EntityManagerInterface $em
  * @param Reader                 $reader
  */
 public function addSubscribers(EventManager $manager, EntityManagerInterface $em, Reader $reader = null)
 {
     $subscriber = new TranslatableListener();
     $subscriber->setTranslatableLocale($this->application->getLocale());
     $subscriber->setDefaultLocale($this->repository->get('app.locale'));
     $this->addSubscriber($subscriber, $manager, $reader);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  * @return void|mixed
  */
 public function handle(Request $request, Closure $next)
 {
     if (!$this->app->isDownForMaintenance()) {
         return $next($request);
     }
     if ($request->segment(1) == 'admin') {
         return $next($request);
     }
     if (in_array($request->getClientIp(), $this->config->get('streams::maintenance.ip_whitelist', []))) {
         return $next($request);
     }
     /* @var UserInterface $user */
     $user = $this->guard->user();
     if ($user && $user->isAdmin()) {
         return $next($request);
     }
     if ($user && $this->authorizer->authorize('streams::maintenance.access')) {
         return $next($request);
     }
     if (!$user && $this->config->get('streams::maintenance.auth')) {
         /* @var Response|null $response */
         $response = $this->guard->onceBasic();
         if (!$response) {
             return $next($request);
         }
         $response->setContent(view('streams::errors.401'));
         return $response;
     }
     abort(503);
 }
示例#21
0
 /**
  * Returns the Aimeos object.
  *
  * @return \Aimeos Aimeos object
  */
 public function get()
 {
     if ($this->object === null) {
         $extDirs = (array) $this->config->get('shop.extdir', array());
         $this->object = new \Aimeos\Bootstrap($extDirs, false);
     }
     return $this->object;
 }
示例#22
0
 /**
  * @param Dompdf $dompdf
  * @param \Illuminate\Contracts\Config\Repository $config
  * @param \Illuminate\Filesystem\Filesystem $files
  * @param \Illuminate\Contracts\View\Factory $view
  */
 public function __construct(Dompdf $dompdf, ConfigRepository $config, Filesystem $files, ViewFactory $view)
 {
     $this->dompdf = $dompdf;
     $this->config = $config;
     $this->files = $files;
     $this->view = $view;
     $this->showWarnings = $this->config->get('dompdf.show_warnings', false);
 }
示例#23
0
 public function __construct(Config $config)
 {
     // Set default configuration values
     $this->setDefaultImage($config->get('gravatar.default'));
     $this->defaultSize = $config->get('gravatar.size');
     $this->setMaxRating($config->get('gravatar.maxRating', 'g'));
     $this->enableSecureImages();
 }
示例#24
0
 /**
  * Metrics view composer.
  *
  * @param \Illuminate\Contracts\View\View $view
  *
  * @return void
  */
 public function compose(View $view)
 {
     $metrics = null;
     if ($displayMetrics = $this->config->get('setting.display_graphs')) {
         $metrics = Metric::displayable()->orderBy('order')->orderBy('id')->get();
     }
     $view->withDisplayMetrics($displayMetrics)->withMetrics($metrics);
 }
 /**
  * Returns the handler bound to the command's class name.
  *
  * @param  string  $command
  * @return object
  *
  * @throws \League\Tactician\Exception\MissingHandlerException
  */
 public function getHandlerForCommand($command)
 {
     $handlers = $this->config->get('tactician.handlers', []);
     if (!isset($handlers[$command]) || !class_exists($handlers[$command])) {
         throw MissingHandlerException::forCommand($command);
     }
     return $this->container->make($handlers[$command]);
 }
示例#26
0
 /**
  * Get all configured lists.
  *
  * @return array
  *
  * @throws Exception
  */
 public function getAllLists()
 {
     $allLists = $this->config->get('laravel-newsletter.mailChimp.lists');
     if (!count($allLists)) {
         throw new Exception('There are no MailChimp lists defined');
     }
     return $allLists;
 }
 /**
  * Bootstrap any application services.
  *
  * @param  \Illuminate\Contracts\Config\Repository  $config
  * @return void
  */
 public function boot(Repository $config)
 {
     $this->publishes([__DIR__ . '/config/config.php' => config_path('oauth2-otland.php')]);
     $this->mergeConfigFrom(__DIR__ . '/config/config.php', 'oauth2-otland');
     $this->app->bind(OtLand::class, function () use($config) {
         return new OtLand(['clientId' => $config->get('oauth2-otland.client-id'), 'clientSecret' => $config->get('oauth2-otland.client-secret'), 'redirectUri' => $config->get('oauth2-otland.redirect-uri')]);
     });
 }
示例#28
0
 /**
  * Handle the command.
  *
  * @param Repository $config
  * @param Resolver   $resolver
  * @param Evaluator  $evaluator
  * @param Value      $value
  * @return string
  */
 public function handle(Repository $config, Resolver $resolver, Evaluator $evaluator, Value $value)
 {
     $base = '/' . $config->get('anomaly.module.posts::paths.module');
     if (!$this->post->isLive()) {
         return $base . '/preview/' . $this->post->getStrId();
     }
     return $base . '/' . $value->make($evaluator->evaluate($resolver->resolve($config->get('anomaly.module.posts::paths.permalink'), ['post' => $this->post]), ['post' => $this->post]), $this->post);
 }
 public function handle()
 {
     $storeName = $this->config->get('laravel-responsecache.cacheStore');
     $this->laravel['events']->fire('responsecache:clearing', [$storeName]);
     $this->cache->store($storeName)->flush();
     $this->laravel['events']->fire('responsecache:cleared', [$storeName]);
     $this->info('Response cache cleared!');
 }
示例#30
0
 /**
  * @param Repository $config
  *
  * @return mixed
  */
 public function getTargetEntity(Repository $config)
 {
     // Config driver has no target entity
     if ($config->get('acl.permissions.driver', 'config') === 'config') {
         return false;
     }
     return $this->targetEntity ?: $config->get('acl.permissions.entity', 'Permission');
 }