I’m having difficulty getting Gii to recognize my custom CrudCode class. I’m having no problem getting gii to recognize my custom crud templates. They work great. But I need to override some of the CrudCode methods.
So I’ve created my custom gii directory in the protected folder. In it I have
gii/
crud/
MycrudCode.php
MycrudGenerator.php
templates/
(Don’t know why the indents are funny here. You get the idea.)
In MycrudCode.php:
<?php
Yii::import('gii.generators.crud.CrudCode');
class MycrudCode extends CrudCode
{
public function class2name($className,$pluralize=false)
{
if($pluralize)
$className=$this->pluralize($className);
$myName = preg_replace("/^(\w+) (.*)/",'$2',$className);
return $myName;
}
}
And in MycrudGenerator.php:
<?php
Yii::import('gii.generators.crud.CrudGenerator');
class MycrudGenerator extends CrudGenerator
{
public $codeModel = 'application.gii.MycrudCode';
}
In config/main.php:
'modules'=>array(
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'harinisa',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array(getTestIp(),'127.0.0.1','::1'),
'generatorPaths'=>array(
'application.gii',
),
),
...
Doing this, my custom templates are found, but not MycrudCode or MycrudGenerator. They have no effect, and apparently aren’t being loaded. I’ve run basic tests by having them do a simple
echo "I'm here"; exit;
in the functions and before declaring the class. Nothing.
Any ideas?