Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
job.php
1
<?php
2
3
namespace
Bitrix\Seo\Controller\Sitemap
;
4
5
use
Bitrix\Main
;
6
use
Bitrix\Main\Engine\Response\AjaxJson
;
7
use
Bitrix\Seo\Sitemap
;
8
9
final
class
Job
extends
Main\Engine\Controller
10
{
11
public
function
addAction
(
int
$sitemapId):
AjaxJson
12
{
13
try
{
14
$job = Sitemap\Job::addJob($sitemapId);
15
16
return
$job
17
?
self::createSuccess
($job->getData())
18
:
self::createError
(
"Can't add job {$sitemapId}"
)
19
;
20
}
21
catch
(Main\
SystemException
$e)
22
{
23
return
self::createError
($e->getMessage() .
" Sitemap id: {$sitemapId}"
);
24
}
25
}
26
27
public
function
doAction
(
int
$sitemapId):
AjaxJson
28
{
29
try
30
{
31
$job = Sitemap\Job::findJob($sitemapId);
32
if
(!$job)
33
{
34
$job = Sitemap\Job::addJob($sitemapId);
35
}
36
37
$res = $job->doStep();
38
if
($res->isSuccess())
39
{
40
return
self::createSuccess
($job->getData());
41
}
42
43
return
self::createError
(implode(
'; '
, $res->getErrors()));
44
}
45
catch
(Main\
SystemException
$e)
46
{
47
return
self::createError
($e->getMessage() .
" Sitemap id: {$sitemapId}"
);
48
}
49
}
50
51
protected
static
function
createSuccess
(mixed $data):
AjaxJson
52
{
53
return
AjaxJson::createSuccess($data);
54
}
55
56
protected
static
function
createError
(
string
$message):
AjaxJson
57
{
58
$errorCollection
=
new
Main\ErrorCollection
();
59
$errorCollection
[] =
new
Main\Error
($message);
60
61
return
AjaxJson::createError(
$errorCollection
);
62
}
63
}
Bitrix\Main\Engine\Controller
Definition
controller.php:32
Bitrix\Main\Engine\Controller\$errorCollection
$errorCollection
Definition
controller.php:46
Bitrix\Main\Engine\Response\AjaxJson
Definition
ajaxjson.php:11
Bitrix\Main\ErrorCollection
Definition
errorcollection.php:14
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\SystemException
Definition
exception.php:8
Bitrix\Seo\Controller\Sitemap\Job
Definition
job.php:10
Bitrix\Seo\Controller\Sitemap\Job\doAction
doAction(int $sitemapId)
Definition
job.php:27
Bitrix\Seo\Controller\Sitemap\Job\createError
static createError(string $message)
Definition
job.php:56
Bitrix\Seo\Controller\Sitemap\Job\addAction
addAction(int $sitemapId)
Definition
job.php:11
Bitrix\Seo\Controller\Sitemap\Job\createSuccess
static createSuccess(mixed $data)
Definition
job.php:51
Bitrix\Main
Bitrix\Seo\Controller\Sitemap
Definition
job.php:3
Bitrix\Seo\Sitemap
modules
seo
lib
controller
sitemap
job.php
Создано системой
1.10.0