mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-08-29 17:46:02 +08:00
SuiteCRM 8 initial commit
This commit is contained in:
commit
c895877b7e
547 changed files with 40449 additions and 0 deletions
42
core/base/Config/Loader/YamlLoader.php
Normal file
42
core/base/Config/Loader/YamlLoader.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace SuiteCRM\Core\Base\Config\Loader;
|
||||
|
||||
use Exception;
|
||||
use Symfony\Component\Config\Loader\FileLoader;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
/**
|
||||
* Class YamlLoader
|
||||
* @package SuiteCRM\Core\Base\Config\Loader
|
||||
*/
|
||||
class YamlLoader extends FileLoader
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mixed $resource The resource
|
||||
* @param string|null $type The resource type or null if unknown
|
||||
* @return mixed The YAML converted to a PHP value
|
||||
* @throws Exception
|
||||
*/
|
||||
public function load($resource, $type = null)
|
||||
{
|
||||
$contents = file_get_contents($resource);
|
||||
|
||||
return Yaml::parse($contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $resource
|
||||
* @param null $type
|
||||
* @return bool
|
||||
*/
|
||||
public function supports($resource, $type = null): bool
|
||||
{
|
||||
return is_string($resource) && 'yml' === pathinfo(
|
||||
$resource,
|
||||
PATHINFO_EXTENSION
|
||||
);
|
||||
}
|
||||
}
|
65
core/base/Config/Manager.php
Normal file
65
core/base/Config/Manager.php
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace SuiteCRM\Core\Base\Config;
|
||||
|
||||
use SuiteCRM\Core\Base\Config\Loader\YamlLoader;
|
||||
use SuiteCRM\Core\Base\Helper\Data\CollectionInterface;
|
||||
use SuiteCRM\Core\Base\Helper\File\FileMapperInterface;
|
||||
use SuiteCRM\Core\Base\Config\ParameterCollection;
|
||||
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Loader\DelegatingLoader;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
|
||||
/**
|
||||
* Class Manager
|
||||
* @package SuiteCRM\Core\Base\Config
|
||||
*/
|
||||
class Manager implements FileMapperInterface
|
||||
{
|
||||
/**
|
||||
* Load the current configuration files
|
||||
*
|
||||
* @param bool $config_paths The config paths to load resources
|
||||
* @return CollectionInterface
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function loadFiles($config_paths = false): CollectionInterface
|
||||
{
|
||||
if ($config_paths === false) {
|
||||
throw new \RuntimeException('Config paths need to be set up correctly');
|
||||
}
|
||||
|
||||
// Get array from config paths
|
||||
$configPaths = (array)$config_paths;
|
||||
|
||||
$fileLocator = new FileLocator($configPaths);
|
||||
|
||||
// Check paths exists
|
||||
foreach ($configPaths as $path) {
|
||||
$fileLocator->locate($path);
|
||||
}
|
||||
|
||||
$loaderResolver = new LoaderResolver([new YamlLoader($fileLocator)]);
|
||||
|
||||
$delegatingLoader = new DelegatingLoader($loaderResolver);
|
||||
|
||||
// All config parameters
|
||||
$allParameters = [];
|
||||
|
||||
if ($configPaths !== false) {
|
||||
foreach ($configPaths as $path) {
|
||||
// Load the parameters from the path resource
|
||||
$parameters = $delegatingLoader->load($path);
|
||||
|
||||
// Merge parameters together
|
||||
if (!empty($parameters)) {
|
||||
$allParameters = array_merge($allParameters, $parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ParameterCollection($allParameters);
|
||||
}
|
||||
}
|
||||
|
13
core/base/Config/ParameterCollection.php
Normal file
13
core/base/Config/ParameterCollection.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace SuiteCRM\Core\Base\Config;
|
||||
|
||||
use SuiteCRM\Core\Base\Helper\Data\Collection;
|
||||
|
||||
/**
|
||||
* Class ParameterCollection
|
||||
* @package SuiteCRM\Core\Base\Config
|
||||
*/
|
||||
class ParameterCollection extends Collection
|
||||
{
|
||||
}
|
4
core/base/Config/modules.config.yml
Normal file
4
core/base/Config/modules.config.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
modules:
|
||||
enabled:
|
||||
- Administration
|
||||
- Users
|
2
core/base/Config/services.config.yml
Normal file
2
core/base/Config/services.config.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
services:
|
||||
users.authentication: 'SuiteCRM\Core\Legacy\AuthenticationService'
|
Loading…
Add table
Add a link
Reference in a new issue