-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathYmirConfiguration.php
More file actions
55 lines (49 loc) · 2.23 KB
/
YmirConfiguration.php
File metadata and controls
55 lines (49 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
declare(strict_types=1);
/*
* This file is part of Ymir WordPress plugin.
*
* (c) Carl Alexander <support@ymirapp.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Ymir\Plugin\Configuration;
use Ymir\Plugin\DependencyInjection\Container;
use Ymir\Plugin\DependencyInjection\ContainerConfigurationInterface;
use Ymir\Plugin\Http\CurlClient;
use Ymir\Plugin\Http\WordPressClient;
use Ymir\Plugin\ValueObject\MappedDomainNames;
/**
* Configures the dependency injection container with Ymir parameters and services.
*/
class YmirConfiguration implements ContainerConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function modify(Container $container)
{
$container['ymir_cdn_image_processing_enabled'] = $container->service(function () {
if (defined('YMIR_CDN_IMAGE_PROCESSING_ENABLED')) {
return (bool) YMIR_CDN_IMAGE_PROCESSING_ENABLED;
} elseif (false !== getenv('YMIR_CDN_IMAGE_PROCESSING_ENABLED')) {
return (bool) getenv('YMIR_CDN_IMAGE_PROCESSING_ENABLED');
}
return false;
});
$container['ymir_environment'] = getenv('YMIR_ENVIRONMENT') ?: '';
$container['ymir_http_client'] = $container->service(function (Container $container) {
return function_exists('_wp_http_get_object') ? new WordPressClient(_wp_http_get_object(), $container['ymir_plugin_version']) : new CurlClient($container['ymir_plugin_version']);
});
$container['ymir_mapped_domain_names'] = $container->service(function (Container $container) {
return new MappedDomainNames((array) explode(',', (string) getenv('YMIR_DOMAIN_NAMES')), $container['ymir_primary_domain_name']);
});
$container['ymir_primary_domain_name'] = (string) getenv('YMIR_PRIMARY_DOMAIN_NAME');
$container['ymir_project_type'] = getenv('YMIR_PROJECT_TYPE') ?: 'wordpress';
$container['ymir_plugin_version'] = '1.28.0';
$container['ymir_using_vanity_domain'] = $container->service(function (Container $container) {
return false !== stripos($container['site_url'], '.ymirsites.com');
});
}
}