protected function addTranslatedColumnSetter(Column $column)
 {
     $visibility = $column->getTable()->isReadOnly() ? 'protected' : $column->getMutatorVisibility();
     $typeHint = '';
     $null = '';
     if ($column->getTypeHint()) {
         $typeHint = $column->getTypeHint();
         if ('array' !== $typeHint) {
             $typeHint = $this->declareClass($typeHint);
         }
         $typeHint .= ' ';
         if (!$column->isNotNull()) {
             $null = ' = null';
         }
     }
     $typeHint = "{$typeHint}\$v{$null}";
     $i18nTablePhpName = $this->builder->getClassNameFromBuilder($this->builder->getNewStubObjectBuilder($this->behavior->getI18nTable()));
     $tablePhpName = $this->builder->getObjectClassName();
     $objectBuilder = $this->builder->getNewObjectBuilder($this->behavior->getI18nTable());
     $comment = '';
     if ($this->isDateType($column->getType())) {
         $objectBuilder->addTemporalMutatorComment($comment, $column);
     } else {
         $objectBuilder->addMutatorComment($comment, $column);
     }
     $comment = preg_replace('/^\\t/m', '', $comment);
     $comment = str_replace('@return     $this|' . $i18nTablePhpName, '@return     $this|' . $tablePhpName, $comment);
     return $this->renderTemplate('objectTranslatedColumnSetter', ['comment' => $comment, 'column' => $column, 'visibility' => $visibility, 'typeHint' => $typeHint, 'columnPhpName' => $column->getPhpName(), 'localeColumnName' => $this->behavior->getLocaleColumn()->getPhpName()]);
 }
예제 #2
0
 /**
  * Adds the mutator function declaration.
  *
  * @param string &$script
  * @param Column $column
  */
 public function addMutatorOpenOpen(&$script, Column $column)
 {
     $cfc = $column->getPhpName();
     $visibility = $this->getTable()->isReadOnly() ? 'protected' : $column->getMutatorVisibility();
     $typeHint = '';
     $null = '';
     if ($column->getTypeHint()) {
         $typeHint = $column->getTypeHint();
         if ('array' !== $typeHint) {
             $typeHint = $this->declareClass($typeHint);
         }
         $typeHint .= ' ';
         if (!$column->isNotNull()) {
             $null = ' = null';
         }
     }
     $script .= "\n    " . $visibility . " function set{$cfc}({$typeHint}\$v{$null})\n    {";
 }