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

setNamespaceName() public method

public setNamespaceName ( string $namespaceName ) : self
$namespaceName string
return self
    public function setNamespaceName($namespaceName)
    {
        $this->namespaceName = $namespaceName;
        return $this;
    }

Usage Example

 private function updateModuleConfig()
 {
     $dir = getcwd() . '/module/' . ucfirst($this->db) . '/config/';
     $filename = $dir . 'module.config.php';
     $moduleConfigArray = (include $filename);
     $keyCtrl = $this->getModuleName() . '\\' . $this->subDir . '\\' . $this->getClassName();
     if (!array_key_exists($keyCtrl, $moduleConfigArray['controllers']['invokables'])) {
         $moduleConfigArray['controllers']['invokables'][$keyCtrl] = $this->getModuleName() . '\\' . $this->subDir . '\\' . $this->getClassName();
     }
     $keyRoute = $this->tableName;
     if (!array_key_exists($keyRoute, $moduleConfigArray['router']['routes'])) {
         $moduleConfigArray['router']['routes'][$keyRoute] = array('type' => 'segment', 'options' => array('route' => '/' . $keyRoute . '[/:id]', 'defaults' => array('controller' => $keyCtrl)));
     }
     $newContent = '<? return ' . var_export($moduleConfigArray, true) . ';';
     // dir doesn't exist, make it
     if (!is_dir($dir)) {
         mkdir($dir);
         // ** Generate Module.php class ** //
         // Definitions
         $classGenerator = new ClassGenerator();
         $classGenerator->setName('Module');
         $classGenerator->setNamespaceName(ucfirst($this->db));
         // Methods
         $classGenerator->addMethods(array(new MethodGenerator('getConfig', [], MethodGenerator::FLAG_PUBLIC, "return include __DIR__ . '/config/module.config.php';"), new MethodGenerator('getAutoloaderConfig', [], MethodGenerator::FLAG_PUBLIC, "return array(\r                            'Zend\\Loader\\StandardAutoloader' => array(\r                                'namespaces' => array(\r                                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,\r                                ),\r                            ),\r                        );")));
         $this->fileCreate(getcwd() . '/module/' . ucfirst($this->db) . '/Module.php', $classGenerator);
         // ** Generate Module.php class ** //
     }
     file_put_contents($filename, $newContent);
 }
All Usage Examples Of Zend\Code\Generator\ClassGenerator::setNamespaceName