-
Notifications
You must be signed in to change notification settings - Fork 0
Usage
halmhatt edited this page Sep 18, 2012
·
2 revisions
This is how to use Dependencies.
- You create an object of the Dependencies class
- You add sources/dependencies
- You sort them in the right order
<?php
// Require file
require_once('dependencies.php');
// Keeps track of all the dependencies
$dep = new Dependencies();
// Add source that depends on jquery and underscore
$dep -> add('module-name', array('jquery', 'underscore'));
// Add underscore
$dep -> add('underscore')
// Add source that do not depend on anything
$dep -> add('jquery');
// Sort the dependencies
$sorted = $dep -> sort();
// Print all the dependencies in the right order
foreach($sorted as $dependency) {
printf('%s (%s)', $dependency -> name, implode(', ', $dependency -> dependencies));
echo PHP_EOL;
}
/* Results in
jquery ()
underscore ()
module-name (jquery, underscore)
*/
?>