Register Bugsnag instance.

@author Morten Rugaard <moru@nodes.dk>
@author Rasmus Ebbesen <re@nodes.dk>

@return void
763813
protected function registerBugsnag()
    {
        $config = config('nodes.bugsnag');

        if (!in_array($this->app->environment(), config('nodes.bugsnag.notify_release_stages', []))) {
            return;
        }

        $this->app->singleton('nodes.bugsnag', function (Container $app) use ($config) {
            // Retrieve bugsnag settings
            $bugsnag = new Client(new Configuration($config['api_key']), new LaravelResolver($app), $this->getGuzzle($config));
            $this->setupPaths($bugsnag, $app->basePath(), $app->path(), base_path(), app_path());
            $bugsnag->setReleaseStage($app->environment());
            $bugsnag->setBatchSending(false);
            $bugsnag->setNotifier([
                'name'    => 'Nodes Bugsnag Laravel',
                'version' => self::VERSION,
                'url'     => 'http://packagist.com/nodes/bugsnag',
            ]);

            // Set notify release stages
            if (!empty($config['notify_release_stages'])) {
                $bugsnag->setNotifyReleaseStages((array) $config['notify_release_stages']);
            }

            // Set filters
            if (!empty($config['filters'])) {
                $bugsnag->setFilters((array) $config['filters']);
            }

            $bugsnag->registerDefaultCallbacks();

            // Attach user agent data to all exceptions
            $bugsnag->registerCallback(function (Report $report) {
                $report->setMetaData(['User Agent' => $this->gatherUserAgentData()]);
            });

            return $bugsnag;
        });

        $this->app->singleton('bugsnag.logger', function (Container $app) {
            return new LaravelLogger($app['nodes.bugsnag']);
        });

        $this->app->singleton('bugsnag.multi', function (Container $app) {
            return new MultiLogger([$app['log'], $app['bugsnag.logger']]);
        });

        $this->app->alias('nodes.bugsnag', Client::class);
        $this->app->alias('bugsnag.logger', LaravelLogger::class);
        $this->app->alias('bugsnag.multi', MultiLogger::class);
    }
370763
public function register()
    {
        $configPath = __DIR__ . '/../config/phpgit.php';
        $this->mergeConfigFrom($configPath, 'phpgit');

        $this->app->bindShared('command.patch.script', function () {
            return new \DavinBao\PhpGit\Console\Commands\PatchScript;
        });

        $this->app->bindShared('command.patch.db', function () {
            return new \DavinBao\PhpGit\Console\Commands\PatchDb;
        });

        $this->commands(array('command.patch.script', 'command.patch.db'));
    }
1113992
public function register()
    {
        if (!$this->isLumen()) {
            $this->publishes([
                __DIR__ . '/../config/safequeue.php' => config_path('safequeue.php'),
            ], 'safequeue');
        }

        $this->mergeConfigFrom(
            __DIR__ . '/../config/safequeue.php', 'safequeue'
        );

        $this->registerWorker();
    }
39395
public function register()
    {
        if (!$this->isRegistered) {
            // Workaround PHP bug 42098
            // https://bugs.php.net/bug.php?id=42098
            class_exists("\\Whoops\\Exception\\ErrorException");
            class_exists("\\Whoops\\Exception\\FrameCollection");
            class_exists("\\Whoops\\Exception\\Frame");
            class_exists("\\Whoops\\Exception\\Inspector");

            set_error_handler(array($this, self::ERROR_HANDLER));
            set_exception_handler(array($this, self::EXCEPTION_HANDLER));
            register_shutdown_function(array($this, self::SHUTDOWN_HANDLER));

            $this->isRegistered = true;
        }

        return $this;
    }
1227617
public function register()
    {
        $this->app->singleton('fluxbb.server.core', function ($app) {
            $server = new Server(new ActionFactory($app));
            $this->registerActions($server);

            return $server;
        });

        $this->app->singleton('FluxBB\Server\ServerInterface', function ($app) {
            return $app->make('fluxbb.server.core');
        });

        $this->app->extend('FluxBB\Server\ServerInterface', function ($server, $app) {
            $validator = new RequestValidator($app, $server);
            $this->registerValidators($validator);

            return $validator;
        });

        $this->app->extend('FluxBB\Server\ServerInterface', function ($server, $app) {
            $authorization = new AuthorizationServer($app, $server);
            $this->registerAuthorizers($authorization);

            return $authorization;
        });
    }
236823
protected function registerMessages()
    {
        $messageTypes = [
            'error'   => ErrorMessages::class,
            'info'    => InfoMessages::class,
            'success' => SuccessMessages::class,
            'warning' => WarningMessages::class,
        ];
        foreach ($messageTypes as $messageType) {
            $this->app[WidgetsRegistryInterface::class]->registerWidget($messageType);
        }

        $this->app->singleton('sleeping_owl.message', function () use ($messageTypes) {
            return new MessageStack($messageTypes);
        });
    }
165209
public function register()
    {
        $this->instance = register_post_type($this->slug, $this->getArguments());
        $this->registerStatus();
    }
288553
public function register()
    {
        if (!defined('TDDD_PATH')) {
            define('TDDD_PATH', realpath(__DIR__.'/../../'));
        }

        $this->registerResourceWatcher();

        $this->registerService();

        $this->registerWatcher();

        $this->registerTester();

        $this->registerConfig();

        $this->registerCache();

        $this->registerWatchCommand();

        $this->registerTestCommand();

        $this->registerNotifier();

        $this->registerEventListeners();
    }
363418
public function register()
    {
        if (! $this->config->shouldIntegrateHorizon) {
            return;
        }

        $this->config->loadHorizonConfiguration();

        $this->registerServices();

        if ($this->shouldRebindHorizonRedisFactory()) {
            $this->rebindHorizonRedisFactory();
        }
    }
1249697
public function boot()
    {
        // If current environment is in the array of "notify release stages",
        // we'll re-bind the default Exception Handler to use our Bugsnag Handler
        // so exceptions will be reported to Bugsnag.
        if (in_array($this->app->environment(), config('nodes.bugsnag.notify_release_stages', []))) {
            $this->app->singleton('Illuminate\Contracts\Debug\ExceptionHandler', function ($app) {
                return app(BugsnagHandler::class);
            });
        }

        // Register publish groups
        $this->publishGroups();

        // Failed jobs listener
        $this->registerFailedJobsListener();
    }
1355790
private function registerJavascript()
    {
        $filePath = '//d2wy8f7a9ursnm.cloudfront.net/bugsnag-' . $this->version . '.js';
        if (!$this->useCdn)
        {
            $this->sourcePath = '@bower/bugsnag/src';
			$filePath = 'bugsnag.js';

			if (!file_exists(Yii::getAlias($this->sourcePath . '/' . $filePath)))
			{
				throw new InvalidConfigException('Cannot find Bugsnag.js source code.  Is bower-asset/bugsnag installed?');
			}
        }

        $this->js[] = [
            $filePath, 
            'data-apikey' => Yii::$app->bugsnag->bugsnag_api_key,
            'data-releasestage' => Yii::$app->bugsnag->releaseStage,
            'data-appversion' => Yii::$app->version,
            'position' => \yii\web\View::POS_HEAD,
        ];

        // Include this wrapper since bugsnag.js might be blocked by adblockers.  We don't want to completely die if so.
        $js = 'var Bugsnag = Bugsnag || {};';

        if (!Yii::$app->user->isGuest)
        {
            $userId = Json::htmlEncode(Yii::$app->user->id);
            $js .= "Bugsnag.user = { id: $userId };";
        }

        if (!empty(Yii::$app->bugsnag->notifyReleaseStages))
        {
            $releaseStages = Json::htmlEncode(Yii::$app->bugsnag->notifyReleaseStages);
            $js .= "Bugsnag.notifyReleaseStages = $releaseStages;";
        }

        Yii::$app->view->registerJs($js, \yii\web\View::POS_BEGIN);
    }
1001360
private function registerDetectors()
    {
        $this->singleton(Contracts\Detectors\CrawlerDetector::class, function (AppContract $app) {
            /** @var  \Illuminate\Http\Request  $request */
            $request = $app['request'];

            return new Detectors\CrawlerDetector(
                new \Jaybizzle\CrawlerDetect\CrawlerDetect(
                    $request->headers->all(),
                    $request->server('HTTP_USER_AGENT')
                )
            );
        });

        $this->singleton(Contracts\Detectors\DeviceDetector::class,   Detectors\DeviceDetector::class);
        $this->singleton(Contracts\Detectors\GeoIpDetector::class,    Detectors\GeoIpDetector::class);
        $this->singleton(Contracts\Detectors\LanguageDetector::class, Detectors\LanguageDetector::class);
    }
58220
public function register()
    {
        // Add database driver.
        $this->app->resolving('db', function ($db)
        {
            $db->extend('mongodb', function ($config)
            {
                return new Connection($config);
            });
        });
    }
1309161
protected function registerFailedJobsListener()
    {
        if (!in_array($this->app->environment(), config('nodes.bugsnag.notify_release_stages', []))) {
            return;
        }

        $shouldReport = config('nodes.bugsnag.report_failed_jobs');

        if ($shouldReport) {
            Queue::failing(function (JobFailed $event) {
                $exception = $event->exception;
                $meta = [
                    'job' => [
                        'name'     => $event->job->getName(),
                        'queue'    => $event->job->getQueue(),
                        'raw_body' => $event->job->getRawBody(),
                    ],
                    'connection' => [
                        'name' => $event->connectionName,
                    ],
                ];

                app('nodes.bugsnag')->notifyException($exception, function (\Bugsnag\Report $report) use ($meta) {
                    $report->setMetaData($meta, true);
                });
            });
        }
    }
1252237
private function registerExceptionHandler()
    {
        $handler = $this->app[ExceptionHandlerContract::class];

        $this->singleton(ExceptionHandlerContract::class, function ($app) use ($handler) {
            return new Exceptions\Handler($app[Contracts\Tracker::class], $handler);
        });
    }
102391
protected function registerLogger()
    {
        $this->app->singleton('bugsnag.logger', function ($app) {
            return new Logger($app['bugsnag']);
        });

        $this->app->alias('bugsnag.logger', Logger::class);
    }
771299
public function init()
    {
        if (TIGA_DEBUG == true && !$this->app->isConsole()) {
            $whoops = new \Whoops\Run();

            if ($this->app['request']->isJson()) {
                $whoops->pushHandler(new \Whoops\Handler\JsonResponseHandler());
            } else {
                $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
            }

            $whoops->register();
        }
    }