Skip to content

Commit

Permalink
Added namespace to everything including the future generated files in…
Browse files Browse the repository at this point in the history
… source.
  • Loading branch information
nickl- committed May 25, 2012
1 parent 61704d3 commit 2ff82ef
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/config.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
namespace DumbledORM;

class DbConfig {
const HOST = 'localhost';
const PORT = 3306;
Expand Down
5 changes: 3 additions & 2 deletions src/dumbledorm.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
namespace DumbledORM;
/**
*
* DumbledORM
Expand Down Expand Up @@ -104,7 +105,7 @@ public static function generateBase($prefix=null,$dir='model') {
}
}
}
$basetables = "<?php\nspl_autoload_register(function(\$class) { @include(__DIR__.\"/\$class.class.php\"); });\n";
$basetables = "<?php\nnamespace DumbledORM;\n\nspl_autoload_register(function(\$class) { @include(__DIR__.\"/\$class.class.php\"); });\n";
foreach ($tables as $table => $conf) {
$relations = preg_replace('/[\n\t\s]+/','',var_export((array)@$conf['relations'],true));
$meta = isset($conf['meta']) ? "\$meta_class = '{$conf['meta']['class']}', \$meta_field = '{$conf['meta']['field']}'," : '';
Expand All @@ -115,7 +116,7 @@ public static function generateBase($prefix=null,$dir='model') {
foreach (array_keys($tables) as $table) {
$file = "./$dir/$prefix".self::camelCase($table).'.class.php';
if (!file_exists($file)) {
file_put_contents($file,"<?php\nclass ".$prefix.self::camelCase($table).' extends '.$prefix.self::camelCase($table).'Base {}');
file_put_contents($file,"<?php\nnamespace DumbledORM;\n\nclass ".$prefix.self::camelCase($table).' extends '.$prefix.self::camelCase($table).'Base {}');
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions test/test.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php
namespace DumbledORM;

require 'bootstrap.php';
$dbname = DbConfig::DBNAME;
require('dumbledorm.php');
class OrmTestException extends Exception {}
class OrmTestException extends \Exception {}
class OrmTest {
public static $fails = 0;
public static function assertTrue($message,$test) {
Expand Down

1 comment on commit 2ff82ef

@nickl-
Copy link
Owner Author

@nickl- nickl- commented on 2ff82ef May 26, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was changed back in the last commit as it made no sense to force usage of the model entities as \DumbledORM\Object namespaced.

Please sign in to comment.