/** * {@inheritdoc} */ public function send(Swift_Mime_Message $message, &$failedRecipients = null) { $mailmanMessage = new MailmanMimeMessage($message); $this->beforeSendPerformed($message); // Deny email delivery if environment is not allowed in the config if (!in_array($this->app->environment(), config('mailman.delivery.environments'))) { $mailmanMessage->deny(); $recipients = array_keys($mailmanMessage->getTo()); $allowedRecipients = config('mailman.delivery.recipients'); $recipientsDiff = array_diff($recipients, $allowedRecipients); // If all recipients are allowed to receive emails // from denied environments - allow email delivery. if (count($recipientsDiff) === 0) { $mailmanMessage->allow(); } } else { $mailmanMessage->allow(); } if (config('mailman.log.enabled')) { $logger = app('mailman.logger'); $logger->log($mailmanMessage); } if ($mailmanMessage->allowed()) { /** @var Swift_Transport $transport */ $transport = $this->app['swift.transport']->driver(config('mailman.delivery.driver')); with(new Swift_Mailer($transport))->send($mailmanMessage->getSwiftMessage()); } }
public function path($extension) { $type = $this->config->get('assets.types.' . $extension); if ($this->app->environment() == 'local') { return $this->asset($type['origin_dir']); } return $this->asset($type['dist_dir']) . '/' . $this->cache->get('laravel-asset-versioning.version'); }
protected function shouldCatchErrors($default = true, $production_default = false) { if ($this->app->environment() == 'production') { return $production_default; } else { return $default; } }
/** * Constructor. */ public function __construct(RollbarNotifier $rollbar, Application $app, $level = 'debug') { $this->rollbar = $rollbar; $this->app = $app; $this->level = $this->parseLevel($level ?: 'debug'); // Set Laravel information $this->rollbar->environment = $this->app['config']->get('services.rollbar.environment', $this->app->environment()); $this->rollbar->root = base_path(); }
protected function getSiteName() { $title = $this->config->get('c::site.html-name') ?: ($this->config->get('c::site.name') ?: $this->config->get('app.url')); $env = $this->app->environment(); if ($env !== 'production') { $title .= ' <strong>' . strtoupper($env) . '</strong>'; } return $title; }
/** * Add Laravel specific information to the context. * * @param array $context */ protected function addContext(array $context = []) { // Add session data. if ($session = $this->app->session->all()) { if (empty($context['user']) or !is_array($context['user'])) { $context['user'] = []; } if (isset($context['user']['data'])) { $context['user']['data'] = array_merge($session, $context['user']['data']); } else { $context['user']['data'] = $session; } // User session id as user id if not set. if (!isset($context['user']['id'])) { $context['user']['id'] = $this->app->session->getId(); } } // Automatic tags $tags = ['environment' => $this->app->environment(), 'server' => $this->app->request->server('HTTP_HOST')]; // Add tags to context. if (isset($context['tags'])) { $context['tags'] = array_merge($tags, $context['tags']); } else { $context['tags'] = $tags; } // Automatic extra data. $extra = ['ip' => $this->app->request->getClientIp()]; // Everything that is not 'user', 'tags' or 'level' is automatically considered // as additonal 'extra' context data. $extra = array_merge($extra, array_except($context, ['user', 'tags', 'level', 'extra'])); // Add extra to context. if (isset($context['extra'])) { $context['extra'] = array_merge($extra, $context['extra']); } else { $context['extra'] = $extra; } // Clean out other values from context. $context = array_only($context, ['user', 'tags', 'level', 'extra']); return $context; }
/** * @param Filesystem $filesystem * @param Application $app */ public function __construct(Filesystem $filesystem, Application $app) { $this->app = $app; $this->env = $this->app->environment(); $this->file = $filesystem; $this->configFile = $this->app['path'] . '/config/app.php'; /* Adding environment-specific packages has some nuances See: https://github.com/laravel/framework/issues/1603 https://github.com/barryvdh/laravel-debugbar/issues/86 https://github.com/laravel/framework/issues/3327 So at the moment this is at stage of TODO if ($this->env === 'production') { $this->configFile = $this->app['path'] . '/config/app.php'; } else { $this->configFile = $this->app['path'] . '/config/' . $this->env . '/app.php'; if (!$this->file->exists($this->configFile)) { $this->file->copy(__DIR__ . '/app.config.stub', $this->configFile); } } */ }
/** * Add Laravel specific information to the context. * * @param array $context */ protected function addContext(array $context = []) { // Add session data. if ($session = $this->app->session->all()) { if (empty($context['user']) or !is_array($context['user'])) { $context['user'] = []; } if (isset($context['user']['data'])) { $context['user']['data'] = array_merge($session, $context['user']['data']); } else { $context['user']['data'] = $session; } // User session id as user id if not set. if (!isset($context['user']['id'])) { $context['user']['id'] = $this->app->session->getId(); } } try { $gitBranch = implode('/', array_slice(explode('/', file_get_contents(app_path() . '/../.git/HEAD')), 2)); } catch (Exception $e) { $gitBranch = 'undefined'; } // Automatic tags $tags = ['branch' => $gitBranch, 'environment' => $this->app->environment(), 'server' => $this->app->request->server('HTTP_HOST')]; // Add tags to context. if (isset($context['tags'])) { $context['tags'] = array_merge($tags, $context['tags']); } else { $context['tags'] = $tags; } // Automatic extra data. $extra = ['ip' => $this->app->request->getClientIp()]; // Everything that is not 'user', 'tags' or 'level' is automatically considered // as additonal 'extra' context data. $extra = array_merge($extra, array_except($context, ['user', 'tags', 'level', 'extra'])); // Add extra to context. if (isset($context['extra'])) { $context['extra'] = array_merge($extra, $context['extra']); } else { $context['extra'] = $extra; } // Clean out other values from context. $context = array_only($context, ['user', 'tags', 'level', 'extra']); return $context; }
/** * Get or check the current application environment. * * @param mixed * @return string * @static */ public static function environment() { return \Illuminate\Foundation\Application::environment(); }
private function isTrackableEnvironment() { return !in_array($this->laravel->environment(), $this->config->get('do_not_track_environments')); }
/** * The confirmation text to show * * @return string */ public function getConfirmationText() { return 'Application in ' . ucfirst($this->app->environment()); }
function it_should_not_confirm_when_not_in_configured_enivronment(Application $app, Repository $config) { $config->get('guardian::environments')->willReturn(['local']); $app->environment('local')->willReturn(false); $this->needsConfirmation()->shouldBe(false); }
/** * Create a new SaveUrlMiddleware instance * * @param Store $store * @param Config $config * @return void */ public function __construct(Application $app) { $this->store = $app['session.store']; $this->sessionKey = $app['config']->get('save-url.session-key'); $this->isRunningInConsole = !$app->environment('testing') && $app->runningInConsole(); }