Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
R
r-test
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
r-test
Commits
31fbe39b
Commit
31fbe39b
authored
May 17, 2022
by
Telenkov Ruslan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
drush
parent
1c730d50
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
284 additions
and
64 deletions
+284
-64
composer.json
app/composer.json
+3
-0
composer.lock
app/composer.lock
+185
-1
drush.info.yml
app/docroot/modules/custom/drush/drush.info.yml
+6
-0
drush.services.yml
app/docroot/modules/custom/drush/drush.services.yml
+5
-0
BatchCommands.php
...croot/modules/custom/drush/src/Commands/BatchCommands.php
+81
-0
myservice.module
app/docroot/modules/custom/myservice/myservice.module
+4
-63
No files found.
app/composer.json
View file @
31fbe39b
...
...
@@ -23,6 +23,7 @@
"drupal/devel"
:
"^4.0"
,
"drupal/devel_kint_extras"
:
"^1.0"
,
"drupal/devel_php"
:
"^1.0"
,
"drupal/facets"
:
"^2.0"
,
"drupal/field_group"
:
"^3.2"
,
"drupal/fontawesome_menu_icons"
:
"^1.9"
,
"drupal/jquery_ui"
:
"^1.4"
,
...
...
@@ -39,12 +40,14 @@
"drupal/recaptcha"
:
"^3.0"
,
"drupal/redirect"
:
"^1.7"
,
"drupal/search_api"
:
"^1.23"
,
"drupal/search_api_autocomplete"
:
"^1.6"
,
"drupal/shariff"
:
"^1.7"
,
"drupal/simple_sitemap"
:
"^4.1"
,
"drupal/twig_field_value"
:
"^2.0"
,
"drupal/twig_tweak"
:
"^3.1"
,
"drupal/ultimate_cron"
:
"^2.8"
,
"drupal/verf"
:
"^1.0"
,
"drupal/views_infinite_scroll"
:
"^2.0"
,
"drupal/webform"
:
"^6.1"
,
"drush/drush"
:
"^10.3"
,
"hirak/prestissimo"
:
"^0.3.7"
,
...
...
app/composer.lock
View file @
31fbe39b
...
...
@@ -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": "
4568c138cf524de214568fd3ee192ad
c",
"content-hash": "
6639a784cdd882aa400a17afddb8dd5
c",
"packages": [
{
"name": "asm89/stack-cors",
...
...
@@ -2841,6 +2841,80 @@
"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",
"version": "3.2.0",
...
...
@@ -4149,6 +4223,60 @@
"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",
"version": "1.7.0",
...
...
@@ -4547,6 +4675,62 @@
"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",
"version": "6.1.3",
...
...
app/docroot/modules/custom/drush/drush.info.yml
0 → 100644
View file @
31fbe39b
name
:
Custom drush
description
:
Create a custom drush command.
package
:
Custom
type
:
module
core_version_requirement
:
^8.8 || ^9
app/docroot/modules/custom/drush/drush.services.yml
0 → 100644
View file @
31fbe39b
services
:
drush.commands
:
class
:
\Drupal\drush\Commands\BatchCommands
tags
:
-
{
name
:
drush.command
}
app/docroot/modules/custom/drush/src/Commands/BatchCommands.php
0 → 100644
View file @
31fbe39b
<?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
);
}
}
}
}
app/docroot/modules/custom/myservice/myservice.module
View file @
31fbe39b
...
...
@@ -10,55 +10,6 @@ use Drupal\Core\Entity\EntityInterface;
* 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
()
{
...
...
@@ -69,9 +20,6 @@ function myservice_cron()
foreach
(
$request
as
$row_item
){
$queue
->
createItem
(
$row_item
);
}
//getResult($queue,'https://swapi.dev/api/');
//getNodePeople($queue);
/**
* Implements hook_form_alter().
*/
...
...
@@ -88,16 +36,9 @@ function myservice_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form
$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;
}
*/
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