Skip to content
GitLab
Explore
Sign in
project
provision
Compare revisions
127503149adb2f4b379a0a26fed4343121587f10 to 4.x-services
Commits on Source (5)
Add ServiceSubscription class and use that instead of Service on all non-server contexts.
· 088401df
Jon Pugh
authored
Oct 26, 2017
088401df
Make sure there are enough items in the list of servers and services.
· 83919d63
Jon Pugh
authored
Oct 26, 2017
83919d63
Remove shell command for now.
· 0167b213
Jon Pugh
authored
Oct 26, 2017
0167b213
Generate http_vhostd_path in SiteConfiguration and add vhost.tpl.php file.
· 1c68f8df
Jon Pugh
authored
Nov 02, 2017
1c68f8df
Merge branch '4.x-services' of git.drupal.org:project/provision into 4.x-services
· c8625f17
Jon Pugh
authored
Nov 02, 2017
c8625f17
Hide whitespace changes
Inline
Side-by-side
src/Application.php
View file @
c8625f17
...
...
@@ -124,7 +124,7 @@ class Application extends BaseApplication
$commands
[]
=
new
ListCommand
();
$commands
[]
=
new
SaveCommand
();
$commands
[]
=
new
ServicesCommand
();
$commands
[]
=
new
ShellCommand
();
//
$commands[] = new ShellCommand();
$commands
[]
=
new
StatusCommand
();
$commands
[]
=
new
VerifyCommand
();
...
...
src/Command/ServicesCommand.php
View file @
c8625f17
...
...
@@ -8,6 +8,7 @@ use Aegir\Provision\Context\PlatformContext;
use
Aegir\Provision\Context\ServerContext
;
use
Aegir\Provision\Context\SiteContext
;
use
Consolidation\AnnotatedCommand\CommandFileDiscovery
;
use
Symfony\Component\Console\Exception\LogicException
;
use
Symfony\Component\Console\Input\ArrayInput
;
use
Symfony\Component\Console\Input\InputInterface
;
use
Symfony\Component\Console\Input\InputDefinition
;
...
...
@@ -123,6 +124,10 @@ class ServicesCommand extends Command
// If server, ask which service type.
if
(
$this
->
context
->
type
==
'server'
)
{
if
(
empty
(
$this
->
context
->
getServiceTypeOptions
(
$service
)))
{
throw
new
\Exception
(
"There was no class found for service
$service
. Create one named
\\
Aegir
\\
Provision
\\
Service
\\
{
$service
}
Service"
);
}
$service_type
=
$this
->
io
->
choice
(
'Which service type?'
,
$this
->
context
->
getServiceTypeOptions
(
$service
));
// Then ask for all options.
...
...
@@ -137,6 +142,10 @@ class ServicesCommand extends Command
}
// All other context types are associating with servers that provide the service.
else
{
if
(
empty
(
$this
->
getApplication
()
->
getServerOptions
(
$service
)))
{
throw
new
\Exception
(
"No servers providing
$service
service were found. Create one with `provision save` or use `provision services` to add to an existing server."
);
}
$server
=
$this
->
io
->
choice
(
'Which server?'
,
$this
->
getApplication
()
->
getServerOptions
(
$service
));
// Then ask for all options.
...
...
src/Context.php
View file @
c8625f17
...
...
@@ -136,10 +136,7 @@ class Context
elseif
(
isset
(
$this
->
config
[
'service_subscriptions'
]))
{
foreach
(
$this
->
config
[
'service_subscriptions'
]
as
$service_name
=>
$service
)
{
$this
->
servers
[
$service_name
]
=
$server
=
$this
->
application
->
getContext
(
$service
[
'server'
]);
$service_type
=
ucfirst
(
$server
->
services
[
$service_name
]
->
type
);
$service_name
=
ucfirst
(
$service_name
);
$service_class
=
"
\\
Aegir
\\
Provision
\\
Service
\\
{
$service_name
}
\\
{
$service_name
}{
$service_type
}
Service"
;
$this
->
services
[
strtolower
(
$service_name
)]
=
new
$service_class
(
$service
,
$this
);
$this
->
services
[
$service_name
]
=
new
ServiceSubscription
(
$this
,
$server
,
$service_name
);
}
}
else
{
...
...
@@ -346,9 +343,24 @@ class Context
*/
public
function
showServices
(
DrupalStyle
$io
)
{
if
(
!
empty
(
$this
->
getServices
()))
{
$is_server
=
$this
->
type
==
'server'
;
$rows
=
[];
$headers
=
$is_server
?
[
'Services'
]
:
[
'Service'
,
'Server'
,
'Type'
];
foreach
(
$this
->
getServices
()
as
$name
=>
$service
)
{
$rows
[]
=
[
$name
,
$service
->
type
];
if
(
$is_server
)
{
$rows
[]
=
[
$name
,
$service
->
type
];
}
else
{
$rows
[]
=
[
$name
,
$service
->
server
->
name
,
$service
->
server
->
getService
(
$name
)
->
type
];
}
// Show all properties.
if
(
!
empty
(
$service
->
properties
))
{
...
...
@@ -357,7 +369,7 @@ class Context
}
}
}
$io
->
table
(
[
'Services'
]
,
$rows
);
$io
->
table
(
$headers
,
$rows
);
}
}
...
...
src/Context/SiteContext.php
View file @
c8625f17
...
...
@@ -33,15 +33,18 @@ class SiteContext extends Context implements ConfigurationInterface
parent
::
__construct
(
$name
,
$console_config
,
$application
,
$options
);
// Load "db_server" context.
if
(
isset
(
$this
->
config
[
'
db_
serv
er
'
]))
{
$this
->
db_server
=
$application
->
getContext
(
$this
->
config
[
'service_subscriptions'
][
'db'
][
'server'
]);
$this
->
db_server
->
logger
=
$application
->
logger
;
//
if (isset($this->config['serv
ice_subscriptions']['db
'])) {
//
$this->db_server = $application->getContext($this->config['service_subscriptions']['db']['server']);
//
}
$this
->
platform
=
$application
->
getContext
(
$this
->
config
[
'platform'
]);
}
else
{
throw
new
\Exception
(
'No db_server found.'
);
$this
->
logger
=
$application
->
logger
;
if
(
isset
(
$this
->
config
[
'platform'
]))
{
$this
->
platform
=
$application
->
getContext
(
$this
->
config
[
'platform'
]
);
}
}
static
function
option_documentation
()
...
...
src/Service/Http/Apache/Configuration/SiteConfiguration.php
View file @
c8625f17
...
...
@@ -55,5 +55,16 @@ class SiteConfiguration extends Configuration {
$this
->
template
=
$this
->
disabled_template
;
}
$app_dir
=
$this
->
context
->
console_config
[
'config_path'
]
.
'/'
.
$this
->
service
->
getType
();
// $this->data['http_port'] = $this->service->properties['http_port'];
// $this->data['include_statement'] = '# INCLUDE STATEMENT';
// $this->data['http_pred_path'] = "{$app_dir}/pre.d";
// $this->data['http_postd_path'] = "{$app_dir}/post.d";
// $this->data['http_platformd_path'] = "{$app_dir}/platform.d";
// $this->data['extra_config'] = "";
$this
->
data
[
'http_vhostd_path'
]
=
"
{
$app_dir
}
/vhost.d"
;
}
}
\ No newline at end of file
src/ServiceSubscription.php
0 → 100644
View file @
c8625f17
<?php
/**
* @file
* A context's subscription to a service. Handles properties specific to a
* context for each service.
*
* @see Provision_Service
*/
namespace
Aegir\Provision
;
class
ServiceSubscription
{
public
$context
;
public
$service
;
public
$server
;
public
$type
;
function
__construct
(
$context
,
$server
,
$service_name
)
{
$this
->
context
=
$context
;
$this
->
server
=
$server
;
$this
->
service
=
$server
->
getService
(
$service_name
);
$this
->
type
=
$server
->
getService
(
$service_name
)
->
type
;
}
}