Skip to content

Commit a5964a9

Browse files
committed
hydro and email bugs fixes
1 parent 6ac52db commit a5964a9

File tree

6 files changed

+61
-84
lines changed

6 files changed

+61
-84
lines changed

src/Http/Router.php

+27-25
Original file line numberDiff line numberDiff line change
@@ -191,38 +191,40 @@ public function handle(KernelMessageUri $uri = null)
191191
* Try to find static page
192192
* ------------------------------------------------------------------------
193193
*/
194-
if (false !== ($pageFilePath = view()->getPageFilePath($this->uri->segments->__toString()))) {
195-
presenter()->page->setFile($pageFilePath);
194+
if(services()->has('view')){
195+
if (false !== ($pageFilePath = view()->getPageFilePath($this->uri->segments->__toString()))) {
196+
presenter()->page->setFile($pageFilePath);
196197

197-
if($spaControllerClassName = $this->getControllerClassName('Pages')) {
198-
if (presenter()->page->file instanceof SplFileInfo) {
199-
$this->setController(
200-
(new KernelControllerDataStructure($spaControllerClassName))
201-
->setRequestMethod('index')
202-
);
203-
204-
return true;
205-
}
206-
}
207-
} elseif (class_exists($pagesModelClassName = modules()->top()->getNamespace() . 'Models\Pages')) {
208-
models()->load($pagesModelClassName, 'controller');
209-
210-
if (false !== ($page = models('controller')->findWhere([
211-
'slug' => $this->uri->segments->__toString()
212-
], 1))) {
213-
if (isset($page->content)) {
214-
foreach($page as $offset => $value) {
215-
presenter()->page->offsetSet($offset, $value);
216-
}
217-
218-
if (class_exists($spaControllerClassName = modules()->top()->getNamespace() . 'Controllers\Pages')) {
198+
if($spaControllerClassName = $this->getControllerClassName('Pages')) {
199+
if (presenter()->page->file instanceof SplFileInfo) {
219200
$this->setController(
220201
(new KernelControllerDataStructure($spaControllerClassName))
221202
->setRequestMethod('index')
222203
);
204+
205+
return true;
223206
}
207+
}
208+
} elseif (class_exists($pagesModelClassName = modules()->top()->getNamespace() . 'Models\Pages')) {
209+
models()->load($pagesModelClassName, 'controller');
210+
211+
if (false !== ($page = models('controller')->findWhere([
212+
'slug' => $this->uri->segments->__toString()
213+
], 1))) {
214+
if (isset($page->content)) {
215+
foreach($page as $offset => $value) {
216+
presenter()->page->offsetSet($offset, $value);
217+
}
218+
219+
if (class_exists($spaControllerClassName = modules()->top()->getNamespace() . 'Controllers\Pages')) {
220+
$this->setController(
221+
(new KernelControllerDataStructure($spaControllerClassName))
222+
->setRequestMethod('index')
223+
);
224+
}
224225

225-
return true;
226+
return true;
227+
}
226228
}
227229
}
228230
}

src/Models/Sql/System/Media.php

+15
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,19 @@ public function rebuildRow(&$row)
6666

6767
$row->url = $row->record->type === 'IMAGE' ? images_url($filePath) : storage_url($filePath);
6868
}
69+
70+
// ------------------------------------------------------------------------
71+
/**
72+
* Media::image
73+
*
74+
* @return string
75+
*/
76+
public function image(): string
77+
{
78+
$image = PATH_STORAGE . 'images/' .$this->row->filepath;
79+
if (is_file($image)) {
80+
return images_url($image);
81+
}
82+
return images_url('/images/default/no-image.jpg');
83+
}
6984
}

src/Models/Sql/System/Storage/Authorities.php

-57
This file was deleted.

src/Models/Sql/System/Users.php

+10
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,14 @@ public function profile()
130130
return $this->morphOneThrough(People::class, Relationships::class, 'relation');
131131
}
132132
// ------------------------------------------------------------------------
133+
134+
/**
135+
* Users::avatar
136+
*
137+
* @return string
138+
*/
139+
public function avatar()
140+
{
141+
return 'https://avatars.dicebear.com/v2/initials/' . preg_replace('/[^a-z0-9 _.-]+/i', '', $this->row->username) . '.svg';
142+
}
133143
}

src/Models/Sql/Traits/RecordTrait.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
// ------------------------------------------------------------------------
1616

17+
use O2System\Session;
1718
use O2System\Spl\DataStructures\SplArrayStorage;
1819

1920
/**
@@ -173,8 +174,10 @@ protected function insertRecordData(SplArrayStorage &$data)
173174
protected function updateRecordData(SplArrayStorage &$data)
174175
{
175176
if(is_null($this->recordUser)) {
176-
if(session()->offsetExists('account')) {
177-
$this->setRecordUser(session()->account->id);
177+
if(session() instanceof Session) {
178+
if(session()->offsetExists('account')) {
179+
$this->setRecordUser(session()->account->id);
180+
}
178181
}
179182
}
180183

src/Services/Email.php

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public function __construct()
3636
if ($config = config()->loadFile('email', true)) {
3737
$this->setConfig($config->getArrayCopy());
3838
}
39+
40+
if(ENVIRONMENT === 'PRODUCTION') {
41+
$this->config['debug'] = false;
42+
}
3943
}
4044

4145
// ------------------------------------------------------------------------

0 commit comments

Comments
 (0)