/** * Parse the model definition line and append the results to the appropriate * data structure * @param string $line The input line to be parsed * @return array The name of the model/table that was parsed and the * the definition type (model/table) */ public function parseModelDefinitionLine($line) { // Parse the model definition $parsed = $this->modelDefinitionParser->parse(trim($line)); // Figure out whether it is a table or a model definition. $modelName = $parsed['modelName']; $tableName = $parsed['tableName']; $type = $parsed['type']; // In case of a model definition: // Create a new model and migration // The table name can either be blank or overriden. // Process relations // Return modelName as the model name, and the type if ($type == 'model') { $this->modelList->create($modelName, $tableName); $this->migrationList->create($modelName, $tableName); // Detect and add in relations for later use foreach ($parsed['relations'] as $rel) { $this->relations[] = array_merge(array('fromModel' => $modelName), $rel); } // Return model name and type return array($modelName, $type); } else { $this->migrationList->create($tableName, $tableName); // Return the tableName, type pair return array($tableName, $type); } }
private function getParsedResults($line) { $m = new ModelDefinitionParser(); return $m->parse($line); }