mirror of
https://github.com/flarum/core.git
synced 2025-08-03 15:07:53 +02:00
Introduce a vendor path
This lets us or anyone modify the path from where dependencies (usually installed into /vendor by Composer) are loaded. We need to be able to tweak this in our integration tests, where the application code under test needs access to certain dependencies.
This commit is contained in:
@@ -41,6 +41,20 @@ class Application extends Container implements ApplicationContract
|
||||
*/
|
||||
protected $publicPath;
|
||||
|
||||
/**
|
||||
* The custom storage path defined by the developer.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $storagePath;
|
||||
|
||||
/**
|
||||
* A custom vendor path to find dependencies in non-standard environments.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $vendorPath;
|
||||
|
||||
/**
|
||||
* Indicates if the application has "booted".
|
||||
*
|
||||
@@ -83,13 +97,6 @@ class Application extends Container implements ApplicationContract
|
||||
*/
|
||||
protected $deferredServices = [];
|
||||
|
||||
/**
|
||||
* The custom storage path defined by the developer.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $storagePath;
|
||||
|
||||
/**
|
||||
* Create a new Flarum application instance.
|
||||
*
|
||||
@@ -226,7 +233,7 @@ class Application extends Container implements ApplicationContract
|
||||
*/
|
||||
protected function bindPathsInContainer()
|
||||
{
|
||||
foreach (['base', 'public', 'storage'] as $path) {
|
||||
foreach (['base', 'public', 'storage', 'vendor'] as $path) {
|
||||
$this->instance('path.'.$path, $this->{$path.'Path'}());
|
||||
}
|
||||
}
|
||||
@@ -261,6 +268,16 @@ class Application extends Container implements ApplicationContract
|
||||
return $this->storagePath ?: $this->basePath.DIRECTORY_SEPARATOR.'storage';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to the vendor directory where dependencies are installed.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function vendorPath()
|
||||
{
|
||||
return $this->vendorPath ?: $this->basePath.DIRECTORY_SEPARATOR.'vendor';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the storage directory.
|
||||
*
|
||||
@@ -276,6 +293,21 @@ class Application extends Container implements ApplicationContract
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the vendor directory.
|
||||
*
|
||||
* @param string $path
|
||||
* @return $this
|
||||
*/
|
||||
public function useVendorPath($path)
|
||||
{
|
||||
$this->vendorPath = $path;
|
||||
|
||||
$this->instance('path.vendor', $path);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or check the current application environment.
|
||||
*
|
||||
|
@@ -100,6 +100,10 @@ class InstalledSite implements SiteInterface
|
||||
|
||||
$laravel->useStoragePath($this->paths['storage']);
|
||||
|
||||
if (isset($this->paths['vendor'])) {
|
||||
$laravel->useVendorPath($this->paths['vendor']);
|
||||
}
|
||||
|
||||
$laravel->instance('env', 'production');
|
||||
$laravel->instance('flarum.config', $this->config);
|
||||
$laravel->instance('config', $config = $this->getIlluminateConfig($laravel));
|
||||
|
@@ -59,6 +59,10 @@ class UninstalledSite implements SiteInterface
|
||||
|
||||
$laravel->useStoragePath($this->paths['storage']);
|
||||
|
||||
if (isset($this->paths['vendor'])) {
|
||||
$laravel->useVendorPath($this->paths['vendor']);
|
||||
}
|
||||
|
||||
$laravel->instance('env', 'production');
|
||||
$laravel->instance('flarum.config', []);
|
||||
$laravel->instance('config', $config = $this->getIlluminateConfig());
|
||||
|
Reference in New Issue
Block a user