Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
76eeca54
Commit
76eeca54
authored
Feb 09, 2026
by
duke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Разработать API для страницы "Конфигураторы оборудования"
parent
0937cc34
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
5 deletions
+53
-5
frontend/config/main.php
frontend/config/main.php
+3
-0
frontend/modules/api/components/PageAction.php
frontend/modules/api/components/PageAction.php
+45
-0
frontend/modules/api/controllers/StaticController.php
frontend/modules/api/controllers/StaticController.php
+2
-2
frontend/modules/api/docs/static.md
frontend/modules/api/docs/static.md
+3
-3
No files found.
frontend/config/main.php
View file @
76eeca54
...
...
@@ -164,6 +164,9 @@ return [
'class'
=>
'yii\rest\UrlRule'
,
'controller'
=>
'api/static'
,
'pluralize'
=>
false
,
'tokens'
=>
[
'{id}'
=>
'<id:.+>'
,
],
'only'
=>
[
'view'
,
'options'
]
],
[
...
...
frontend/modules/api/components/PageAction.php
0 → 100644
View file @
76eeca54
<?php
namespace
frontend\modules\api\components
;
use
yii\db\ActiveRecordInterface
;
use
yii\rest\Action
;
use
yii\web\NotFoundHttpException
;
/**
* Class PageAction
* @package frontend\modules\api\components
*/
class
PageAction
extends
Action
{
/**
* Displays a model.
* @param string $id the primary key of the model.
* @return \yii\db\ActiveRecordInterface the model being displayed
*/
public
function
run
(
$id
)
{
$model
=
$this
->
findModel
(
$id
);
if
(
$this
->
checkAccess
)
{
call_user_func
(
$this
->
checkAccess
,
$this
->
id
,
$model
);
}
return
$model
;
}
public
function
findModel
(
$id
)
{
/* @var $modelClass ActiveRecordInterface */
$modelClass
=
$this
->
modelClass
;
$model
=
$modelClass
::
find
()
->
where
([
'url'
=>
$id
])
->
limit
(
1
)
->
one
();
if
(
isset
(
$model
))
{
return
$model
;
}
throw
new
NotFoundHttpException
(
"Object not found:
$id
"
);
}
}
\ No newline at end of file
frontend/modules/api/controllers/StaticController.php
View file @
76eeca54
...
...
@@ -3,8 +3,8 @@
namespace
frontend\modules\api\controllers
;
use
common\modules\content\models\CoContent
;
use
frontend\modules\api\components\PageAction
;
use
yii\rest\Controller
;
use
yii\rest\ViewAction
;
/**
* Class StaticController
...
...
@@ -29,7 +29,7 @@ class StaticController extends Controller
{
return
[
'view'
=>
[
'class'
=>
View
Action
::
className
(),
'class'
=>
Page
Action
::
className
(),
'modelClass'
=>
CoContent
::
className
()
]
];
...
...
frontend/modules/api/docs/static.md
View file @
76eeca54
...
...
@@ -2,9 +2,9 @@
Используется для получения контента страницы API.
**URL**
:
`/api/static/{
id
}`
**URL**
:
`/api/static/{
slug
}`
`{
id}`
- идентификатор
страницы, можно узнать в ПУ http://taskon.task-on.com/content/content-admin/manage
`{
slug}`
- url
страницы, можно узнать в ПУ http://taskon.task-on.com/content/content-admin/manage
**Method**
:
`GET`
...
...
@@ -12,7 +12,7 @@
**Data example**
`/api/static/
9
`
`/api/static/
for-api
`
## Success Response
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment