Commit 9d089975 authored by Jon Pugh's avatar Jon Pugh

Renaming ContextSubscriber to ServiceSubscriber and ContextProvider to...

Renaming ContextSubscriber to ServiceSubscriber and ContextProvider to ServiceProvider. Moving getServices() and service() to Context.php
parent 9056c25c
......@@ -312,6 +312,25 @@ class Context implements BuilderAwareInterface
}
}
/**
* Return all services this context provides.
*
* @return array
*/
public function getServices() {
return $this->services;
}
/**
* Return all services for this context.
*
* @return \Aegir\Provision\Service
*/
public function service($type)
{
return $this->getService($type);
}
/**
* {@inheritdoc}
*/
......
......@@ -3,7 +3,7 @@
namespace Aegir\Provision\Context;
use Aegir\Provision\Application;
use Aegir\Provision\ContextSubscriber;
use Aegir\Provision\ServiceSubscriber;
use Aegir\Provision\Provision;
use Symfony\Component\Config\Definition\ConfigurationInterface;
......@@ -14,7 +14,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
*
* @see \Provision_Context_platform
*/
class PlatformContext extends ContextSubscriber implements ConfigurationInterface
class PlatformContext extends ServiceSubscriber implements ConfigurationInterface
{
/**
* @var string
......
......@@ -3,7 +3,7 @@
namespace Aegir\Provision\Context;
use Aegir\Provision\Console\Config;
use Aegir\Provision\ContextProvider;
use Aegir\Provision\ServiceProvider;
use Aegir\Provision\Property;
use Aegir\Provision\Provision;
use Aegir\Provision\Service\DockerServiceInterface;
......@@ -20,7 +20,7 @@ use Symfony\Component\Yaml\Yaml;
*
* @see \Provision_Context_server
*/
class ServerContext extends ContextProvider implements ConfigurationInterface
class ServerContext extends ServiceProvider implements ConfigurationInterface
{
/**
* @var string
......
......@@ -3,8 +3,7 @@
namespace Aegir\Provision\Context;
use Aegir\Provision\Application;
use Aegir\Provision\Context;
use Aegir\Provision\ContextSubscriber;
use Aegir\Provision\ServiceSubscriber;
use Aegir\Provision\Provision;
use Symfony\Component\Config\Definition\ConfigurationInterface;
......@@ -15,7 +14,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
*
* @see \Provision_Context_site
*/
class SiteContext extends ContextSubscriber implements ConfigurationInterface
class SiteContext extends ServiceSubscriber implements ConfigurationInterface
{
/**
* @var string
......
<?php
/**
* @file
* Provides the Aegir\Provision\ContextSubscriber class.
* Provides the Aegir\Provision\ServiceProvider class.
*
*
......@@ -9,17 +9,14 @@
namespace Aegir\Provision;
use Symfony\Component\Config\Definition\ConfigurationInterface;
/**
* Class ContextProvider
* Class ServiceProvider
*
* Context class for a provider of services. Typically ServerContext
*
* @package Aegir\Provision
*/
class ContextProvider extends Context
class ServiceProvider extends Context
{
const ROLE = 'provider';
......@@ -32,26 +29,6 @@ class ContextProvider extends Context
$this->services[$service_name] = new $service_class($service, $this);
}
}
/**
* Return all services this context provides.
*
* @return array
*/
public function getServices() {
return $this->services;
}
/**
* Return all services for this context.
*
* @return \Aegir\Provision\Service
*/
public function service($type)
{
return $this->getService($type);
}
/**
* Loads service properties into the config tree.
......@@ -61,17 +38,14 @@ class ContextProvider extends Context
$root_node
->attribute('context', $this)
->children()
->arrayNode('services')
->prototype('array')
->children()
->scalarNode('type')
->isRequired(true)
->end()
->append($this->addServiceProperties('services'))
->end()
->arrayNode('services')
->prototype('array')
->children()
->scalarNode('type')
->isRequired(true)
->end()
->append($this->addServiceProperties('services'))
->end()
->end();
}
}
......@@ -10,13 +10,13 @@
namespace Aegir\Provision;
/**
* Class ContextSubscriber
* Class ServiceSubscriber
*
* Context class for those consuming services, typically sites & platforms.
*
* @package Aegir\Provision
*/
class ContextSubscriber extends Context
class ServiceSubscriber extends Context
{
const ROLE = 'subscriber';
......@@ -69,19 +69,11 @@ class ContextSubscriber extends Context
throw new \Exception("Service subscription '$type' does not exist in the context '{$this->name}'.");
}
}
/**
* Return an array of Service classes.
* @return array
* Loads service_subscriptions properties into the config tree.
* @param $root_node
*/
public function getServices() {
$services = [];
foreach ($this->getSubscriptions() as $service => $subscription) {
$services[$service] = $subscription->service;
}
return $services;
}
protected function servicesConfigTree(&$root_node) {
$root_node
->attribute('context', $this)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment