Commit 23ba47b0 authored by Steven Jones's avatar Steven Jones

Merge branch 'dev/1318374-autoloader' into 6.x-2.x

parents 6aec31b1 a674ddb7
......@@ -116,14 +116,11 @@ class Provision_Config {
private function load_template() {
$class_name = get_class($this);
$reflect = new reflectionObject($this);
if (isset($this->template)) {
while ($class_name) {
// Iterate through the config file's parent classes until we
// find the template file to use.
$reflect = new reflectionClass($class_name);
$base_dir = dirname($reflect->getFilename());
$base_dir = provision_class_directory($class_name);
$file = $base_dir . '/' . $this->template;
......
......@@ -6,4 +6,4 @@
LoadModule ssl_module modules/mod_ssl.so
</IfModule>
<?php include('http/apache/server.tpl.php'); ?>
<?php include(provision_class_directory('Provision_Config_Apache_Server') . '/server.tpl.php'); ?>
......@@ -69,6 +69,6 @@ if (sizeof($this->aliases)) {
<?php endif; ?>
<?php
include('http/apache/vhost.tpl.php');
include(provision_class_directory('Provision_Config_Apache_Site') . '/vhost.tpl.php');
?>
......@@ -31,5 +31,5 @@
<?php endif; ?>
<?php
include('http/apache/vhost_disabled.tpl.php');
include(provision_class_directory('Provision_Config_Apache_Site') . '/vhost_disabled.tpl.php');
?>
<?php include('http/nginx/server.tpl.php'); ?>
<?php include(provision_class_directory('Provision_Config_Nginx_Server') . '/server.tpl.php'); ?>
#######################################################
### nginx default ssl server
......
......@@ -43,5 +43,5 @@ $nginx_has_upload_progress = drush_get_option('nginx_has_upload_progress');
<?php
// Generate the standard virtual host too.
include('http/nginx/vhost.tpl.php');
include(provision_class_directory('Provision_Config_Nginx_Site') . '/vhost.tpl.php');
?>
......@@ -23,5 +23,5 @@ server {
<?php
// Generate the standard virtual host too.
include('http/nginx/vhost_disabled.tpl.php');
include(provision_class_directory('Provision_Config_Nginx_Site') . '/vhost_disabled.tpl.php');
?>
......@@ -70,6 +70,33 @@ function provision_autoload_register_prefix($prefix, $dir, $prepend = FALSE) {
// Add our prefix to the autoloader.
provision_autoload_register_prefix('Provision_', __DIR__);
/**
* Return the directory containing the file a class is defined in.
*
* @param $class_name
* The class name to search for.
* @return
* A directory if the class can be found or an empty string if not.
*/
function provision_class_directory($class_name) {
return dirname(provision_class_file($class_name));
}
/**
* Return the file a class is defined in.
*
* @param $class_name
* The class name to search for.
* @return
* A file if the class can be found or an empty string if not.
*/
function provision_class_file($class_name) {
if (class_exists($class_name)) {
$reflect = new reflectionClass($class_name);
return $reflect->getFilename();
}
return '';
}
/**
* @defgroup sitedata Site data management utility functions.
......
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