Commit 31fbe39b authored by Telenkov Ruslan's avatar Telenkov Ruslan

drush

parent 1c730d50
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
"drupal/devel": "^4.0", "drupal/devel": "^4.0",
"drupal/devel_kint_extras": "^1.0", "drupal/devel_kint_extras": "^1.0",
"drupal/devel_php": "^1.0", "drupal/devel_php": "^1.0",
"drupal/facets": "^2.0",
"drupal/field_group": "^3.2", "drupal/field_group": "^3.2",
"drupal/fontawesome_menu_icons": "^1.9", "drupal/fontawesome_menu_icons": "^1.9",
"drupal/jquery_ui": "^1.4", "drupal/jquery_ui": "^1.4",
...@@ -39,12 +40,14 @@ ...@@ -39,12 +40,14 @@
"drupal/recaptcha": "^3.0", "drupal/recaptcha": "^3.0",
"drupal/redirect": "^1.7", "drupal/redirect": "^1.7",
"drupal/search_api": "^1.23", "drupal/search_api": "^1.23",
"drupal/search_api_autocomplete": "^1.6",
"drupal/shariff": "^1.7", "drupal/shariff": "^1.7",
"drupal/simple_sitemap": "^4.1", "drupal/simple_sitemap": "^4.1",
"drupal/twig_field_value": "^2.0", "drupal/twig_field_value": "^2.0",
"drupal/twig_tweak": "^3.1", "drupal/twig_tweak": "^3.1",
"drupal/ultimate_cron": "^2.8", "drupal/ultimate_cron": "^2.8",
"drupal/verf": "^1.0", "drupal/verf": "^1.0",
"drupal/views_infinite_scroll": "^2.0",
"drupal/webform": "^6.1", "drupal/webform": "^6.1",
"drush/drush": "^10.3", "drush/drush": "^10.3",
"hirak/prestissimo": "^0.3.7", "hirak/prestissimo": "^0.3.7",
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "4568c138cf524de214568fd3ee192adc", "content-hash": "6639a784cdd882aa400a17afddb8dd5c",
"packages": [ "packages": [
{ {
"name": "asm89/stack-cors", "name": "asm89/stack-cors",
...@@ -2841,6 +2841,80 @@ ...@@ -2841,6 +2841,80 @@
"source": "https://git.drupalcode.org/project/entity_reference_revisions" "source": "https://git.drupalcode.org/project/entity_reference_revisions"
} }
}, },
{
"name": "drupal/facets",
"version": "2.0.2",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/facets.git",
"reference": "2.0.2"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/facets-2.0.2.zip",
"reference": "2.0.2",
"shasum": "17afc46d3f4e4300e8e69f23b3b01a4935b57104"
},
"require": {
"drupal/core": "^9.2 || ^10.0"
},
"conflict": {
"drupal/search_api": "<1.14"
},
"require-dev": {
"drupal/jquery_ui_slider": "~1.1",
"drupal/jquery_ui_touch_punch": "~1.0",
"drupal/search_api": "~1.21"
},
"suggest": {
"drupal/jquery_ui_slider": "Required for the 'Facets Range Widget' module to work",
"drupal/jquery_ui_touch_punch": "Required for the 'Facets Range Widget' module to work"
},
"type": "drupal-module",
"extra": {
"drupal": {
"version": "2.0.2",
"datestamp": "1649070269",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0+"
],
"authors": [
{
"name": "See all contributors",
"homepage": "https://www.drupal.org/node/2348769/committers"
},
{
"name": "StryKaizer",
"homepage": "https://www.drupal.org/user/462700"
},
{
"name": "borisson_",
"homepage": "https://www.drupal.org/user/2393360"
},
{
"name": "drunken monkey",
"homepage": "https://www.drupal.org/user/205582"
},
{
"name": "mkalkbrenner",
"homepage": "https://www.drupal.org/user/124705"
}
],
"description": "The Facet module allows site builders to easily create and manage faceted search interfaces.",
"homepage": "https://www.drupal.org/project/facets",
"support": {
"source": "git://git.drupal.org/project/facets.git",
"issues": "https://www.drupal.org/project/issues/facets",
"irc": "irc://irc.freenode.org/drupal-search-api"
}
},
{ {
"name": "drupal/field_group", "name": "drupal/field_group",
"version": "3.2.0", "version": "3.2.0",
...@@ -4149,6 +4223,60 @@ ...@@ -4149,6 +4223,60 @@
"irc": "irc://irc.freenode.org/drupal-search-api" "irc": "irc://irc.freenode.org/drupal-search-api"
} }
}, },
{
"name": "drupal/search_api_autocomplete",
"version": "1.6.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/search_api_autocomplete.git",
"reference": "8.x-1.6"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/search_api_autocomplete-8.x-1.6.zip",
"reference": "8.x-1.6",
"shasum": "4065946556cac1ccd9b19754a165fb32fc734b92"
},
"require": {
"drupal/core": "^8 || ^9",
"drupal/search_api": "1.x"
},
"require-dev": {
"drupal/search_api_page": "1.x-dev"
},
"type": "drupal-module",
"extra": {
"drupal": {
"version": "8.x-1.6",
"datestamp": "1641998786",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "Thomas Seidl",
"homepage": "https://www.drupal.org/u/drunken-monkey"
},
{
"name": "See other contributors",
"homepage": "https://www.drupal.org/node/1142202/committers"
}
],
"description": "Adds autocomplete functionality to searches.",
"homepage": "https://www.drupal.org/project/search_api_autocomplete",
"support": {
"source": "http://git.drupal.org/project/search_api_autocomplete.git",
"issues": "https://www.drupal.org/project/issues/search_api_autocomplete",
"irc": "irc://irc.freenode.org/drupal-search-api"
}
},
{ {
"name": "drupal/shariff", "name": "drupal/shariff",
"version": "1.7.0", "version": "1.7.0",
...@@ -4547,6 +4675,62 @@ ...@@ -4547,6 +4675,62 @@
"source": "https://git.drupalcode.org/project/verf" "source": "https://git.drupalcode.org/project/verf"
} }
}, },
{
"name": "drupal/views_infinite_scroll",
"version": "2.0.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/views_infinite_scroll.git",
"reference": "2.0.0"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/views_infinite_scroll-2.0.0.zip",
"reference": "2.0.0",
"shasum": "9e1bc62131c8577609f2b2c520d749ac0a9b4142"
},
"require": {
"drupal/core": "^9.2"
},
"type": "drupal-module",
"extra": {
"drupal": {
"version": "2.0.0",
"datestamp": "1641878440",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "Bobík",
"homepage": "https://www.drupal.org/user/123612"
},
{
"name": "Neslee Canil Pinto",
"homepage": "https://www.drupal.org/user/3580850"
},
{
"name": "Remon",
"homepage": "https://www.drupal.org/user/143827"
},
{
"name": "Sam152",
"homepage": "https://www.drupal.org/user/1485048"
}
],
"description": "A pager which allows an infinite scroll effect for views.",
"homepage": "https://www.drupal.org/project/views_infinite_scroll",
"support": {
"source": "https://git.drupalcode.org/project/views_infinite_scroll"
}
},
{ {
"name": "drupal/webform", "name": "drupal/webform",
"version": "6.1.3", "version": "6.1.3",
......
name: Custom drush
description: Create a custom drush command.
package: Custom
type: module
core_version_requirement: ^8.8 || ^9
services:
drush.commands:
class: \Drupal\drush\Commands\BatchCommands
tags:
- { name: drush.command }
<?php
namespace Drupal\drush\Commands;
use Drush\Commands\DrushCommands;
/**
* A Drush commandfile.
*
* In addition to this file, you need a drush.services.yml
* in root of your module, and a composer.json file that provides the name
* of the services file to use
*/
class BatchCommands extends DrushCommands
{
/**
* A custom Drush command to displays the given text.
*
* @command drush-command-example:print-me
* @param $text Argument with text to be printed
* @option uppercase Uppercase the text
* @aliases ccepm,cce-print-me
*/
public function printMe($text = 'Hello world!', $options = ['uppercase' => FALSE])
{
if ($options['uppercase']) {
$text = strtoupper($text);
}
$this->output()->writeln($text);
}
/**
* A custom Drush command to displays the given text.
*
* @command drush-command-example:go-api
* @param $date Argument with text to be printed
* @aliases go-api
*/
public function goApi($date = null)
{
if ($date === null){
$this->output()->writeln('Вы не ввели дату');
}
else {
$timestamp = strtotime($date);
$service = \Drupal::service('myservice.my');
$request = $service->getResult('https://swapi.dev/api/');
foreach ($request as $api_url) {
$url = $api_url;
do {
$request_items = $service->getResult($url);
$result_items = $request_items->results; // выкинул служебную информацию
foreach ($result_items as $row_item){
$timestamp_swapi = strtotime($row_item->edited);
if ($timestamp < $timestamp_swapi){
$type =$service->nodeType($row_item->url); // получаю ID ноды для дальнейшей проверки из БД
$id = $service->nodeId($row_item->url); // получаю тип ноды для дальнейшей проверки из БД
$nids = $service->existNode($type, $id); // вызываю функцию проверки ноды в БД, если есть, то вернется ID
$this->output()->writeln('Обработана сущность: ' . $type . $id);
if (empty($nids)){
$service->createNode($row_item); // вызываю метод создания ноды из сервиса
$service->updateNode($row_item);
}
else {
$service->updateNode($row_item);
}
}
}
$url = $request_items->next;
} while ($url);
}
}
}
}
...@@ -10,55 +10,6 @@ use Drupal\Core\Entity\EntityInterface; ...@@ -10,55 +10,6 @@ use Drupal\Core\Entity\EntityInterface;
* Implements hook_cron(). * Implements hook_cron().
*/ */
/*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);
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(
'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() function myservice_cron()
{ {
...@@ -69,9 +20,6 @@ function myservice_cron() ...@@ -69,9 +20,6 @@ function myservice_cron()
foreach ($request as $row_item){ foreach ($request as $row_item){
$queue->createItem($row_item); $queue->createItem($row_item);
} }
//getResult($queue,'https://swapi.dev/api/');
//getNodePeople($queue);
/** /**
* Implements hook_form_alter(). * Implements hook_form_alter().
*/ */
...@@ -88,16 +36,9 @@ function myservice_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form ...@@ -88,16 +36,9 @@ function myservice_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form
$form['field_name']['widget'][0]['value']['#default_value'] = $name; $form['field_name']['widget'][0]['value']['#default_value'] = $name;
} }
} if ($form_id == 'views_exposed_form' and $form['#id'] == 'views-exposed-form-people-page-1') {
$form["actions"]["reset"]["#access"] = true;
}
//$name = $user['values']['name'];
/* $users = \Drupal::entityTypeManager()
->getStorage('user')
->loadByProperties([
'name' => $name,
]);
foreach ($users as $concrete_user){
$user = $concrete_user;
} }
*/
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