Created
May 3, 2012 13:39
-
-
Save zanematthew/2585716 to your computer and use it in GitHub Desktop.
This is a snippet from bootstrap.php which acts as an auto loader based on scan dir.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This will auto load the following and/or create files if needed. | |
// | |
// plugin/controllers/$post_type_controller.php | |
// plugin/models/$post_type.php | |
// plugin/assets/stylesheets/$post_type.php | |
// plugin/assets/javascripts/$post_type.php | |
// | |
// note as of now the oder of the files is not important, we'll cross | |
// that bridge when we get to it. | |
foreach( $tmp_controllers as $controller ) { | |
/** | |
* autoload Controllers | |
*/ | |
require_once CONTROLLERS_ROOT_DIR . $controller; | |
// Return just the first part of our controller | |
$name = array_shift( explode( '_', $controller ) ); | |
/** | |
* Models | |
*/ | |
if ( file_exists( MODELS_ROOT_DIR . $name . '.php' ) ) | |
require_once MODELS_ROOT_DIR . $name . '.php'; | |
/** | |
* Add our stylesheets to our global array | |
*/ | |
if ( file_exists( CSS_ROOT_DIR . $name . '.css' ) ) { | |
$_styles[] = CSS_DIR . $name . '.css'; | |
} else { | |
@file_put_contents( CSS_ROOT_DIR . $name . '.css', "/*This is your css file for the {$name} model, controller */"); | |
} | |
/** | |
* Add our javascript to our global array | |
*/ | |
if ( file_exists( JS_ROOT_DIR . $name . '.js' ) ) { | |
$_scripts[] = JS_DIR . $name . '.js'; | |
} else { | |
@file_put_contents( JS_ROOT_DIR . $name . '.js', "/*This is your js file for the {$name} model, controller */"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment