Exemple #1
0
 protected function getString($name, $prettify = false, $replace = array())
 {
     $name = $this->record[$name];
     if ($prettify) {
         return str_identifier(str_replace(array_keys($replace), array_values($replace), $name));
     } else {
         return $name;
     }
 }
Exemple #2
0
 protected function configure()
 {
     parent::configure();
     $this->templatesFolder = realpath(__DIR__ . '/../Resources/Templates');
     $this->workFolder = getcwd();
     $this->applicationName = str_identifier((new \SplFileInfo($this->workFolder))->getBasename());
     $this->prepareTablesAndContext();
     $this->templates = $this->getTemplateNames();
     $this->setName('init')->setDescription('Initializes a new BlendEngine project in [' . $this->workFolder . ']')->addOption('template', 't', InputOption::VALUE_OPTIONAL, 'Name of the template to generate this project (' . implode(',', $this->templates) . ')', 'Basic')->addOption('appname', 'a', InputOption::VALUE_OPTIONAL, 'Name of the application to generate', $this->applicationName);
 }
Exemple #3
0
 public function getName($prettify = false)
 {
     $name = $this->getString('schema_name');
     if ($prettify) {
         if ($name == 'public') {
             $name = 'common';
         }
         return str_identifier($name);
     } else {
         return $this->getString('schema_name');
     }
 }
 /**
  * Here we loop the columns and create a property definition.
  * We also resolve an optional field converter for a given property
  * that we provided in the builder configuration file
  * @param array $def
  * @return type
  */
 protected function preparBuildDefinition($def)
 {
     $properties = [];
     foreach ($this->relation->getColumns() as $column) {
         $name = $column->getName();
         $type = 'mixed';
         $schema = $column->getField('table_schema');
         $relation = $column->getField('table_name');
         $dbtype = $column->getField('data_type');
         $this->resolveColumnConverter($schema, $relation, $column->getName(), $dbtype, $column->getFQCN());
         $properties[] = array('name' => $name, 'getter' => 'get' . str_identifier(strtolower($name)), 'setter' => 'set' . str_identifier(strtolower($name)), 'type' => $type);
     }
     $def['props'] = $properties;
     return $def;
 }
Exemple #5
0
 public function testStrIdentifier()
 {
     $this->assertEquals('getCustomerEmail()', str_identifier('customer_email', 'get', '()'));
 }
 /**
  * Creates a caller definition based on an array with columns to be used
  * to generate function parameters
  * @param array $columns
  * @return array
  */
 private function createCallerDefinition(array $columns)
 {
     $functionName = [];
     $functionParams = [];
     $functionCallParam = [];
     foreach ($columns as $column) {
         $argName = '$' . strtolower($column->getName());
         $colName = $column->getName();
         /* @var $column \Blend\DataModelBuilder\Schema\Column */
         $functionName[] = str_identifier(str_replace('_id', '_ID', $colName));
         $functionParams[] = $argName;
         $functionParamsDoc[] = [$column->getField('udt_name'), $argName];
         $functionCallParam[] = "'{$colName}' => " . $argName;
     }
     return ['functionName' => ucwords(implode('And', $functionName)), 'functionParams' => implode(', ', $functionParams), 'functionParamsDoc' => $functionParamsDoc, 'functionCallParam' => implode(', ', $functionCallParam)];
 }