metadata Getting names of controllers/actions/modules/models in your app

Description

Yii Metadata component helps to get information about models,controllers and actions from your application

Installation & Usage

1. Place Metadata.php to directory with components of your application (your_app_dir/protected/components/) or to extensions (your_app_dir/protected/extensions/)

2. Add 'metadata' element to 'components' in your application config (your_app_dir/protected/config/main.php):

... 
 'components'=>array(
      'metadata'=>array('class'=>'Metadata'),
 ...
  ), 

If you place Metadata.php to extensions, then you should write 'class'=>'ext.Metadata' instead of 'class'=>'Metadata'

3. Use:

$user_actions = Yii::app()->metadata->getActions('UserController');
   var_dump($user_actions); #Get actions of 'UserController'

   $controllers = Yii::app()->metadata->getControllers(); #You can specify module name as parameter
   var_dump($controllers); #Get list of application controllers

   $controllersWithActions = Yii::app()->metadata->getControllersActions('user'); #if no $module param, controllers&actions of application will returned
   var_dump($controllers); #Get controllers and their actions of module 'user'

   $models = Yii::app()->metadata->getModels(); #You can specify module name as parameter
   var_dump($models); #Get list of models application 

   $modules = Yii::app()->metadata->getModules();
   var_dump($modules);
Issues

v0.2:

  1. If some modules in your app have controllers with same names, MetaData will raise fatal error, when you will try to get information about controllers of both this modules.

  2. getModules method can not find modules inside other modules. (will fixed in next ver.)

  3. MetaData cannot find information about controller actions, specified by actions() method (will fixed in next ver.)

Resources
Requirements
  • Yii 1.0 or above

Change Log

November 04, 2010 v0.2 released (fixed some bugs)

June 13, 2010 Initial release.

8 2
12 followers
1 809 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Others
Tags: metadata
Developed by: Nayjest
Created on: Jun 14, 2010
Last updated: 14 years ago

Downloads

show all

Related Extensions