Skip to content

Commit

Permalink
v3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Giacomo Terreni committed Mar 9, 2020
1 parent b964b53 commit 86e9c6e
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 11 deletions.
40 changes: 38 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

## 3.0 - 2020-03-06
## 3.0 - 2020-03-09
### Changed
- `composer.json` updated for Laravel 7.x

## 2.4 - 2020-03-09
### Changed
- Force the detection of the domain when trying to access to domain info if the domain has never been detected
- Improved tests

## 2.3 - 2020-01-17
### Changed
- README.md: added notes on `storage:link` command
Expand All @@ -28,6 +33,11 @@ skipped and not replicated in the new .env.<domain> file
### Changed
- `composer.json` updated for Laravel 6.x

## 1.4.4 - 2020-03-09
### Changed
- Force the detection of the domain when trying to access to domain info if the domain has never been detected
- Improved tests

## 1.4.3 - 2020-01-17
### Changed
- README.md: added notes on `storage:link` command
Expand All @@ -47,6 +57,11 @@ skipped and not replicated in the new .env.<domain> file
### Changed
- `composer.json` updated for Laravel 5.8

## 1.3.4 - 2020-03-09
### Changed
- Force the detection of the domain when trying to access to domain info if the domain has never been detected
- Improved tests

## 1.3.3 - 2020-01-17
### Changed
- README.md: added notes on `storage:link` command
Expand All @@ -68,6 +83,11 @@ skipped and not replicated in the new .env.<domain> file
- Bugfix in `Gecche\Multidomain\Queue\Listener` due to changes in handling
worker commands in the parent class.

## 1.2.4 - 2020-03-09
### Changed
- Force the detection of the domain when trying to access to domain info if the domain has never been detected
- Improved tests

## 1.2.3 - 2020-01-17
### Changed
- README.md: added notes on `storage:link` command
Expand All @@ -87,6 +107,11 @@ skipped and not replicated in the new .env.<domain> file
### Changed
- `composer.json` updated for Laravel 5.6

## 1.1.10 - 2020-03-09
### Changed
- Force the detection of the domain when trying to access to domain info if the domain has never been detected
- Improved tests

## 1.1.9 - 2020-01-17
### Changed
- README.md: added notes on `storage:link` command
Expand Down Expand Up @@ -138,19 +163,30 @@ Laravel release starting from 5.5 and as pointed out in the docs)
### Added
- Initial version for Laravel 5.5.

[Unreleased]: https://github.com/gecche/laravel-multidomain/compare/v2.2...HEAD
[Unreleased]: https://github.com/gecche/laravel-multidomain/compare/v3.0...HEAD
[3.0]: https://github.com/gecche/laravel-multidomain/compare/v2.4...v3.0
[2.4]: https://github.com/gecche/laravel-multidomain/compare/v2.3...v2.4
[2.3]: https://github.com/gecche/laravel-multidomain/compare/v2.2...v2.3
[2.2]: https://github.com/gecche/laravel-multidomain/compare/v2.1...v2.2
[2.1]: https://github.com/gecche/laravel-multidomain/compare/v2.0...v2.1
[2.0]: https://github.com/gecche/laravel-multidomain/compare/v1.4.0...v2.0
[1.4.4]: https://github.com/gecche/laravel-multidomain/compare/v1.4.3...v1.4.4
[1.4.3]: https://github.com/gecche/laravel-multidomain/compare/v1.4.2...v1.4.3
[1.4.2]: https://github.com/gecche/laravel-multidomain/compare/v1.4.1...v1.4.2
[1.4.1]: https://github.com/gecche/laravel-multidomain/compare/v1.4.0...v1.4.1
[1.4.0]: https://github.com/gecche/laravel-multidomain/compare/v1.3.0...v1.4.0
[1.3.4]: https://github.com/gecche/laravel-multidomain/compare/v1.3.3...v1.3.4
[1.3.3]: https://github.com/gecche/laravel-multidomain/compare/v1.3.2...v1.3.3
[1.3.2]: https://github.com/gecche/laravel-multidomain/compare/v1.3.1...v1.3.2
[1.3.1]: https://github.com/gecche/laravel-multidomain/compare/v1.3.0...v1.3.1
[1.3.0]: https://github.com/gecche/laravel-multidomain/compare/v1.2.0...v1.3.0
[1.2.4]: https://github.com/gecche/laravel-multidomain/compare/v1.2.3...v1.2.4
[1.2.3]: https://github.com/gecche/laravel-multidomain/compare/v1.2.2...v1.2.3
[1.2.2]: https://github.com/gecche/laravel-multidomain/compare/v1.2.1...v1.2.2
[1.2.1]: https://github.com/gecche/laravel-multidomain/compare/v1.2.0...v1.2.1
[1.2.0]: https://github.com/gecche/laravel-multidomain/compare/v1.1.6...v1.2.0
[1.1.10]: https://github.com/gecche/laravel-multidomain/compare/v1.1.9...v1.1.10
[1.1.9]: https://github.com/gecche/laravel-multidomain/compare/v1.1.8...v1.1.9
[1.1.8]: https://github.com/gecche/laravel-multidomain/compare/v1.1.7...v1.1.8
[1.1.7]: https://github.com/gecche/laravel-multidomain/compare/v1.1.6...v1.1.7
[1.1.6]: https://github.com/gecche/laravel-multidomain/compare/v1.1.5...v1.1.6
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![Laravel](https://img.shields.io/badge/Laravel-5.x-orange.svg?style=flat-square)](http://laravel.com)
[![Laravel](https://img.shields.io/badge/Laravel-6.x-orange.svg?style=flat-square)](http://laravel.com)
[![Laravel](https://img.shields.io/badge/Laravel-7.x-orange.svg?style=flat-square)](http://laravel.com)
[![License](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://tldrlegal.com/license/mit-license)

# laravel-multidomain
Expand All @@ -25,6 +26,7 @@ for each such customer.
5.7.x | 1.3.x
5.8.x | 1.4.x
6.x | 2.x
7.x | 3.x

#### Further notes on Compatibility

Expand Down
47 changes: 38 additions & 9 deletions src/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Gecche\Multidomain\Foundation;

use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Support\Env;

class Application extends \Illuminate\Foundation\Application
Expand All @@ -14,11 +13,18 @@ class Application extends \Illuminate\Foundation\Application
*/
protected $environmentFile = null;

/**
* @var bool
*
* False is the domain has never been detected
*/
protected $domainDetected = false;

/**
* Detect the application's current domain.
*
* @param array|string $envs
* @return string
* @param array|string $envs
* @return void;
*/
public function detectDomain()
{
Expand All @@ -32,6 +38,22 @@ public function detectDomain()
$this['domain'] = $domain_name;
$this['domain_scheme'] = $domain_scheme;
$this['domain_port'] = $domain_port;

$this->domainDetected = true;
return;
}


/**
* Force the detection of the domain if it has never been detected.
* It should not happens in standard flow.
*
* @return void;
*/
protected function checkDomainDetection()
{
if (!$this->domainDetected)
$this->detectDomain();
return;
}

Expand All @@ -42,6 +64,9 @@ public function detectDomain()
*/
public function domain()
{

$this->checkDomainDetection();

if (count(func_get_args()) > 0) {
return in_array($this['domain'], func_get_args());
}
Expand All @@ -57,6 +82,8 @@ public function domain()
*/
public function fullDomain()
{
$this->checkDomainDetection();

if (count(func_get_args()) > 0) {
return in_array($this['full_domain'], func_get_args());
}
Expand All @@ -83,13 +110,10 @@ public function environmentFile()
*/
public function environmentFileDomain($domain = null)
{
$this->checkDomainDetection();

if (is_null($domain)) {
try {
$domain = $this['domain'];
} catch (BindingResolutionException $e) {
$this->detectDomain();
$domain = $this['domain'];
}
$domain = $this['domain'];
}
$filePath = rtrim($this['path.base'], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
$file = '.env.' . $domain;
Expand All @@ -107,6 +131,9 @@ public function environmentFileDomain($domain = null)
*/
public function domainStoragePath($domain = null)
{

$this->checkDomainDetection();

if (is_null($domain)) {
$domain = $this['domain'];
}
Expand Down Expand Up @@ -178,6 +205,8 @@ protected function getDomainCachedFileDefault($default)
if ($envFile && $envFile == '.env')
return $default;

$this->checkDomainDetection();

$defaultWithoutPhpExt = substr($default,0,-4);

return $defaultWithoutPhpExt.'-'.domain_sanitized($this['domain']).'.php';
Expand Down

0 comments on commit 86e9c6e

Please sign in to comment.