Zend\Code\Generator\ClassGenerator::__construct PHP Method

__construct() public method

public __construct ( string $name = null, string $namespaceName = null, array | string $flags = null, string $extends = null, array $interfaces = [], array $properties = [], array $methods = [], Zend\Code\Generator\DocBlockGenerator $docBlock = null )
$name string
$namespaceName string
$flags array | string
$extends string
$interfaces array
$properties array
$methods array
$docBlock Zend\Code\Generator\DocBlockGenerator
    public function __construct($name = null, $namespaceName = null, $flags = null, $extends = null, $interfaces = [], $properties = [], $methods = [], $docBlock = null)
    {
        $this->traitUsageGenerator = new TraitUsageGenerator($this);
        if ($name !== null) {
            $this->setName($name);
        }
        if ($namespaceName !== null) {
            $this->setNamespaceName($namespaceName);
        }
        if ($flags !== null) {
            $this->setFlags($flags);
        }
        if ($properties !== []) {
            $this->addProperties($properties);
        }
        if ($extends !== null) {
            $this->setExtendedClass($extends);
        }
        if (is_array($interfaces)) {
            $this->setImplementedInterfaces($interfaces);
        }
        if ($methods !== []) {
            $this->addMethods($methods);
        }
        if ($docBlock !== null) {
            $this->setDocBlock($docBlock);
        }
    }

Usage Example

 /**
  * @param string $className
  * @param string $moduleName
  * @param string $namespaceName
  * @param string $tableName
  * @param array  $loadedTable
  * @param array  $config
  */
 public function __construct($className, $moduleName, $namespaceName, $tableName, array $loadedTable = [], array $config = [])
 {
     // set config data
     $this->config = $config;
     $this->loadedTable = $loadedTable;
     $this->foreignKeys = [];
     /** @var ConstraintObject $foreignKey */
     foreach ($this->loadedTable['foreignKeys'] as $foreignKey) {
         foreach ($foreignKey->getColumns() as $column) {
             $this->foreignKeys[$column] = $foreignKey;
         }
     }
     // call parent constructor
     parent::__construct($className . 'Factory', $moduleName . '\\' . $namespaceName);
     // add namespaces for foreign key tables
     foreach ($this->foreignKeys as $foreignKey) {
         $this->addUse($moduleName . '\\' . $this->config['namespaceStorage'] . '\\' . StaticFilter::execute($foreignKey->getReferencedTableName(), 'Word\\UnderscoreToCamelCase') . 'Storage');
     }
     // add used namespaces and extended classes
     $this->addUse('Zend\\ServiceManager\\FactoryInterface');
     $this->addUse('Zend\\ServiceManager\\ServiceLocatorAwareInterface');
     $this->addUse('Zend\\ServiceManager\\ServiceLocatorInterface');
     $this->setImplementedInterfaces(['FactoryInterface']);
     // add methods
     $this->addCreateServiceMethod($className, $moduleName);
     $this->addClassDocBlock($className);
 }
All Usage Examples Of Zend\Code\Generator\ClassGenerator::__construct