Skip to content

Commit 7ac8d80

Browse files
committed
orm bugs fixing
1 parent 706b11f commit 7ac8d80

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+2091
-1035
lines changed

src/Cli/Commanders/Make.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ public function optionPath($path)
137137
*/
138138
public function optionFilename($name)
139139
{
140-
$name = str_replace('.php', '', $name);
141-
$this->optionFilename = prepare_filename($name) . '.php';
140+
$pathinfo = pathinfo($name);
141+
$this->optionFilename = $pathinfo['filename'] . '.' . (empty($pathinfo['extension']) ? 'php' : $pathinfo['extension']);
142142

143-
$this->optionPath = empty($this->optionPath) ? modules()->top()->getRealPath() : $this->optionPath;
143+
$this->optionPath = empty($pathinfo['dirname']) || $pathinfo['dirname'] === '.' ? $this->optionPath : $pathinfo['dirname'] . DIRECTORY_SEPARATOR;
144144

145145
return $this;
146146
}

src/Cli/Commanders/Make/App.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function optionName($name)
6060
*/
6161
public function execute()
6262
{
63-
$this->__callOptions();
63+
parent::execute();
6464

6565
if (empty($this->optionName)) {
6666
output()->write(

src/Cli/Commanders/Make/Commander.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Commander extends Make
4141
*/
4242
public function execute()
4343
{
44-
$this->__callOptions();
44+
parent::execute();
4545

4646
if (empty($this->optionFilename)) {
4747
output()->write(

src/Cli/Commanders/Make/Config.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Config extends Make
4141
*/
4242
public function execute()
4343
{
44-
$this->__callOptions();
44+
parent::execute();
4545

4646
if (empty($this->optionFilename)) {
4747
output()->write(

src/Cli/Commanders/Make/Controller.php

+8-11
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ public function isHttp()
6464
*/
6565
public function execute()
6666
{
67-
$this->__callOptions();
67+
if(empty($this->optionFilename)) {
68+
parent::execute();
69+
}
6870

6971
if (empty($this->optionFilename)) {
7072
output()->write(
@@ -91,9 +93,9 @@ public function execute()
9193
}
9294

9395
if (strpos($this->optionPath, $controllerDir) === false) {
94-
$filePath = $this->optionPath . $controllerDir . DIRECTORY_SEPARATOR . $this->optionFilename;
96+
$filePath = $this->optionPath . $controllerDir . DIRECTORY_SEPARATOR . str_replace($this->optionPath, '', $this->optionFilename);
9597
} else {
96-
$filePath = $this->optionPath . $this->optionFilename;
98+
$filePath = $this->optionPath . str_replace($this->optionPath, '', $this->optionFilename);
9799
}
98100

99101
$fileDirectory = dirname($filePath) . DIRECTORY_SEPARATOR;
@@ -114,14 +116,9 @@ public function execute()
114116
}
115117

116118
$className = prepare_class_name(pathinfo($filePath, PATHINFO_FILENAME));
117-
@list($namespaceDirectory, $subNamespace) = explode($controllerDir, str_replace(['\\','/'], '\\', dirname($filePath)));
118-
$subNamespace = rtrim($subNamespace, '\\');
119-
120-
$classNamespace = loader()->getDirNamespace(
121-
$namespaceDirectory
122-
) . $controllerDir . (empty($subNamespace)
123-
? null
124-
: $subNamespace) . '\\';
119+
120+
$classNamespace = str_replace(PATH_APP, 'App\\', dirname($filePath));
121+
$classNamespace = str_replace(['\\','/'], '\\', $classNamespace);
125122

126123
$vars[ 'CREATE_DATETIME' ] = date('d/m/Y H:m');
127124
$vars[ 'NAMESPACE' ] = trim($classNamespace, '\\');

src/Cli/Commanders/Make/Helper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Helper extends Make
4141
*/
4242
public function execute()
4343
{
44-
$this->__callOptions();
44+
parent::execute();
4545

4646
if (empty($this->optionFilename)) {
4747
output()->write(

src/Cli/Commanders/Make/Library.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Library extends Make
4141
*/
4242
public function execute()
4343
{
44-
$this->__callOptions();
44+
parent::execute();
4545

4646
if (empty($this->optionFilename)) {
4747
output()->write(

src/Cli/Commanders/Make/Migration.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function optionNoSql()
8787
*/
8888
public function execute()
8989
{
90-
$this->__callOptions();
90+
parent::execute();
9191

9292
if (empty($this->optionFilename)) {
9393
output()->write(

src/Cli/Commanders/Make/Model.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Model extends Make
4141
*/
4242
public function execute()
4343
{
44-
$this->__callOptions();
44+
parent::execute();
4545

4646
if (empty($this->optionFilename)) {
4747
output()->write(

src/Cli/Commanders/Make/Module.php

+5-9
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function optionName($name)
6464
*/
6565
public function execute()
6666
{
67-
$this->__callOptions();
67+
parent::execute();
6868

6969
if (empty($this->optionName)) {
7070
output()->write(
@@ -131,15 +131,11 @@ public function execute()
131131

132132
file_put_contents($filePath, $fileContent);
133133

134-
$this->optionPath = $modulePath;
135-
$this->optionFilename = prepare_filename($this->optionName) . '.php';
136-
137-
(new Controller())
138-
->optionPath($this->optionPath)
139-
->optionFilename($this->optionFilename)
140-
->execute();
141-
142134
if (is_dir($modulePath)) {
135+
(new Controller())
136+
->optionFilename($modulePath . 'Controllers' . DIRECTORY_SEPARATOR . prepare_filename($this->optionName) . '.php')
137+
->execute();
138+
143139
output()->write(
144140
(new Format())
145141
->setContextualClass(Format::SUCCESS)

src/Cli/Commanders/Make/Plugin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function optionName($name)
6464
*/
6565
public function execute()
6666
{
67-
$this->__callOptions();
67+
parent::execute();
6868

6969
if (empty($this->optionName)) {
7070
output()->write(

src/Cli/Commanders/Make/Presenter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Presenter extends Make
4141
*/
4242
public function execute()
4343
{
44-
$this->__callOptions();
44+
parent::execute();
4545

4646
if (empty($this->optionFilename)) {
4747
output()->write(

src/Cli/Commanders/Make/Theme.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function optionName($name)
6464
*/
6565
public function execute()
6666
{
67-
$this->__callOptions();
67+
parent::execute();
6868

6969
if (empty($this->optionName)) {
7070
output()->write(

src/Cli/Commanders/Make/Widget.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Widget extends Make
4141
*/
4242
public function execute()
4343
{
44-
$this->__callOptions();
44+
parent::execute();
4545

4646
if (empty($this->optionFilename)) {
4747
output()->write(

src/Cli/Router.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function __construct()
2828
{
2929
parent::__construct();
3030

31-
$this->addFilePath(PATH_FRAMEWORK);
31+
$this->addFilePath(PATH_FRAMEWORK . 'Cli' . DIRECTORY_SEPARATOR);
32+
$this->addFilePath(PATH_APP);
3233
}
3334
}

src/Config/Constants.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
|--------------------------------------------------------------------------
1717
*/
1818
define('FRAMEWORK_NAME', 'O2System PHP Framework');
19-
define('FRAMEWORK_VERSION', '5.0.0');
19+
define('FRAMEWORK_VERSION', '5.7.x');
2020

2121
/*
2222
|--------------------------------------------------------------------------

src/Containers/Config.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class Config extends Env
4343
public function __construct()
4444
{
4545
$this->setFileDirName('Config');
46+
$this->addFilePath(PATH_KERNEL);
4647
$this->addFilePath(PATH_FRAMEWORK);
4748
$this->addFilePath(PATH_APP);
4849

@@ -67,7 +68,7 @@ public function loadFile($offset, $return = false)
6768
$configFile = str_replace($basename, $filename, $offset);
6869
$offset = camelcase($basename);
6970

70-
$configFilePaths = array_reverse($this->filePaths);
71+
$configFilePaths = $this->getFilePaths(true);
7172

7273
foreach ($configFilePaths as $configFilePath) {
7374
if (is_file(

src/Containers/Modules.php

+25-11
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public function __construct()
6868
*/
6969
private function autoload(DataStructures\Module $module)
7070
{
71+
config()->addFilePath($module->getRealPath());
72+
7173
if (!in_array($module->getRealPath(), $this->loaded)) {
7274
// Register to loaded property
7375
$this->loaded[] = $module->getRealPath();
@@ -163,7 +165,6 @@ private function autoloadHelpers(DataStructures\Module $module)
163165
*/
164166
private function autoloadConfig(DataStructures\Module $module)
165167
{
166-
config()->addFilePath($module->getRealPath());
167168
config()->loadFile('Config');
168169

169170
$addresses = config()->loadFile('Addresses', true);
@@ -406,21 +407,34 @@ public function find($segments, $register = false)
406407
'Plugins',
407408
];
408409
$packageJsonFile = 'app.json';
409-
410-
if (is_file($packageJsonFilePath = $packageRealPath . $packageJsonFile)) {
411-
array_shift($segments);
412-
413-
if ($packageRegistry = $this->getPackageRegistry($packageJsonFilePath)) {
414-
if($register === true) {
415-
$this->register($packageRegistry);
416-
}
417-
}
418-
}
419410
} elseif(is_dir($packageRealPath = PATH_APP . 'Modules' . DIRECTORY_SEPARATOR . studlycase($segments[0]) . DIRECTORY_SEPARATOR)) {
420411
$packageSubDirectories = [
421412
'Plugins',
422413
];
423414
$packageJsonFile = 'module.json';
415+
} elseif(globals()->offsetExists('app')) {
416+
if(is_dir($packageRealPath = globals()->app->getRealPath() . studlycase($segments[0]) . DIRECTORY_SEPARATOR)) {
417+
$packageSubDirectories = [
418+
'Modules',
419+
'Plugins',
420+
];
421+
$packageJsonFile = 'app.json';
422+
} elseif(is_dir($packageRealPath = globals()->app->getRealPath() . 'Modules' . DIRECTORY_SEPARATOR . studlycase($segments[0]) . DIRECTORY_SEPARATOR)) {
423+
$packageSubDirectories = [
424+
'Plugins',
425+
];
426+
$packageJsonFile = 'module.json';
427+
}
428+
}
429+
430+
if (is_file($packageJsonFilePath = $packageRealPath . $packageJsonFile)) {
431+
array_shift($segments);
432+
433+
if ($packageRegistry = $this->getPackageRegistry($packageJsonFilePath)) {
434+
if($register === true) {
435+
$this->register($packageRegistry);
436+
}
437+
}
424438
}
425439

426440
if(isset($packageSubDirectories)) {

src/Framework.php

+24-20
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,18 @@ protected function __construct()
253253
$this->services->load($className, $classOffset);
254254
}
255255

256+
// Instantiate Globals Container
257+
if (profiler() !== false) {
258+
profiler()->watch('Starting Globals Container');
259+
}
260+
$this->globals = new Kernel\DataStructures\Input\Globals();
261+
262+
// Instantiate Environment Container
263+
if (profiler() !== false) {
264+
profiler()->watch('Starting Environment Container');
265+
}
266+
$this->env = new Kernel\DataStructures\Input\Env();
267+
256268
// Instantiate Config Container
257269
if (profiler() !== false) {
258270
profiler()->watch('Starting Config Container');
@@ -282,18 +294,6 @@ protected function __construct()
282294
// Instantiate Loader Service
283295
$this->services->load('Services\Loader', 'loader');
284296

285-
// Instantiate Globals Container
286-
if (profiler() !== false) {
287-
profiler()->watch('Starting Globals Container');
288-
}
289-
$this->globals = new Kernel\DataStructures\Input\Globals();
290-
291-
// Instantiate Environment Container
292-
if (profiler() !== false) {
293-
profiler()->watch('Starting Environment Container');
294-
}
295-
$this->env = new Kernel\DataStructures\Input\Env();
296-
297297
// Instantiate Models Container
298298
if (profiler() !== false) {
299299
profiler()->watch('Starting Models Container');
@@ -330,7 +330,7 @@ protected function __reconstruct()
330330

331331
if (is_cli()) {
332332
// Instantiate CLI Router Service
333-
$this->services->load(Kernel\Cli\Router::class);
333+
$this->services->load(Framework\Cli\Router::class);
334334

335335
$this->cliHandler();
336336
} else {
@@ -385,7 +385,7 @@ private function cliHandler()
385385
}
386386
$requestCommander = $commander->getInstance();
387387

388-
if (method_exists($requestController, '__reconstruct')) {
388+
if (method_exists($requestCommander, '__reconstruct')) {
389389
$requestCommander->__reconstruct();
390390
}
391391

@@ -441,12 +441,12 @@ private function httpHandler()
441441
}
442442

443443
if($this->modules instanceof Framework\Containers\Modules) {
444-
if(empty($this->config->get('app'))) {
445-
$app = (new Framework\Containers\Modules\DataStructures\Module(PATH_APP))
446-
->setType('APP')
447-
->setNamespace('App\\');
448-
$this->modules->register($app);
449-
} else {
444+
$app = (new Framework\Containers\Modules\DataStructures\Module(PATH_APP))
445+
->setType('APP')
446+
->setNamespace('App\\');
447+
$this->modules->register($app);
448+
449+
if($this->config->get('app') !== null) {
450450
$app = (new Framework\Containers\Modules\DataStructures\Module(PATH_APP . $this->config->get('app') . DIRECTORY_SEPARATOR))
451451
->setType('APP')
452452
->setNamespace('App\\' . studlycase($this->config->get('app')) . '\\');
@@ -612,6 +612,10 @@ private function httpHandler()
612612
}
613613
} elseif ($this->services->has('view')) {
614614
if (empty($requestControllerOutput) or $requestControllerOutput === '') {
615+
if(presenter()->page->offsetExists('content')) {
616+
presenter()->partials->offsetSet('content', presenter()->page->offsetGet('content'));
617+
}
618+
615619
if(presenter()->partials->offsetExists('content')) {
616620
$htmlOutput = view()->render();
617621

0 commit comments

Comments
 (0)