Skip to content

Instantly share code, notes, and snippets.

@ruliarmando
Created February 22, 2014 06:31
Show Gist options
  • Save ruliarmando/9149603 to your computer and use it in GitHub Desktop.
Save ruliarmando/9149603 to your computer and use it in GitHub Desktop.
RulesMerger (for Yii framework)
<?php
class RulesMerger
{
public static function merge()
{
$urlManager = Yii::app()->getUrlManager();
$path = Yii::getPathOfAlias('application.modules');
foreach(Yii::app()->getModules() as $k => $v)
{
if($k !== 'gii')
{
$file = $path.'/'.$k.'/config/rules.php';
if(file_exists($file))
{
$rules = require $file;
$urlManager->addRules($rules);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment