aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/application.php6
-rw-r--r--core/functions.php18
-rw-r--r--core/namespace/Application.php14
-rw-r--r--core/namespace/ORM/Entities/Page.php (renamed from core/namespace/Page/Entity.php)5
-rw-r--r--core/namespace/ORM/Entities/Post.php (renamed from core/namespace/Post/Entity.php)5
-rw-r--r--core/namespace/ORM/Entities/User.php (renamed from core/namespace/User/Entity.php)5
-rw-r--r--core/namespace/ORM/Entity.php (renamed from core/namespace/Entity.php)2
-rw-r--r--core/namespace/ORM/EntityInterface.php (renamed from core/namespace/EntityInterface.php)2
-rw-r--r--core/namespace/ORM/Repositories/Page.php (renamed from core/namespace/Page/Repository.php)10
-rw-r--r--core/namespace/ORM/Repositories/Post.php (renamed from core/namespace/Post/Repository.php)10
-rw-r--r--core/namespace/ORM/Repositories/User.php8
-rw-r--r--core/namespace/ORM/Repository.php (renamed from core/namespace/Repository.php)3
-rw-r--r--core/namespace/User/Repository.php7
13 files changed, 57 insertions, 38 deletions
diff --git a/core/application.php b/core/application.php
index ecb7947..80952fd 100644
--- a/core/application.php
+++ b/core/application.php
@@ -159,9 +159,9 @@ if(Application::get('CORE.SEND_304') === TRUE AND !defined('ADMINISTRATION')) {
#===========================================================================
$execute = '(SELECT time_update FROM %s ORDER BY time_update DESC LIMIT 1) AS %s';
- $pageTable = Page\Repository::getTableName();
- $postTable = Post\Repository::getTableName();
- $userTable = User\Repository::getTableName();
+ $pageTable = ORM\Repositories\Page::getTableName();
+ $postTable = ORM\Repositories\Post::getTableName();
+ $userTable = ORM\Repositories\User::getTableName();
$pageSQL = sprintf($execute, $pageTable, $pageTable);
$postSQL = sprintf($execute, $postTable, $postTable);
diff --git a/core/functions.php b/core/functions.php
index 55744f1..dadaab8 100644
--- a/core/functions.php
+++ b/core/functions.php
@@ -1,7 +1,9 @@
<?php
-use Page\Entity as Page;
-use Post\Entity as Post;
-use User\Entity as User;
+use ORM\Entities\Page;
+use ORM\Entities\Post;
+use ORM\Entities\User;
+use ORM\EntityInterface;
+
use Template\Template as Template;
use Template\Factory as TemplateFactory;
@@ -114,10 +116,10 @@ function generateItemTemplateData(EntityInterface $Entity): array {
#===============================================================================
function generatePseudoGUID(EntityInterface $Entity) {
switch(get_class($Entity)) {
- case "Page\Entity":
+ case "ORM\Entities\Page":
$attr = Application::get('PAGE.FEED_GUID');
break;
- case "Post\Entity":
+ case "ORM\Entities\Post":
$attr = Application::get('POST.FEED_GUID');
break;
default:
@@ -164,13 +166,13 @@ function parseContentTags(string $text): string {
#===============================================================================
function parseEntityContent(EntityInterface $Entity): string {
switch($class = get_class($Entity)) {
- case 'Page\Entity':
+ case 'ORM\Entities\Page':
$prefix = 'PAGE';
break;
- case 'Post\Entity':
+ case 'ORM\Entities\Post':
$prefix = 'POST';
break;
- case 'User\Entity':
+ case 'ORM\Entities\User':
$prefix = 'USER';
break;
default:
diff --git a/core/namespace/Application.php b/core/namespace/Application.php
index 0d6d30e..2329253 100644
--- a/core/namespace/Application.php
+++ b/core/namespace/Application.php
@@ -1,4 +1,6 @@
<?php
+use ORM\EntityInterface;
+
class Application {
#===============================================================================
@@ -97,9 +99,9 @@ class Application {
#===============================================================================
# Return singleton repository instance
#===============================================================================
- public static function getRepository(string $namespace): Repository {
- $identifier = strtolower($namespace);
- $repository = "$namespace\Repository";
+ public static function getRepository(string $entity): ORM\Repository {
+ $identifier = strtolower($entity);
+ $repository = "ORM\Repositories\\$entity";
if(!isset(self::$repositories[$identifier])) {
$Repository = new $repository(self::getDatabase());
@@ -186,13 +188,13 @@ class Application {
#===============================================================================
public static function getEntityURL(EntityInterface $Entity) {
switch($class = get_class($Entity)) {
- case 'Page\Entity':
+ case 'ORM\Entities\Page':
$attr = self::get('PAGE.SLUG_URLS') ? 'slug' : 'id';
return self::getPageURL($Entity->get($attr).'/');
- case 'Post\Entity':
+ case 'ORM\Entities\Post':
$attr = self::get('POST.SLUG_URLS') ? 'slug' : 'id';
return self::getPostURL($Entity->get($attr).'/');
- case 'User\Entity':
+ case 'ORM\Entities\User':
$attr = self::get('USER.SLUG_URLS') ? 'slug' : 'id';
return self::getUserURL($Entity->get($attr).'/');
default:
diff --git a/core/namespace/Page/Entity.php b/core/namespace/ORM/Entities/Page.php
index 6ca5979..94e5ff5 100644
--- a/core/namespace/Page/Entity.php
+++ b/core/namespace/ORM/Entities/Page.php
@@ -1,7 +1,8 @@
<?php
-namespace Page;
+namespace ORM\Entities;
+use ORM\Entity;
-class Entity extends \Entity {
+class Page extends Entity {
protected $id = FALSE;
protected $user = FALSE;
protected $slug = FALSE;
diff --git a/core/namespace/Post/Entity.php b/core/namespace/ORM/Entities/Post.php
index 399f5bb..e6bff36 100644
--- a/core/namespace/Post/Entity.php
+++ b/core/namespace/ORM/Entities/Post.php
@@ -1,7 +1,8 @@
<?php
-namespace Post;
+namespace ORM\Entities;
+use ORM\Entity;
-class Entity extends \Entity {
+class Post extends Entity {
protected $id = FALSE;
protected $user = FALSE;
protected $slug = FALSE;
diff --git a/core/namespace/User/Entity.php b/core/namespace/ORM/Entities/User.php
index fdfaf9e..f0c9a1f 100644
--- a/core/namespace/User/Entity.php
+++ b/core/namespace/ORM/Entities/User.php
@@ -1,7 +1,8 @@
<?php
-namespace User;
+namespace ORM\Entities;
+use ORM\Entity;
-class Entity extends \Entity {
+class User extends Entity {
protected $id = FALSE;
protected $slug = FALSE;
protected $username = FALSE;
diff --git a/core/namespace/Entity.php b/core/namespace/ORM/Entity.php
index 4bedd37..9cc7755 100644
--- a/core/namespace/Entity.php
+++ b/core/namespace/ORM/Entity.php
@@ -1,4 +1,6 @@
<?php
+namespace ORM;
+
abstract class Entity implements EntityInterface {
protected $id;
protected $time_insert;
diff --git a/core/namespace/EntityInterface.php b/core/namespace/ORM/EntityInterface.php
index 8eaa089..68c9588 100644
--- a/core/namespace/EntityInterface.php
+++ b/core/namespace/ORM/EntityInterface.php
@@ -1,4 +1,6 @@
<?php
+namespace ORM;
+
interface EntityInterface {
public function get(string $attribute);
public function set(string $attribute, $value);
diff --git a/core/namespace/Page/Repository.php b/core/namespace/ORM/Repositories/Page.php
index b76ef85..595b420 100644
--- a/core/namespace/Page/Repository.php
+++ b/core/namespace/ORM/Repositories/Page.php
@@ -1,11 +1,13 @@
<?php
-namespace Page;
+namespace ORM\Repositories;
+use ORM\Repository;
+use ORM\Entities\User;
-class Repository extends \Repository {
+class Page extends Repository {
public static function getTableName(): string { return 'page'; }
- public static function getClassName(): string { return 'Page\Entity'; }
+ public static function getClassName(): string { return 'ORM\Entities\Page'; }
- public function getCountByUser(\User\Entity $User): int {
+ public function getCountByUser(User $User): int {
$query = 'SELECT COUNT(id) FROM %s WHERE user = ?';
$query = sprintf($query, static::getTableName());
diff --git a/core/namespace/Post/Repository.php b/core/namespace/ORM/Repositories/Post.php
index 5a3d834..8eac12f 100644
--- a/core/namespace/Post/Repository.php
+++ b/core/namespace/ORM/Repositories/Post.php
@@ -1,11 +1,13 @@
<?php
-namespace Post;
+namespace ORM\Repositories;
+use ORM\Repository;
+use ORM\Entities\User;
-class Repository extends \Repository {
+class Post extends Repository {
public static function getTableName(): string { return 'post'; }
- public static function getClassName(): string { return 'Post\Entity'; }
+ public static function getClassName(): string { return 'ORM\Entities\Post'; }
- public function getCountByUser(\User\Entity $User): int {
+ public function getCountByUser(User $User): int {
$query = 'SELECT COUNT(id) FROM %s WHERE user = ?';
$query = sprintf($query, static::getTableName());
diff --git a/core/namespace/ORM/Repositories/User.php b/core/namespace/ORM/Repositories/User.php
new file mode 100644
index 0000000..629d9c1
--- /dev/null
+++ b/core/namespace/ORM/Repositories/User.php
@@ -0,0 +1,8 @@
+<?php
+namespace ORM\Repositories;
+use ORM\Repository;
+
+class User extends Repository {
+ public static function getTableName(): string { return 'user'; }
+ public static function getClassName(): string { return 'ORM\Entities\User'; }
+}
diff --git a/core/namespace/Repository.php b/core/namespace/ORM/Repository.php
index e2b42a7..507605c 100644
--- a/core/namespace/Repository.php
+++ b/core/namespace/ORM/Repository.php
@@ -1,4 +1,7 @@
<?php
+namespace ORM;
+use Database;
+
abstract class Repository {
protected $Database;
protected $entities = [];
diff --git a/core/namespace/User/Repository.php b/core/namespace/User/Repository.php
deleted file mode 100644
index 59205b3..0000000
--- a/core/namespace/User/Repository.php
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php
-namespace User;
-
-class Repository extends \Repository {
- public static function getTableName(): string { return 'user'; }
- public static function getClassName(): string { return 'User\Entity'; }
-}