Last active
August 29, 2015 14:25
-
-
Save toomuchpete/ec2538b23d62fab99c2d to your computer and use it in GitHub Desktop.
Module Autoloader
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 | |
function loadThingsMagically($folder_path) { | |
// Cache pre-existing | |
$preExistingClasses = count(get_declared_classes()); | |
requireAllFromFolder($folder_path); | |
foreach (array_slice(get_declared_classes(), $preExistingClasses) as $class) { | |
if (method_exists($class, 'loadCoolModule')) { | |
$class::loadCoolModule(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment