Commit 31a41cc3 authored by Jon Pugh's avatar Jon Pugh

Move getService and hasService to Context.php

parent 00cf999a
......@@ -37,7 +37,7 @@ class Context implements BuilderAwareInterface
use BuilderAwareTrait;
use ProvisionAwareTrait;
/**
* @var string
* Name for saving aliases and referencing.
......@@ -71,7 +71,13 @@ class Context implements BuilderAwareInterface
* init(), set defaults with setProperty().
*/
protected $properties = [];
/**
* @var array
* A list of services provided by or subscribed to by this context.
*/
protected $services = [];
/**
* @var \Symfony\Component\Filesystem\Filesystem
*/
......@@ -274,6 +280,38 @@ class Context implements BuilderAwareInterface
];
}
/**
* Return a specific service provided by this context.
*
* @param $type
*
* @return \Aegir\Provision\Service
*/
public function getService($type) {
if (isset($this->services[$type])) {
return $this->services[$type];
}
else {
throw new \Exception("Service '$type' does not exist in the context '{$this->name}'.");
}
}
/**
* Whether or not this Server has a service.
*
* @param $type
* @return bool
*/
public function hasService($type) {
if (isset($this->services[$type])) {
return TRUE;
}
else {
return FALSE;
}
}
/**
* {@inheritdoc}
*/
......
......@@ -22,14 +22,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
class ContextProvider extends Context
{
const ROLE = 'provider';
/**
* @var array
* A list of services provided by this context.
*/
protected $services = [];
/**
* Load Service classes from config into Context.
*/
......@@ -48,38 +41,7 @@ class ContextProvider extends Context
public function getServices() {
return $this->services;
}
/**
* Return a specific service provided by this context.
*
* @param $type
*
* @return \Aegir\Provision\Service
*/
public function getService($type) {
if (isset($this->services[$type])) {
return $this->services[$type];
}
else {
throw new \Exception("Service '$type' does not exist in the context '{$this->name}'.");
}
}
/**
* Whether or not this Server has a service.
*
* @param $type
* @return bool
*/
public function hasService($type) {
if (isset($this->services[$type])) {
return TRUE;
}
else {
return FALSE;
}
}
/**
* Return all services for this context.
*
......
......@@ -99,19 +99,4 @@ class ContextSubscriber extends Context
->end()
->end();
}
/**
* Whether or not this Server has a service.
*
* @param $type
* @return bool
*/
public function hasService($type) {
if (isset($this->services[$type])) {
return TRUE;
}
else {
return FALSE;
}
}
}
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