Skip to content

Commit 7afbaf5

Browse files
committed
added sitemaps support
1 parent 80df1fe commit 7afbaf5

File tree

10 files changed

+196
-165
lines changed

10 files changed

+196
-165
lines changed

app/base/abstracts/FrontendModel.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
use \App\Site\Models\Rewrite;
1919
use \Exception;
2020
use \App\Base\Traits\WithWebsiteTrait;
21+
use \App\Base\Traits\WithOwnerTrait;
2122

2223
/**
2324
* A model that will be shown on frontend
2425
*/
2526
abstract class FrontendModel extends Model
2627
{
27-
use WithWebsiteTrait;
28-
28+
use WithWebsiteTrait, WithOwnerTrait;
29+
2930
/**
3031
* @var Rewrite|null rewrite object
3132
*/
@@ -69,11 +70,11 @@ public function getFrontendUrl()
6970
public function postPersist()
7071
{
7172
$rewrite = $this->getRewrite();
72-
$rewrite->website_id = $this->website_id;
73+
$rewrite->website_id = $this->getWebsiteId();
7374
$rewrite->url = $this->getFrontendUrl();
74-
$rewrite->route = '/'.$this->getRewritePrefix().'/'.$this->id;
75-
$rewrite->user_id = null; // not a property for all FrontendModels
76-
$rewrite->locale = $this->locale;
75+
$rewrite->route = '/'.$this->getRewritePrefix().'/'.$this->getId();
76+
$rewrite->user_id = $this->getUserId();
77+
$rewrite->locale = $this->getLocale();
7778
$rewrite->persist();
7879

7980
return parent::postPersist();

app/base/tools/Utils/Globals.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use \Swift_Message;
2929
use \Exception;
3030
use \Degami\PHPFormsApi\Accessories\TagElement;
31+
use \Spatie\ArrayToXml\ArrayToXml;
3132

3233
/**
3334
* Global utils functions Helper Class
@@ -215,6 +216,35 @@ public function exceptionJson(\Exception $exception)
215216
));
216217
}
217218

219+
/**
220+
* returns an exception error xml
221+
*
222+
* @param \Exception $exception
223+
* @return Response
224+
*/
225+
public function exceptionXML(\Exception $exception)
226+
{
227+
if ($this->getEnv('DEBUG')) {
228+
$content = [
229+
'success' => false,
230+
'message' => $exception->getMessage(),
231+
'trace' => $exception->getTraceAsString(),
232+
];
233+
} else {
234+
$content = [
235+
'success' => false,
236+
'message' => 'Exception!',
237+
];
238+
}
239+
240+
return (new Response(
241+
ArrayToXml::convert($content),
242+
500,
243+
['Content-Type' => 'text/xml']
244+
));
245+
}
246+
247+
218248
/**
219249
* returns a "site is offline" error page
220250
*

app/site/controllers/Admin/ContactForms.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public function getFormDefinition(FAPI\Form $form, &$form_state)
249249
'title' => $component['field_label'],
250250
'collapsible' => true,
251251
'collapsed' => true,
252-
],
252+
],
253253
$index
254254
),
255255
$index,
@@ -315,15 +315,15 @@ public function getFormDefinition(FAPI\Form $form, &$form_state)
315315
'default_value' => $contact_submit_to,
316316
]
317317
)
318-
->addField(
319-
'button',
320-
[
321-
'type' => 'submit',
322-
'value' => 'ok',
323-
'container_class' => 'form-item mt-3',
324-
'attributes' => ['class' => 'btn btn-primary btn-lg btn-block'],
325-
]
326-
);
318+
->addField(
319+
'button',
320+
[
321+
'type' => 'submit',
322+
'value' => 'ok',
323+
'container_class' => 'form-item mt-3',
324+
'attributes' => ['class' => 'btn btn-primary btn-lg btn-block'],
325+
]
326+
);
327327
break;
328328

329329
case 'delete':
@@ -442,8 +442,8 @@ public function formValidate(FAPI\Form $form, &$form_state)
442442
public function formSubmitted(FAPI\Form $form, &$form_state)
443443
{
444444
/**
445-
* @var Contact $contact
446-
*/
445+
* @var Contact $contact
446+
*/
447447
$contact = $this->newEmptyObject();
448448
if ($this->getRequest()->get('contact_id')) {
449449
$contact = $this->loadObject($this->getRequest()->get('contact_id'));

0 commit comments

Comments
 (0)