BaseModuleCode::prepare PHP Method

prepare() public method

public prepare ( )
    public function prepare()
    {
        $this->files = array();
        $templatePath = $this->templatePath;
        $modulePath = $this->modulePath;
        $moduleTemplateFile = $templatePath . DIRECTORY_SEPARATOR . 'module.php';
        $this->files[] = new CCodeFile($modulePath . '/' . $this->moduleClass . '.php', $this->render($moduleTemplateFile));
        $files = CFileHelper::findFiles($templatePath, array('exclude' => array('.svn')));
        foreach ($files as $file) {
            if ($file !== $moduleTemplateFile) {
                if (CFileHelper::getExtension($file) === 'php') {
                    $content = $this->render($file);
                } elseif (basename($file) === '.yii') {
                    // an empty directory
                    $file = dirname($file);
                    $content = null;
                } else {
                    $content = file_get_contents($file);
                }
                $this->files[] = new CCodeFile($modulePath . substr($file, strlen($templatePath)), $content);
            }
        }
    }

Usage Example

 public function initialise($properties = false)
 {
     if ($properties) {
         foreach ($properties as $key => $value) {
             $this->{$key} = $value;
         }
     }
     parent::prepare();
     $this->files = array();
     $this->moduleTemplateFile = $this->templatePath . DIRECTORY_SEPARATOR . 'module.php';
     $this->files[] = new CCodeFile($this->modulePath . '/' . $this->moduleClass . '.php', $this->render($this->moduleTemplateFile));
     $this->files_to_process = CFileHelper::findFiles($this->templatePath, array('exclude' => array('.svn')));
 }