public function testModuleGenerator()
 {
     $generator = new ModuleGenerator();
     $generator->template = 'default';
     $generator->moduleID = 'test';
     $generator->moduleClass = 'app\\modules\\test\\Module';
     $valid = $generator->validate();
     $this->assertTrue($valid, 'Validation failed: ' . print_r($generator->getErrors(), true));
     $this->assertNotEmpty($generator->generate());
 }
Пример #2
0
 public function testModuleGenerator()
 {
     $generator = new ModuleGenerator();
     $generator->template = 'default';
     $generator->moduleID = 'test';
     $generator->moduleClass = 'app\\modules\\test\\Module';
     if ($generator->validate()) {
         $generator->generate();
     } else {
         print_r($generator->getErrors());
     }
 }
Пример #3
0
 public function actionCreateModule($id)
 {
     /**
      * @var CodeFile $code
      */
     $generator = new Generator();
     $generator->moduleID = $id;
     $generator->moduleClass = 'app\\modules\\' . strtolower($id) . '\\' . ucfirst($id) . "Module";
     foreach ($generator->generate() as $code) {
         $code->save();
     }
     $this->stdout("Module '{$id}' generated\n");
     $this->stdout("Add to modules: '{$id}' => '{$generator->moduleClass}'\ns");
 }
Пример #4
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return array_merge(parent::rules(), [[['moduleID', 'moduleClass'], 'filter', 'filter' => 'trim'], [['moduleID', 'moduleClass'], 'required'], [['moduleID'], 'match', 'pattern' => '/^[\\w\\-]+$/', 'message' => 'Only word characters and dashes are allowed.'], [['moduleClass'], 'match', 'pattern' => '/^[\\w\\\\]*$/', 'message' => 'Only word characters and backslashes are allowed.'], [['moduleClass'], 'validateModuleClass']]);
 }
Пример #5
0
 /**
  * Create also "search" and "messages" folders. Also create "messages/config.php"
  *
  * @inheritdoc
  */
 public function save($files, $answers, &$results)
 {
     // If there are not errors - create "models" and "search" folders
     if (parent::save($files, $answers, $results)) {
         $modelsDir = $this->getModulePath() . '/models';
         $searchDir = $modelsDir . '/search';
         mkdir($searchDir, 0777, true);
         chmod($modelsDir, 0777);
         chmod($searchDir, 0777);
         return true;
     }
     return false;
 }