Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
new_project
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Telenkov Ruslan
new_project
Commits
1d81fd90
Commit
1d81fd90
authored
Jul 11, 2022
by
Telenkov Ruslan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ALL TASK
parent
7c804b3c
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
138 additions
and
117 deletions
+138
-117
BatchCommands.php
...croot/modules/custom/drush/src/Commands/BatchCommands.php
+27
-28
formApi.module
app/docroot/modules/custom/formApi/formApi.module
+3
-1
FormApiTask.php
app/docroot/modules/custom/formApi/src/Form/FormApiTask.php
+17
-0
link_test.info.yml
app/docroot/modules/custom/link_test/link_test.info.yml
+4
-0
link_test.routing.yml
app/docroot/modules/custom/link_test/link_test.routing.yml
+7
-0
LinkPage.php
...root/modules/custom/link_test/src/Controller/LinkPage.php
+31
-0
DrupalLocalTask.php
...dules/custom/localtask/src/Controller/DrupalLocalTask.php
+1
-0
MyService.php
...oot/modules/custom/myservice/src/Controller/MyService.php
+2
-2
role.module
app/docroot/modules/custom/role/role.module
+3
-6
GetUserByEmailResource.php
...block/src/Plugin/rest/resource/GetUserByEmailResource.php
+20
-73
ConBlock.php
...odules/custom/testblocklast/src/Plugin/Block/ConBlock.php
+6
-7
student-registration-form.html.twig
...stom/thanks/templates/student-registration-form.html.twig
+4
-0
test.html.twig
app/docroot/modules/custom/thanks/templates/test.html.twig
+0
-0
thanks.module
app/docroot/modules/custom/thanks/thanks.module
+13
-0
No files found.
app/docroot/modules/custom/drush/src/Commands/BatchCommands.php
View file @
1d81fd90
...
@@ -37,46 +37,45 @@ class BatchCommands extends DrushCommands
...
@@ -37,46 +37,45 @@ class BatchCommands extends DrushCommands
* @param $date Argument with text to be printed
* @param $date Argument with text to be printed
* @aliases go-api
* @aliases go-api
*/
*/
public
function
goApi
(
$date
=
null
)
public
function
goApi
(
$date
=
null
)
{
{
//дата 0 - не ввели дату
//дата 0 - не ввели дату
if
(
$date
===
null
){
if
(
$date
===
null
){
$this
->
output
()
->
writeln
(
'Вы не ввели дату'
);
$this
->
output
()
->
writeln
(
'Вы не ввели дату'
);
return
;
}
}
else
{
$timestamp
=
strtotime
(
$date
);
//перевод даты в нужный формат
$service
=
\Drupal
::
service
(
'myservice.my'
);
//обраение к сервису
$request
=
$service
->
getResult
(
'https://swapi.dev/api/'
);
// получение адресов апи
foreach
(
$request
as
$api_url
)
{
//цикл для каждого url апишки
$url
=
$api_url
;
do
{
$request_items
=
$service
->
getResult
(
$url
);
// обращаюсь к сервису, получаю уже на основе точного url элементы
$result_items
=
$request_items
->
results
;
// выкинул служебную информацию, более структурировано выглядит
foreach
(
$result_items
as
$row_item
)
{
//прохожусь по каждому элементу
$timestamp
=
strtotime
(
$date
);
//перевод даты в нужный формат
$service
=
\Drupal
::
service
(
'myservice.my'
);
//обраение к сервису
$request
=
$service
->
getResult
(
'https://swapi.dev/api/'
);
// получение адресов апи
foreach
(
$request
as
$api_url
)
{
//цикл для каждого url апишки
$url
=
$api_url
;
do
{
$request_items
=
$service
->
getResult
(
$url
);
// обращаюсь к сервису, получаю уже на основе точного url элементы
$result_items
=
$request_items
->
results
;
// выкинул служебную информацию, более структурировано выглядит
$timestamp_swapi
=
strtotime
(
$row_item
->
edited
);
// получаю дату со свапи
foreach
(
$result_items
as
$row_item
)
{
//прохожусь по каждому элементу
if
(
$timestamp
<
$timestamp_swapi
)
{
//если дата меньше чем дата свапи, делаею дальнейшую обработку элемента
$type
=
$service
->
nodeType
(
$row_item
->
url
);
// получаю ID ноды для дальнейшей проверки из БД
$timestamp_swapi
=
strtotime
(
$row_item
->
edited
);
// получаю дату со свапи
$id
=
$service
->
nodeId
(
$row_item
->
url
);
// получаю тип ноды для дальнейшей проверки из БД
if
(
$timestamp
<
$timestamp_swapi
)
{
//если дата меньше чем дата свапи, делаею дальнейшую обработку элемента
$nids
=
$service
->
existNode
(
$type
,
$id
);
// вызываю функцию проверки ноды в БД, если есть, то вернется ID
$this
->
output
()
->
writeln
(
'Обработана сущность: '
.
$type
.
$id
);
// более корректный вывод в самой команде
$type
=
$service
->
nodeType
(
$row_item
->
url
);
// получаю ID ноды для дальнейшей проверки из БД
if
(
empty
(
$nids
))
{
$id
=
$service
->
nodeId
(
$row_item
->
url
);
// получаю тип ноды для дальнейшей проверки из БД
$service
->
createNode
(
$row_item
);
// вызываю метод создания ноды из сервиса
$nids
=
$service
->
existNode
(
$type
,
$id
);
// вызываю функцию проверки ноды в БД, если есть, то вернется ID
$service
->
updateNode
(
$row_item
);
// сразу апдейт, чтобы 2 раза не запускать прогу , если нод реферанца нет - создат и свяжет ТОЛЬКО на нужную референц
$this
->
output
()
->
writeln
(
'Обработана сущность: '
.
$type
.
$id
);
// более корректный вывод в самой команде
}
else
{
if
(
empty
(
$nids
))
{
$service
->
updateNode
(
$row_item
);
$service
->
createNode
(
$row_item
);
// вызываю метод создания ноды из сервиса
}
$service
->
updateNode
(
$row_item
);
// сразу апдейт, чтобы 2 раза не запускать прогу , если нод реферанца нет - создат и свяжет ТОЛЬКО на нужную референц
}
else
{
$service
->
updateNode
(
$row_item
);
}
}
}
}
}
$url
=
$request_items
->
next
;
// меняем УРЛ чтобы перейти на следующую страницу в апи
$url
=
$request_items
->
next
;
// меняем УРЛ чтобы перейти на следующую страницу в апи
}
while
(
$url
);
// пока есть урл, т е пока у меня есть следующая страница
}
while
(
$url
);
// пока есть урл, т е пока у меня есть следующая страница
}
}
}
}
}
/**
/**
* A custom Drush command to displays the given text.
* A custom Drush command to displays the given text.
*
*
...
...
app/docroot/modules/custom/formApi/formApi.module
View file @
1d81fd90
...
@@ -6,7 +6,9 @@
...
@@ -6,7 +6,9 @@
function
formApi_theme
(
$existing
,
$type
,
$theme
,
$path
)
{
function
formApi_theme
(
$existing
,
$type
,
$theme
,
$path
)
{
return
[
return
[
'form_theme'
=>
[
'form_theme'
=>
[
'variables'
=>
[],
'variables'
=>
[
'result'
=>
''
,
],
],
],
];
];
}
}
...
...
app/docroot/modules/custom/formApi/src/Form/FormApiTask.php
View file @
1d81fd90
...
@@ -187,6 +187,23 @@ class FormApiTask extends FormBase {
...
@@ -187,6 +187,23 @@ class FormApiTask extends FormBase {
->
execute
();
->
execute
();
$content1
[
'#attached'
][
'library'
][]
=
'core/drupal.dialog.ajax'
;
$content1
[
'#attached'
][
'library'
][]
=
'core/drupal.dialog.ajax'
;
$myConfigPage
=
\Drupal\config_pages\Entity\ConfigPages
::
config
(
'custom_config'
);
$string_modal
=
$myConfigPage
->
get
(
'field_modal_title'
)
->
value
;
$current_user
=
\Drupal
::
currentUser
();
$user
=
\Drupal\user\Entity\User
::
load
(
$current_user
->
id
());
$name
=
$user
->
get
(
'name'
)
->
value
;
$user_last_name
=
$user
->
field_last_name
->
value
;
if
(
$name
==
NULL
){
$content1
[
'#result'
]
=
$string_modal
.
", гость!"
;
}
else
{
$content1
[
'#result'
]
=
$string_modal
.
', '
.
$user_last_name
.
' '
.
$name
;
}
$content1
[
'#theme'
]
=
'form_theme'
;
$content1
[
'#theme'
]
=
'form_theme'
;
$title
=
'Сообщение'
;
$title
=
'Сообщение'
;
$response
->
addCommand
(
new
OpenModalDialogCommand
(
$title
,
$content1
,
[
'width'
=>
'200'
,
'height'
=>
'200'
]));
$response
->
addCommand
(
new
OpenModalDialogCommand
(
$title
,
$content1
,
[
'width'
=>
'200'
,
'height'
=>
'200'
]));
...
...
app/docroot/modules/custom/link_test/link_test.info.yml
0 → 100644
View file @
1d81fd90
name
:
Link Task
package
:
Custom
type
:
module
core_version_requirement
:
^8.8 || ^9
app/docroot/modules/custom/link_test/link_test.routing.yml
0 → 100644
View file @
1d81fd90
bootcamptest1.thank_you
:
path
:
'
/link-task'
defaults
:
_controller
:
'
\Drupal\link_test\Controller\LinkPage::content'
_title
:
'
Thanks
for
you
answer'
requirements
:
_permission
:
'
access
content'
app/docroot/modules/custom/link_test/src/Controller/LinkPage.php
0 → 100644
View file @
1d81fd90
<?php
namespace
Drupal\link_test\Controller
;
use
Drupal\bootcamp\Form\BootcampSettingsForm
;
use
Drupal\media\Entity\Media
;
use
Drupal\file\Entity\File
;
/**
* Provides route responses for the DrupalBook module.
*/
//унаследовал класс
class
LinkPage
{
public
function
content
(){
$element
=
array
(
'#markup'
=>
'Hello'
,
);
$media
=
Media
::
loadMultiple
();
foreach
(
$media
as
$media_file
){
$mid
=
$media_file
->
get
(
'mid'
)
->
value
;
$fid
=
$media_file
->
getSource
()
->
getSourceFieldValue
(
$media_file
);
$file
=
File
::
load
(
$fid
);
$url
[]
=
$file
->
url
();
}
return
$element
;
}
}
app/docroot/modules/custom/localtask/src/Controller/DrupalLocalTask.php
View file @
1d81fd90
...
@@ -9,6 +9,7 @@ class DrupalLocalTask {
...
@@ -9,6 +9,7 @@ class DrupalLocalTask {
public
function
getResult
(
$url
)
public
function
getResult
(
$url
)
{
{
//иньъек.зависимости протестировать
try
{
try
{
// Отправка GET-запроса
// Отправка GET-запроса
$request
=
\Drupal
::
httpClient
()
->
get
(
$url
);
$request
=
\Drupal
::
httpClient
()
->
get
(
$url
);
...
...
app/docroot/modules/custom/myservice/src/Controller/MyService.php
View file @
1d81fd90
...
@@ -48,6 +48,7 @@ class MyService
...
@@ -48,6 +48,7 @@ class MyService
{
{
$array_of_url
=
explode
(
'/'
,
$api_url
);
//разделяю адрес АПИ на массив элементов
$array_of_url
=
explode
(
'/'
,
$api_url
);
//разделяю адрес АПИ на массив элементов
$node_id
=
$array_of_url
[
5
];
$node_id
=
$array_of_url
[
5
];
return
$node_id
;
return
$node_id
;
}
}
...
@@ -187,8 +188,7 @@ class MyService
...
@@ -187,8 +188,7 @@ class MyService
}
}
public
function
createNode
(
$row_item
)
public
function
createNode
(
$row_item
)
{
{
$api_url
=
(
string
)
$row_item
->
url
;
//получаю URL будущей ноды
$api_url
=
(
string
)
$row_item
->
url
;
//получаю URL будущей ноды
$type_of_node
=
$this
->
nodeType
(
$api_url
);
//получаю тип ноды
$type_of_node
=
$this
->
nodeType
(
$api_url
);
//получаю тип ноды
$node_id
=
$this
->
nodeId
(
$api_url
);
$node_id
=
$this
->
nodeId
(
$api_url
);
...
...
app/docroot/modules/custom/role/role.module
View file @
1d81fd90
...
@@ -10,7 +10,7 @@ function role_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Se
...
@@ -10,7 +10,7 @@ function role_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Se
//получаю тип ноды текущей
//получаю тип ноды текущей
$type
=
$node
$type
=
$node
->
bundle
();
->
bundle
();
// для одного
if
(
in_array
(
'redaktory'
,
$account
->
getRoles
())){
if
(
in_array
(
'redaktory'
,
$account
->
getRoles
())){
if
(
$type
==
'editor'
&&
$op
==
'update'
)
{
if
(
$type
==
'editor'
&&
$op
==
'update'
)
{
//Узнать uid в поле ноды
//Узнать uid в поле ноды
...
@@ -19,14 +19,11 @@ function role_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Se
...
@@ -19,14 +19,11 @@ function role_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Se
$uid_now
=
$account
->
id
();
$uid_now
=
$account
->
id
();
//сравниваю айдишники и если равны то разрешаю доступ на редактирование
//сравниваю айдишники и если равны то разрешаю доступ на редактирование
if
(
$uid_now
==
$uid_role
)
{
if
(
$uid_now
==
$uid_role
)
{
return
AccessResult
::
allowed
();
return
AccessResult
::
allowed
();
//изменить ,, нужно ли запретить
}
}
}
}
}
}
return
AccessResult
::
neutral
();
// if ($type == 'editor' && $op == 'create') {
//$a =1;
// }
}
}
/**
/**
* Implements hook_form_alter().
* Implements hook_form_alter().
...
...
app/docroot/modules/custom/testblock/src/Plugin/rest/resource/GetUserByEmailResource.php
View file @
1d81fd90
...
@@ -10,6 +10,7 @@ use Drupal\rest\ResourceResponse;
...
@@ -10,6 +10,7 @@ use Drupal\rest\ResourceResponse;
use
Drupal\user\UserInterface
;
use
Drupal\user\UserInterface
;
use
Psr\Log\LoggerInterface
;
use
Psr\Log\LoggerInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
;
use
Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
;
use
Drupal\Core\Url
;
use
Drupal\Core\Url
;
/**
/**
...
@@ -82,7 +83,7 @@ class GetUserByEmailResource extends ResourceBase {
...
@@ -82,7 +83,7 @@ class GetUserByEmailResource extends ResourceBase {
/**
/**
* Responds to GET requests.
* Responds to GET requests.
*/
*/
public
function
get
()
{
public
function
get
(
Request
$request
)
{
if
(
!
$this
->
currentUser
->
hasPermission
(
'access content'
))
{
if
(
!
$this
->
currentUser
->
hasPermission
(
'access content'
))
{
throw
new
AccessDeniedHttpException
();
throw
new
AccessDeniedHttpException
();
}
}
...
@@ -100,7 +101,7 @@ class GetUserByEmailResource extends ResourceBase {
...
@@ -100,7 +101,7 @@ class GetUserByEmailResource extends ResourceBase {
];
];
// page = 0;
// page = 0;
// получаю параметры текущей страницы из запроса пользователя, если нет то выставляю дефолтные значения
// получаю параметры текущей страницы из запроса пользователя, если нет то выставляю дефолтные значения
$request
=
\Drupal
::
request
();
//
$request = \Drupal::request();
$request_query
=
$request
->
query
;
$request_query
=
$request
->
query
;
$request_query_array
=
$request_query
->
all
();
$request_query_array
=
$request_query
->
all
();
$limit
=
$request_query
->
get
(
'limit'
)
?:
$this
->
limit
;
$limit
=
$request_query
->
get
(
'limit'
)
?:
$this
->
limit
;
...
@@ -121,7 +122,7 @@ class GetUserByEmailResource extends ResourceBase {
...
@@ -121,7 +122,7 @@ class GetUserByEmailResource extends ResourceBase {
$response
[
'next_page'
]
=
Url
::
createFromRequest
(
$request
)
$response
[
'next_page'
]
=
Url
::
createFromRequest
(
$request
)
->
setOption
(
'query'
,
$next_page_query
)
->
setOption
(
'query'
,
$next_page_query
)
->
toString
(
TRUE
)
->
toString
(
TRUE
)
->
getGeneratedUrl
();
->
getGeneratedUrl
();
//протестировать
}
}
$response
[
'count'
]
=
$articles_count
;
$response
[
'count'
]
=
$articles_count
;
...
@@ -150,26 +151,11 @@ class GetUserByEmailResource extends ResourceBase {
...
@@ -150,26 +151,11 @@ class GetUserByEmailResource extends ResourceBase {
/** @var \Drupal\node\Entity\Node $article */
/** @var \Drupal\node\Entity\Node $article */
$testarrayfield
=
[
'field_films'
,
'field_species'
];
foreach
(
$articles
as
$article
)
{
foreach
(
$articles
as
$article
)
{
$rez_film
=
$this
->
getRelatedFilm
(
$article
,
$cache
);
foreach
(
$testarrayfield
as
$field
)
{
if
(
$rez_film
==
NULL
){
$rez
[
$field
]
=
$this
->
getRelated
(
$article
,
$cache
,
$field
);
$rez_film
=
[];
}
$rez_species
=
$this
->
getRelatedSpecies
(
$article
);
if
(
$rez_species
==
NULL
){
$rez_species
=
[];
}
$rez_vehicles
=
$this
->
getRelatedVehicles
(
$article
);
if
(
$rez_vehicles
==
NULL
){
$rez_vehicles
=
[];
}
$rez_starships
=
$this
->
getRelatedStarships
(
$article
);
if
(
$rez_starships
==
NULL
){
$rez_starships
=
[];
}
$rez_homeworld
=
$this
->
getRelatedHomeworld
(
$article
);
if
(
$rez_homeworld
==
NULL
){
$rez_homeworld
=
[];
}
}
$response
[
'results'
][]
=
[
$response
[
'results'
][]
=
[
...
@@ -181,11 +167,11 @@ class GetUserByEmailResource extends ResourceBase {
...
@@ -181,11 +167,11 @@ class GetUserByEmailResource extends ResourceBase {
'eye_color'
=>
$article
->
get
(
'field_eye_color'
)
->
value
,
'eye_color'
=>
$article
->
get
(
'field_eye_color'
)
->
value
,
'birth_year'
=>
$article
->
get
(
'field_birth_year'
)
->
value
,
'birth_year'
=>
$article
->
get
(
'field_birth_year'
)
->
value
,
'gender'
=>
$article
->
get
(
'field_gender'
)
->
value
,
'gender'
=>
$article
->
get
(
'field_gender'
)
->
value
,
'homeworld'
=>
$rez
_homeworld
,
'homeworld'
=>
$rez
[
'field_homeworld'
]
,
'films'
=>
$rez
_film
,
'films'
=>
$rez
[
'field_films'
]
,
'species'
=>
$rez
_species
,
'species'
=>
$rez
[
'field_species'
]
,
'vehicles'
=>
$rez
_vehicles
,
'vehicles'
=>
$rez
[
'field_vehicles'
]
,
'starships'
=>
$rez
_starships
,
'starships'
=>
$rez
[
'field_starships'
]
,
'created'
=>
$article
->
getCreatedTime
(),
'created'
=>
$article
->
getCreatedTime
(),
'edited'
=>
$article
->
getChangedTime
(),
'edited'
=>
$article
->
getChangedTime
(),
'url'
=>
$article
->
get
(
'field_url'
)
->
value
,
'url'
=>
$article
->
get
(
'field_url'
)
->
value
,
...
@@ -195,56 +181,17 @@ class GetUserByEmailResource extends ResourceBase {
...
@@ -195,56 +181,17 @@ class GetUserByEmailResource extends ResourceBase {
return
(
new
ResourceResponse
(
$response
,
200
))
->
addCacheableDependency
(
$cache
);
return
(
new
ResourceResponse
(
$response
,
200
))
->
addCacheableDependency
(
$cache
);
}
}
public
function
getRelatedFilm
(
$article
,
&
$cache
){
public
function
getRelated
(
$article
,
&
$cache
,
$field
){
$person_film
=
$article
->
field_films
->
referencedEntities
();
foreach
(
$person_film
as
$film
){
$related
=
$article
->
get
(
$field
)
->
referencedEntities
();
$cache
->
addCacheableDependency
(
$film
);
foreach
(
$related
as
$value
){
$res_film
[]
=
[
$cache
->
addCacheableDependency
(
$value
);
$film
->
nid
->
value
=>
$film
->
getTitle
()
$res_film
[]
=
[
];
$value
->
id
()
=>
$value
->
label
()
}
return
$res_film
;
}
public
function
getRelatedSpecies
(
$article
){
$person_spacie
=
$article
->
field_species
->
referencedEntities
();
foreach
(
$person_spacie
as
$specie
){
$res_specie
[]
=
[
$specie
->
nid
->
value
=>
$specie
->
getTitle
()
];
}
return
$res_specie
;
}
public
function
getRelatedVehicles
(
$article
){
$person_vehicles
=
$article
->
field_vehicles
->
referencedEntities
();
foreach
(
$person_vehicles
as
$vehicle
){
$res_vehicles
[]
=
[
$vehicle
->
nid
->
value
=>
$vehicle
->
getTitle
()
];
}
return
$res_vehicles
;
}
public
function
getRelatedStarships
(
$article
){
$person_starships
=
$article
->
field_starships
->
referencedEntities
();
foreach
(
$person_starships
as
$starships
){
$res_starships
[]
=
[
$starships
->
nid
->
value
=>
$starships
->
getTitle
()
];
];
}
}
return
$res_
starships
;
return
$res_
film
;
}
}
public
function
getRelatedHomeworld
(
$article
){
$person_homeworld
=
$article
->
field_homeworld
->
referencedEntities
();
foreach
(
$person_homeworld
as
$p_h
){
$res_homeworld
[]
=
[
$p_h
->
nid
->
value
=>
$p_h
->
getTitle
()
];
}
return
$res_homeworld
;
}
public
function
post
(
$data
)
{
public
function
post
(
$data
)
{
if
(
!
$this
->
currentUser
->
hasPermission
(
'create article content'
))
{
if
(
!
$this
->
currentUser
->
hasPermission
(
'create article content'
))
{
...
...
app/docroot/modules/custom/testblocklast/src/Plugin/Block/ConBlock.php
View file @
1d81fd90
...
@@ -30,19 +30,18 @@ class ConBlock extends BlockBase{
...
@@ -30,19 +30,18 @@ class ConBlock extends BlockBase{
$output
=
''
;
$output
=
''
;
$node
=
$this
->
getContextValue
(
'node'
);
$node
=
$this
->
getContextValue
(
'node'
);
$term
=
$this
->
getContextValue
(
'term'
);
$term
=
$this
->
getContextValue
(
'term'
);
if
(
$node
!=
null
){
$rss_output
=
[];
if
(
!
empty
(
$node
)){
$view_builder
=
\Drupal
::
entityTypeManager
()
->
getViewBuilder
(
'node'
);
$view_builder
=
\Drupal
::
entityTypeManager
()
->
getViewBuilder
(
'node'
);
$rss_output
=
$view_builder
->
view
(
$node
,
'teaser'
);
$rss_output
=
$view_builder
->
view
(
$node
,
'teaser'
);
$output
=
\Drupal
::
service
(
'renderer'
)
->
render
(
$rss_output
);
//
$output = \Drupal::service('renderer')->render($rss_output);
}
}
else
{
else
if
(
!
empty
(
$term
))
{
$view_builder
=
\Drupal
::
entityTypeManager
()
->
getViewBuilder
(
'taxonomy_term'
);
$view_builder
=
\Drupal
::
entityTypeManager
()
->
getViewBuilder
(
'taxonomy_term'
);
$rss_output
=
$view_builder
->
view
(
$term
,
'teaser'
);
$rss_output
=
$view_builder
->
view
(
$term
,
'teaser'
);
$output
=
\Drupal
::
service
(
'renderer'
)
->
render
(
$rss_output
);
//
$output = \Drupal::service('renderer')->render($rss_output);
}
}
return
[
return
$rss_output
;
'#markup'
=>
$output
,
];
}
}
}
}
app/docroot/modules/custom/thanks/templates/student-registration-form.html.twig
0 → 100644
View file @
1d81fd90
<form
{{
attributes
}}
>
{{
form
}}
</form>
app/docroot/modules/custom/thanks/templates/test.html.twig
0 → 100644
View file @
1d81fd90
app/docroot/modules/custom/thanks/thanks.module
View file @
1d81fd90
...
@@ -8,6 +8,12 @@ function thanks_theme($existing, $type, $theme, $path) {
...
@@ -8,6 +8,12 @@ function thanks_theme($existing, $type, $theme, $path) {
'dummy_example_first'
=>
[
'dummy_example_first'
=>
[
'variables'
=>
[],
'variables'
=>
[],
],
],
'test'
=>
[
'render element'
=>
'element'
],
'student_registration_form'
=>
[
'render element'
=>
'form'
]
];
];
}
}
/**
/**
...
@@ -18,3 +24,10 @@ function template_preprocess_dummy_example_first(&$variables) {
...
@@ -18,3 +24,10 @@ function template_preprocess_dummy_example_first(&$variables) {
$date_formatter
=
\Drupal
::
service
(
'date.formatter'
);
$date_formatter
=
\Drupal
::
service
(
'date.formatter'
);
$variables
[
'date'
]
=
$date_formatter
->
format
(
time
());
$variables
[
'date'
]
=
$date_formatter
->
format
(
time
());
}
}
function
thanks_form_alter
(
&
$form
,
\Drupal\Core\Form\FormStateInterface
$form_state
,
$form_id
){
if
(
$form_id
==
'student_registration_form'
)
{
$form
[
'name'
][
'#theme'
]
=
'test'
;
$form
[
'#theme'
]
=
'student_registration_form'
;
}
}
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