コード例 #1
1
 /**
  * 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');
 }
コード例 #3
0
ファイル: InstallCommand.php プロジェクト: notadd/framework
 /**
  * @return void
  */
 public function fire()
 {
     if (!$this->isDataSetted) {
         $this->setDataFromConsoling();
     }
     $this->config->set('database', ['fetch' => PDO::FETCH_OBJ, 'default' => $this->data->get('driver'), 'connections' => [], 'redis' => []]);
     switch ($this->data->get('driver')) {
         case 'mysql':
             $this->config->set('database.connections.mysql', ['driver' => 'mysql', 'host' => $this->data->get('database_host'), 'database' => $this->data->get('database'), 'username' => $this->data->get('database_username'), 'password' => $this->data->get('database_password'), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => $this->data->get('database_prefix'), 'strict' => true, 'engine' => null]);
             break;
         case 'pgsql':
             $this->config->set('database.connections.pgsql', ['driver' => 'pgsql', 'host' => $this->data->get('database_host'), 'database' => $this->data->get('database'), 'username' => $this->data->get('database_username'), 'password' => $this->data->get('database_password'), 'charset' => 'utf8', 'prefix' => $this->data->get('database_prefix'), 'schema' => 'public', 'sslmode' => 'prefer']);
             break;
         case 'sqlite':
             $this->config->set('database.connections.sqlite', ['driver' => 'sqlite', 'database' => $this->container->storagePath() . DIRECTORY_SEPARATOR . 'bootstraps' . DIRECTORY_SEPARATOR . 'database.sqlite', 'prefix' => $this->data->get('database_prefix')]);
             touch($this->container->storagePath() . DIRECTORY_SEPARATOR . 'bootstraps' . DIRECTORY_SEPARATOR . 'database.sqlite');
             break;
     }
     $this->call('migrate', ['--force' => true, '--path' => str_replace(base_path() . DIRECTORY_SEPARATOR, '', database_path('migrations'))]);
     $this->call('passport:keys');
     $this->call('passport:client', ['--password' => true, '--name' => 'Notadd Administrator Client']);
     $setting = $this->container->make(SettingsRepository::class);
     $setting->set('site.name', $this->data->get('website'));
     $setting->set('setting.image.engine', 'webp');
     if ($this->data->get('image_engine', false)) {
     } else {
         $setting->set('setting.image.engine', 'normal');
     }
     $this->createAdministrationUser();
     $this->writingConfiguration();
     $this->call('key:generate');
     $this->info('Notadd Installed!');
 }
コード例 #4
0
 /**
  * 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);
 }
コード例 #5
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());
 }
コード例 #6
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);
 }
コード例 #7
0
 /**
  * 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);
 }
コード例 #8
0
 /**
  * Handle the command.
  *
  * @param ModuleCollection $modules
  * @param Decorator        $decorator
  * @param Repository       $config
  * @param Container        $container
  * @param Request          $request
  * @param Search           $search
  * @return LengthAwarePaginator
  */
 public function handle(ModuleCollection $modules, Decorator $decorator, Repository $config, Container $container, Request $request, Search $search)
 {
     /* @var Query $query */
     $query = $search->index($this->criteria->option('index', 'default'));
     $constraint = $this->criteria->option('in');
     if (!empty($constraint) && is_string($constraint)) {
         $query = $query->search('stream', $constraint, ['required' => true]);
     }
     if (!empty($constraint) && is_array($constraint)) {
         /* @var Module $module */
         foreach ($modules->withConfig('search') as $module) {
             foreach ($config->get($module->getNamespace('search')) as $model => $definition) {
                 /* @var EntryInterface $model */
                 $model = $container->make($model);
                 $stream = $model->getStreamNamespace() . '.' . $model->getStreamSlug();
                 if (!in_array($stream, $constraint)) {
                     $query = $query->search('stream', $stream, ['required' => false, 'prohibited' => true]);
                 }
             }
         }
     }
     foreach ($this->criteria->getOperations() as $operation) {
         $query = call_user_func_array([$query, $operation['name']], $operation['arguments']);
     }
     $page = $request->get('page', 1);
     $perPage = $this->criteria->option('paginate', $this->criteria->option('limit', 15));
     $query->limit($perPage, ($page - 1) * $perPage);
     $collection = new SearchCollection(array_map(function ($result) use($decorator) {
         return $decorator->decorate(new SearchItem($result));
     }, $query->get()));
     return (new LengthAwarePaginator($collection, $query->count(), $perPage, $page))->setPath($request->path())->appends($request->all());
 }
コード例 #9
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;
 }
コード例 #10
0
 /**
  * @param \Maknz\Slack\Client $client
  * @param Repository          $config
  */
 public function __construct(Client $client, Repository $config)
 {
     $this->config = $config->get('server-monitor.notifications.slack');
     $client->setDefaultUsername($this->config['username']);
     $client->setDefaultIcon($this->config['icon']);
     $this->client = $client;
 }
コード例 #11
0
 public static function registerMenu(Dispatcher $events, Repository $config)
 {
     $events->listen(BuildingMenu::class, function (BuildingMenu $event) use($config) {
         $menu = $config->get('adminlte.menu');
         call_user_func_array([$event->menu, 'add'], $menu);
     });
 }
コード例 #12
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;
 }
コード例 #13
0
 /**
  * @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);
     });
 }
コード例 #14
0
 /**
  * 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);
 }
コード例 #15
0
 function it_should_not_set_error_handler_when_passed_false(Config $config)
 {
     $config->get('opbeat.enable_error_handler', true)->willReturn(false);
     $this->beConstructedWith($config);
     $errorHandler = [$this->getWrappedObject(), ['handleError']];
     $this->errorHandler()->shouldNotReturn(set_error_handler(null));
 }
コード例 #16
0
 /**
  * @param Container        $container
  * @param ConfigRepository $config
  */
 protected function createManager(Container $container, ConfigRepository $config)
 {
     $fileManager = $container->make(FileManager::class);
     $imageManager = new ImageManager($fileManager);
     $this->configureManager($imageManager, $container, $config->get('imagemanager', []));
     return $imageManager;
 }
コード例 #17
0
 /**
  * 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));
 }
コード例 #18
0
ファイル: Backup.php プロジェクト: recca0120/laravel-support
 public function __construct(Connection $connection, RepositoryContract $config)
 {
     $dbconfig = $config->get('database.connections.' . $connection->getName());
     $this->dsn = static::parseDSN($dbconfig);
     $this->username = $dbconfig['username'];
     $this->password = $dbconfig['password'];
 }
コード例 #19
0
 /**
  * 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']);
 }
コード例 #20
0
 public function test_it_should_call_all_binders()
 {
     $this->configMock->shouldReceive('get')->with('routes.binders', [])->andReturn(['foo', 'bar', 'baz']);
     $this->appMock->shouldReceive('routesAreCached')->andReturn(false);
     $this->expectBinders();
     $this->sp->boot($this->routerMock);
 }
コード例 #21
0
 /**
  * @param \Illuminate\Contracts\Database\DatabaseManager $db
  * @param \Illuminate\Contracts\Config\Repository $config
  */
 public function __construct(DatabaseManager $db, Config $config = null)
 {
     $this->db = $db;
     if ($config) {
         $this->table = $config->get('database.migrations', $this->table);
     }
 }
コード例 #22
0
 /**
  * @param Client $client
  * @param ConfigRepository $config
  * @param Log $log
  * @param BillValidator $validator
  */
 function __construct(Client $client, ConfigRepository $config, Log $log, BillValidator $validator)
 {
     $this->apiKey = $config->get('billplz.api_key');
     $this->client = $client;
     $this->log = $log;
     $this->validator = $validator;
 }
コード例 #23
0
ファイル: ModelDeterminer.php プロジェクト: kenarkose/files
 /**
  * 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');
 }
コード例 #24
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';
 }
コード例 #25
0
 /**
  * Handle the command.
  *
  * @param Repository $config
  * @param Encrypter  $encrypter
  * @return string
  */
 public function handle(Repository $config, Encrypter $encrypter)
 {
     $email = $encrypter->encrypt($this->user->getEmail());
     $code = $encrypter->encrypt($this->user->getResetCode());
     $query = "?email={$email}&code={$code}&redirect={$this->redirect}";
     return $config->get('anomaly.module.users::paths.reset') . $query;
 }
コード例 #26
0
 /**
  * @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);
 }
コード例 #27
0
ファイル: HtmlBuilder.php プロジェクト: resand/teachme
 public function menu($items)
 {
     if (!is_array($items)) {
         $items = $this->config->get($items, array());
     }
     return $this->view->make('partials/menu', compact('items'));
 }
コード例 #28
0
 /**
  * @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);
 }
コード例 #29
0
ファイル: Debugger.php プロジェクト: dasim/laravel-tracy
 public function __construct($options = [], Application $app = null, RepositoryContract $config = null, Dispatcher $dispatcher = null)
 {
     static::$options = $config !== null ? array_merge($options, $config->get('tracy')) : $options;
     TracyDebugger::$time = array_get($_SERVER, 'REQUEST_TIME_FLOAT', microtime(true));
     TracyDebugger::$maxDepth = array_get(static::$options, 'maxDepth');
     TracyDebugger::$maxLen = array_get(static::$options, 'maxLen');
     TracyDebugger::$showLocation = array_get(static::$options, 'showLocation');
     TracyDebugger::$strictMode = array_get(static::$options, 'strictMode');
     TracyDebugger::$editor = array_get(static::$options, 'editor');
     $bar = TracyDebugger::getBar();
     foreach (array_get(static::$options, 'panels') as $key => $enabled) {
         if ($enabled === true) {
             $class = '\\' . __NAMESPACE__ . '\\Panels\\' . ucfirst($key) . 'Panel';
             if (class_exists($class) === false) {
                 $class = $key;
             }
             $this->panels[$key] = new $class($app, static::$options);
             $bar->addPanel($this->panels[$key], $class);
         }
     }
     if ($dispatcher !== null) {
         $dispatcher->listen('kernel.handled', function ($request, $response) {
             return static::appendDebugbar($request, $response);
         });
     } else {
         TracyDebugger::enable();
     }
 }
コード例 #30
0
ファイル: Rebuild.php プロジェクト: visualturk/search-module
 /**
  * Execute the console command.
  *
  * @param ModuleCollection $modules
  * @param Repository       $config
  * @param Search           $search
  * @param Kernel           $console
  */
 public function fire(ModuleCollection $modules, Repository $config, Search $search, Kernel $console)
 {
     $stream = $this->argument('stream');
     if (!$stream) {
         $this->info('Destroying index');
         $console->call('search:destroy');
     } else {
         $this->info('Deleting ' . $stream);
         $search->search('stream', $stream)->delete();
     }
     /* @var Module $module */
     foreach ($modules->withConfig('search') as $module) {
         foreach ($config->get($module->getNamespace('search')) as $model => $search) {
             /* @var EntryModel $model */
             $model = new $model();
             if (!$stream || $stream == $model->getStreamNamespace() . '.' . $model->getStreamSlug()) {
                 $this->info('Rebuilding ' . $stream);
                 $this->output->progressStart($model->count());
                 foreach ($model->all() as $entry) {
                     $entry->save();
                     $this->output->progressAdvance();
                 }
                 $this->output->progressFinish();
             }
         }
     }
 }