Commit 45611519 authored by Telenkov Ruslan's avatar Telenkov Ruslan

3 done

parent 73649fbf
......@@ -25,6 +25,7 @@
"drupal/devel_php": "^1.0",
"drupal/field_group": "^3.2",
"drupal/fontawesome_menu_icons": "^1.9",
"drupal/jquery_ui": "^1.4",
"drupal/layout_builder_restrictions": "^2.13",
"drupal/media_library_block": "^1.0",
"drupal/media_library_form_element": "^2.0",
......@@ -32,6 +33,7 @@
"drupal/module_filter": "^3.2",
"drupal/paragraphs": "^1.13",
"drupal/pathauto": "^1.9",
"drupal/queue_ui": "^3.0",
"drupal/quick_node_clone": "^1.14",
"drupal/rabbit_hole": "^2.26",
"drupal/recaptcha": "^3.0",
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "26bb62d404a206b96084a0b93b84439e",
"content-hash": "854deeed64fa5e16b6ea003e4348660d",
"packages": [
{
"name": "asm89/stack-cors",
......@@ -3734,6 +3734,89 @@
"documentation": "https://www.drupal.org/docs/8/modules/pathauto"
}
},
{
"name": "drupal/queue_ui",
"version": "3.0.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/queue_ui.git",
"reference": "3.0.0"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/queue_ui-3.0.0.zip",
"reference": "3.0.0",
"shasum": "6f9dcff081c601668f06c4733e13228e4defed35"
},
"require": {
"drupal/core": "^9.2 || ^10"
},
"require-dev": {
"drupal/queue_order": "^2"
},
"type": "drupal-module",
"extra": {
"drupal": {
"version": "3.0.0",
"datestamp": "1650616744",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
},
"drush": {
"services": {
"drush.services.yml": "^9 || ^10 || ^11"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0+"
],
"authors": [
{
"name": "floretan",
"homepage": "https://www.drupal.org/user/2743951",
"role": "Maintainer"
},
{
"name": "coltrane",
"homepage": "https://www.drupal.org/user/91990",
"role": "Maintainer"
},
{
"name": "tsphethean",
"homepage": "https://www.drupal.org/user/66163",
"role": "Maintainer"
},
{
"name": "bceyssens",
"homepage": "https://www.drupal.org/user/2811585",
"role": "Maintainer"
},
{
"name": "voleger",
"homepage": "https://www.drupal.org/user/881620",
"role": "Maintainer"
},
{
"name": "voleger",
"homepage": "https://www.drupal.org/user/3260314"
}
],
"description": "Interface and manager for Drupal queues.",
"homepage": "https://www.drupal.org/project/queue_ui",
"keywords": [
"drupal",
"php",
"queue"
],
"support": {
"source": "https://git.drupalcode.org/project/queue_ui",
"issues": "https://www.drupal.org/project/issues/queue_ui"
}
},
{
"name": "drupal/quick_node_clone",
"version": "1.14.0",
......
......@@ -9,30 +9,75 @@ use Drupal\node\Entity\Node;
/**
* Implements hook_cron().
*/
function myservice_cron()
{
$people = \Drupal::service('myservice.my')->getResult(); //получаю данные с сервиса
$queue = \Drupal::queue('my_test_queue'); //объявляю очередь
$queue->createQueue();
/*function getResult($queue,$url){
//do {
$request = \Drupal::service('myservice.my')->getResult($url);
$result = $request->results; // выкинул служебную информацию
foreach ($result as $row_item){
$queue->createItem($row_item);
}
//$url = $request->next;
//} while ($url);
foreach ($people as $person)
$queue->createItem([ //наполняю очередь данными
'name' => $person->name,
]);
$item = $queue->claimItem(); // получаю элементы очереди
return $queue;
}
/*
/*function getNodePeople($queue){
$end = time() + 30;
while (time() < $end && ($item = $queue->claimItem())) {
$fieldurl = (string)$item->data->url;
preg_match_all("/\d+/", $fieldurl, $counter);
# Данные которые мы добавляли в очередь находятся в $item->data.
$node = Node::create(array(
'name' => $item->data['name'],
'type' => 'people' ,
'title' => 'people' . $counter[0][0],
'field_name' =>$item->data->name,
'field_height' =>$item->data->height,
'field_mass' =>$item->data->mass,
'field_hair_color' =>$item->data->hair_color,
'field_skin_color' =>$item->data->skin_color,
'field_eye_color' =>$item->data->eye_color,
'field_birth_year' =>$item->data->birth_year,
'field_gender' =>$item->data->gender,
'langcode' => 'ru',
'status' => 1,
));
$node->save();
}
$queue->deleteItem($item); //удаление элементов
}
$queue->deleteQueue(); //удаление очереди
}
*/
function myservice_cron()
{
$queue = \Drupal::queue('my_test_queue'); //объявляю очередь
$queue->createQueue();
$request = \Drupal::service('myservice.my')->getResult('https://swapi.dev/api/');
// $result = $request->results; // выкинул служебную информацию
foreach ($request as $row_item){
$queue->createItem($row_item);
}
//getResult($queue,'https://swapi.dev/api/');
//getNodePeople($queue);
}
......@@ -8,13 +8,14 @@ use GuzzleHttp\Client;
class MyService
{
public function getResult()
public function getResult($url)
{
// Отправка GET-запроса
$request = \Drupal::httpClient()->get('https://swapi.dev/api/people/');
$request = \Drupal::httpClient()->get($url);
// Ответ GET-запроса
$response = $request->getBody()->getContents();
$result = json_decode($response)->results;
$result = json_decode($response);
return $result;
}
......
<?php
namespace Drupal\myservice\Plugin\QueueWorker;
use Drupal\Core\Queue\QueueWorkerBase;
use Drupal\myservice\Plugin\QueueWorker\MyQueueWorker;
use Drupal\node\Entity\Node;
/**
* Process a queue.
*
* @QueueWorker(
* id = "my_node_queue",
* title = @Translation("Create Node"),
* cron = {"time" = 60}
* )
*/
class MyNodeQueueWorker extends QueueWorkerBase
{
// Функция для определения типа материала, для дальнейшего создания ноды по данному типу
public function nodeType($api_url){
$array_of_url = explode('/', $api_url); //разделяю адрес АПИ на массив элементов
$type_of_node = $array_of_url[4]; // название необходимой ноды - ВСЕГДА четвертый элемент данного массива
return $type_of_node;
}
public function nodeId($api_url){
$array_of_url = explode('/', $api_url); //разделяю адрес АПИ на массив элементов
$node_id = $array_of_url[5];
return $node_id;
}
public function processItem($data){
$api_url = (string)$data->url; //получаю URL будущей ноды
$type_of_node = $this->nodeType($api_url); //получаю тип ноды
$node_id = $this->nodeId($api_url);
preg_match_all("/\d+/", $api_url, $counter);
//Вызываю создание нод для каждого типа материала
if ($type_of_node == 'people'){
//проверить на наличие ноды по полю id и если она есть
$this->createPeopleNode($counter,$data,$node_id);
}
elseif ($type_of_node == 'films'){
$this->createFilmsNode($counter,$data,$node_id);
}
elseif ($type_of_node == 'planets'){
$this->createPlanetsNode($counter,$data,$node_id);
}
elseif ($type_of_node == 'species'){
$this->createSpeciesNode($counter,$data,$node_id);
}
elseif ($type_of_node == 'starships'){
$this->createStarshipsNode($counter,$data,$node_id);
}
elseif ($type_of_node == 'vehicles'){
$this->createVehiclesNode($counter,$data,$node_id);
}
}
/**
* @throws \Drupal\Core\Entity\EntityStorageException
*/
public function createPeopleNode($counter, $data, $node_id){
$node = Node::create(array(
'type' => 'people' ,
'title' => 'people' . $counter[0][0],
'field_swapi_id' => $node_id,
'field_name' =>$data->name,
'field_height' =>$data->height,
'field_mass' =>$data->mass,
'field_hair_color' =>$data->hair_color,
'field_skin_color' =>$data->skin_color,
'field_eye_color' =>$data->eye_color,
'field_birth_year' =>$data->birth_year,
'field_gender' =>$data->gender,
'langcode' => 'ru',
'status' => 1,
));
$node->save();
}
/**
* @throws \Drupal\Core\Entity\EntityStorageException
*/
public function createFilmsNode($counter, $data, $node_id){
$node = Node::create(array(
'type' => 'films' ,
'title' => 'film' . $counter[0][0],
'field_swapi_id' => $node_id,
'field_title' =>$data->title,
'field_episode_id' =>$data->episode_id,
'field_director' =>$data->director,
'field_opening_crawl' =>$data->opening_crawl,
'field_producer' =>$data->producer,
'field_release_date' =>$data->release_date,
'langcode' => 'ru',
'status' => 1,
));
$node->save();
}
/**
* @throws \Drupal\Core\Entity\EntityStorageException
*/
public function createPlanetsNode($counter, $data ,$node_id){
$node = Node::create(array(
'type' => 'planets' ,
'title' => 'planet' . $counter[0][0],
'field_swapi_id' => $node_id,
'field_name' =>$data->name,
'field_diameter' =>$data->diameter,
'field_rotation_period' =>$data->rotation_period,
'field_orbital_period' =>$data->orbital_period,
'field_gravity ' =>$data->gravity,
'field_population' =>$data->population,
'field_climate' =>$data->climate,
'field_terrain' =>$data->terrain,
'field_surface_water' =>$data->surface_water,
'langcode' => 'ru',
'status' => 1,
));
$node->save();
}
/**
* @throws \Drupal\Core\Entity\EntityStorageException
*/
public function createSpeciesNode($counter, $data ,$node_id)
{
$node = Node::create(array(
'type' => 'species' ,
'title' => 'specie' . $counter[0][0],
'field_swapi_id' => $node_id,
'field_name' =>$data->name,
'field_language' =>$data->language,
'field_skin_colors' =>$data->skin_colors,
'field_hair_colors' =>$data->hair_colors,
'field_eye_colors' =>$data->eye_colors,
'field_designation' =>$data->designation,
'field_classification' =>$data->classification,
'field_average_lifespan' =>$data->average_lifespan,
'field_average_height' =>$data->average_height,
'langcode' => 'ru',
'status' => 1,
));
$node->save();
}
/**
* @throws \Drupal\Core\Entity\EntityStorageException
*/
public function createStarshipsNode($counter, $data ,$node_id){
$node = Node::create(array(
'type' => 'starships' ,
'title' => 'starship' . $counter[0][0],
'field_swapi_id' => $node_id,
'field_name' =>$data->name,
'field_model' =>$data->model,
'field_starship_class' =>$data->starship_class,
'field_manufacturer' =>$data->manufacturer,
'field_cost_in_credits' =>$data->cost_in_credits,
'field_length' =>$data->length,
'field_crew' =>$data->crew,
'field_passengers' =>$data->passengers,
'field_max_atmosphering_speed' =>$data->max_atmosphering_speed,
'field_hyperdrive_rating' =>$data->hyperdrive_rating,
'field_MGLT' =>$data->MGLT,
'cargo_capacity' =>$data->cargo_capacity,
'field_consumables' =>$data->consumables,
'langcode' => 'ru',
'status' => 1,
));
$node->save();
}
/**
* @throws \Drupal\Core\Entity\EntityStorageException
*/
public function createVehiclesNode($counter, $data, $node_id){
$node = Node::create(array(
'type' => 'vehicles' ,
'title' => 'vehicle' . $counter[0][0],
'field_swapi_id' => $node_id,
'field_name' =>$data->name,
'field_model' =>$data->model,
'field_vehicle_class' =>$data->vehicle_class,
'field_manufacturer' =>$data->manufacturer,
'field_cost_in_credits' =>$data->cost_in_credits,
'field_length' =>$data->length,
'field_crew' =>$data->crew,
'field_passengers' =>$data->passengers,
'field_max_atmosphering_speed' =>$data->max_atmosphering_speed,
'cargo_capacity' =>$data->cargo_capacity,
'field_consumables' =>$data->consumables,
'langcode' => 'ru',
'status' => 1,
));
$node->save();
}
}
<?php
namespace Drupal\myservice\Plugin\QueueWorker;
use Drupal\Core\Queue\QueueWorkerBase;
/**
* Process a queue.
*
* @QueueWorker(
* id = "my_test_queue",
* title = @Translation("My queue worker"),
* cron = {"time" = 60}
* )
*/
class MyQueueWorker extends QueueWorkerBase {
/**
* {@inheritdoc}
*/
public function existNode($type, $id){
$query = \Drupal::entityQuery('node')
->condition('type', $type)
->condition('field_swapi_id', $id);
$nids = $query->execute();
return $nids;
}
public function nodeType($api_url){
$array_of_url = explode('/', $api_url); //разделяю адрес АПИ на массив элементов
$type_of_node = $array_of_url[4]; // название необходимой ноды - ВСЕГДА четвертый элемент данного массива
return $type_of_node;
}
public function nodeId($api_url){
$array_of_url = explode('/', $api_url); //разделяю адрес АПИ на массив элементов
$node_id = $array_of_url[5];
return $node_id;
}
// 1 API
public function processItem($data)
{
$queue = \Drupal::queue('my_node_queue'); //объявляю очередь
$secondQueue = \Drupal::queue('my_second_node_queue');
$url = $data;
do {
$request = \Drupal::service('myservice.my')->getResult($url);
$result = $request->results; // выкинул служебную информацию
foreach ($result as $row_item){
$type = $this->nodeType($row_item->url); // получаю ID ноды для дальнейшей проверки из БД
$id = $this -> nodeId($row_item->url); // получаю тип ноды для дальнейшей проверки из БД
$nids = $this->existNode($type, $id); // вызываю функцию проверки ноды в БД, если есть, то вернется ID
if (empty($nids)){
$queue->createItem($row_item);
}
else {
$secondQueue->createItem($row_item);
}
}
$url = $request->next;
} while ($url);
}
}
<?php
namespace Drupal\myservice\Plugin\QueueWorker;
use Drupal\Core\Queue\QueueWorkerBase;
/**
* Process a queue.
*
* @QueueWorker(
* id = "my_second_node_queue",
* title = @Translation("Update Node"),
* cron = {"time" = 60}
* )
*/
class MySecondQueueWorker extends QueueWorkerBase
{
public function loadNode($type, $swapi_id)
{
$node = \Drupal::entityTypeManager()
->getStorage('node')
->loadByProperties([
'type' => $type,
'field_swapi_id' => $swapi_id,
]);
foreach ($node as $concrete_node) {
return $concrete_node;
}
}
public function nodeType($api_url)
{
$array_of_url = explode('/', $api_url); //разделяю адрес АПИ на массив элементов
$type_of_node = $array_of_url[4]; // название необходимой ноды - ВСЕГДА четвертый элемент данного массива
return $type_of_node;
}
public function nodeId($api_url)
{
$array_of_url = explode('/', $api_url); //разделяю адрес АПИ на массив элементов
$node_id = $array_of_url[5];
return $node_id;
}
public function getIdArray($array)
{ //получаю массив из адресов сущностей, которые нужно привязать
foreach ($array as $ConcrArray) { // прохожусь по каждому адресу
if ($ConcrArray != NULL) { // адрес должен быть не NULL
$type = $this->nodeType($ConcrArray); // Узнаю тип ноды для связи
$id = $this->nodeId($ConcrArray); // Узнаю айди ноды для связи
$needNode = $this->loadNode($type, $id); //загружаю нужную ноду для связи
$id_array[] = $needNode->id(); // получаю id этой ноды для будущей связи
}
}
return $id_array;
}
public function processItem($data)
{
$type = $this->nodeType($data->url);
$id = $this->nodeId($data->url);
if ($type) {
$node = $this->loadNode($type, $id);
if ($data->films!=[]) {
$array_films = $data->films; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_films); // загрузка новых нод из базы и получение их айдишников
$node->set('field_films', $id_array);
$node->save();
}
if ($data->species!=[]) {
$array_species = $data->species;
$id_array = $this->getIdArray($array_species); // загрузка новых нод из базы и получение их айдишников
$node->set('field_species', $id_array);
$node->save();
}
if ($data->starships!=[]) { // проверяю, есть ли в принципе адреса у поля
$array_starships = $data->starships; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_starships); // загрузка новых нод из базы и получение их айдишников
$node->set('field_starships', $id_array);
$node->save();
}
if ($data->vehicles!=[]) { // проверяю, есть ли в принципе адреса у поля
$array_vehicles = $data->vehicles; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_vehicles); // загрузка новых нод из базы и получение их айдишников
$node->set('field_vehicles', $id_array);
$node->save();
}
if ($data->characters!=[]) { // проверяю, есть ли в принципе адреса у поля
$array_characters = $data->characters; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_characters); // загрузка новых нод из базы и получение их айдишников
$node->set('field_characters', $id_array);
$node->save();
}
if ($data->planets!=[]) { // проверяю, есть ли в принципе адреса у поля
$array_planets = $data->planets; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_planets); // загрузка новых нод из базы и получение их айдишников
$node->set('field_planets', $id_array);
$node->save();
}
if ($data->pilots!=[]) {
$array_pilots = $data->pilots; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_pilots); // загрузка новых нод из базы и получение их айдишников
$node->set('field_pilots', $id_array);
$node->save();
}
if ($data->people!= []) {
$array_people = $data->people; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_people); // загрузка новых нод из базы и получение их айдишников
$node->set('field_people', $id_array);
$node->save();
}
if ($data->residents!= []) {
$array_residents = $data->residents; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_residents); // загрузка новых нод из базы и получение их айдишников
$node->set('field_residents', $id_array);
$node->save();
}
if($data->homeworld){
$homeworld[] = $data->homeworld; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($homeworld); // загрузка новых нод из базы и получение их айдишников
$node->set('field_homeworld', $id_array);
$node->save();
}
}
}
}
/*if ($type == 'people'){
$node = $this->loadNode($type,$id);
if ($data->films!=[]){
$array_films = $data->films; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_films); // загрузка новых нод из базы и получение их айдишников
$node->set('field_films', $id_array);
$node->save();
}
if ($data->species!=[]){
$array_species = $data->species;
$id_array = $this->getIdArray($array_species); // загрузка новых нод из базы и получение их айдишников
$node->set('field_species', $id_array);
$node->save();
}
if ($data->starships!=[]){ // проверяю, есть ли в принципе адреса у поля
$array_starships = $data->starships; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_starships); // загрузка новых нод из базы и получение их айдишников
$node->set('field_starships', $id_array);
$node->save();
}
if ($data->vehicles!=[]){ // проверяю, есть ли в принципе адреса у поля
$array_vehicles = $data->vehicles; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_vehicles); // загрузка новых нод из базы и получение их айдишников
$node->set('field_vehicles', $id_array);
$node->save();
}
}
if ($type == 'films') {
$node = $this->loadNode($type, $id);
if ($data->species!=[]){
$array_species = $data->species;
$id_array = $this->getIdArray($array_species); // загрузка новых нод из базы и получение их айдишников
$node->set('field_species', $id_array);
$node->save();
}
if ($data->starships!=[]){ // проверяю, есть ли в принципе адреса у поля
$array_starships = $data->starships; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_starships); // загрузка новых нод из базы и получение их айдишников
$node->set('field_starships', $id_array);
$node->save();
}
if ($data->vehicles!=[]){ // проверяю, есть ли в принципе адреса у поля
$array_vehicles = $data->vehicles; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_vehicles); // загрузка новых нод из базы и получение их айдишников
$node->set('field_vehicles', $id_array);
$node->save();
}
if ($data->characters!=[]){ // проверяю, есть ли в принципе адреса у поля
$array_characters = $data->characters; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_characters); // загрузка новых нод из базы и получение их айдишников
$node->set('field_characters', $id_array);
$node->save();
}
if ($data->planets!=[]){ // проверяю, есть ли в принципе адреса у поля
$array_planets = $data->planets; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_planets); // загрузка новых нод из базы и получение их айдишников
$node->set('field_planets', $id_array);
$node->save();
}
}
if ($type == 'starships') {
$node = $this->loadNode($type, $id);
if ($data->films!=[]){
$array_films = $data->films; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_films); // загрузка новых нод из базы и получение их айдишников
$node->set('field_films', $id_array);
$node->save();
}
if ($data->pilots!=[]){
$array_pilots = $data->pilots; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_pilots); // загрузка новых нод из базы и получение их айдишников
$node->set('field_pilots', $id_array);
$node->save();
}
}
if ($type == 'vehicles') {
$node = $this->loadNode($type, $id);
if ($data->films!=[]){
$array_films = $data->films; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_films); // загрузка новых нод из базы и получение их айдишников
$node->set('field_films', $id_array);
$node->save();
}
if ($data->pilots!=[]){
$array_pilots = $data->pilots; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_pilots); // загрузка новых нод из базы и получение их айдишников
$node->set('field_pilots', $id_array);
$node->save();
}
}
if ($type == 'species') {
$node = $this->loadNode($type, $id);
if ($data->films!=[]){
$array_films = $data->films; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_films); // загрузка новых нод из базы и получение их айдишников
$node->set('field_films', $id_array);
$node->save();
}
if ($data->people!=[]){
$array_people = $data->people; // получаю список ссылок связанных сущностей
$id_array = $this->getIdArray($array_people); // загрузка новых нод из базы и получение их айдишников
$node->set('field_people', $id_array);
$node->save();
}
}
}
}
*/
/*public function speciesField($array_species){
$id_array = $this->getIdArray($array_species);
return $id_array;
}
public function starshipsField($array_starships){
foreach ($array_starships as $starship){ // Прохожусь по каждому адресу связанной сущности
if ($starship!=NULL) { // проверяю, явзяется ли NULL ( такое значение бывает )
$type = $this->nodeType($starship); // получаю тип ноды по адресу
$id = $this->nodeId($starship); // получаю id ноды по адресу
$nodeStarship = $this->loadNode($type, $id); //выгружаю ноду из базы данных
$id_array[] = $nodeStarship->id(); // получаю массив id необходимых связанных сущностей
}
}
return $id_array;
}
public function vehiclesField($array_vehicles){
foreach ($array_vehicles as $vehicle){ // Прохожусь по каждому адресу связанной сущности
if ($vehicle!=NULL) { // проверяю, явзяется ли NULL ( такое значение бывает )
$type = $this->nodeType($vehicle); // получаю тип ноды по адресу
$id = $this->nodeId($vehicle); // получаю id ноды по адресу
$nodeVehicle = $this->loadNode($type, $id); //выгружаю ноду из базы данных
$id_array[] = $nodeVehicle->id(); // получаю массив id необходимых связанных сущностей
}
}
return $id_array;
}
public function charactersField($array_characters){
foreach ($array_characters as $character){ // Прохожусь по каждому адресу связанной сущности
if ($character!=NULL) { // проверяю, явзяется ли NULL ( такое значение бывает )
$type = $this->nodeType($character); // получаю тип ноды по адресу
$id = $this->nodeId($character); // получаю id ноды по адресу
$nodeCharacter = $this->loadNode($type, $id); //выгружаю ноду из базы данных
$id_array[] = $nodeCharacter->id(); // получаю массив id необходимых связанных сущностей
}
}
return $id_array;
}
public function planetsField($array_planets){
foreach ($array_planets as $planet){ // Прохожусь по каждому адресу связанной сущности
if ($planet!=NULL) { // проверяю, явзяется ли NULL ( такое значение бывает )
$type = $this->nodeType($planet); // получаю тип ноды по адресу
$id = $this->nodeId($planet); // получаю id ноды по адресу
$nodePlanet = $this->loadNode($type, $id); //выгружаю ноду из базы данных
$id_array[] = $nodePlanet->id(); // получаю массив id необходимых связанных сущностей
}
}
return $id_array;
}
*/
{#
/**
* @file
* Theme override for page title block.
*
* @ingroup templates
*/
#}
{% extends "block--bare.html.twig" %}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment