Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
new_project
Project
Project
Details
Activity
Releases
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
3e60c79b
Commit
3e60c79b
authored
Jun 10, 2022
by
Telenkov Ruslan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
this is context definition
parent
65cd2eef
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
90 additions
and
0 deletions
+90
-0
contentDef.info.yml
app/docroot/modules/custom/contDef/contentDef.info.yml
+4
-0
ContBlock.php
...oot/modules/custom/contDef/src/Plugin/Block/ContBlock.php
+32
-0
DrupalLocalTask.php
...dules/custom/localtask/src/Controller/DrupalLocalTask.php
+2
-0
ConBlock.php
...odules/custom/testblocklast/src/Plugin/Block/ConBlock.php
+48
-0
testblocklast.info.yml
...croot/modules/custom/testblocklast/testblocklast.info.yml
+4
-0
No files found.
app/docroot/modules/custom/contDef/contentDef.info.yml
0 → 100644
View file @
3e60c79b
name
:
Cont def. task
package
:
Custom
type
:
module
core_version_requirement
:
^8.8 || ^9
app/docroot/modules/custom/contDef/src/Plugin/Block/ContBlock.php
0 → 100644
View file @
3e60c79b
<?php
namespace
Drupal\contDef\Plugin\Block
;
use
Drupal\Core\Access\AccessResult
;
use
Drupal\Core\Block\BlockBase
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Plugin\Context\EntityContext
;
use
Drupal\Core\Session\AccountInterface
;
use
Drupal\media\Entity\Media
;
use
Drupal\file\Entity\File
;
/**
* Provides a 'ContDef' Block.
*
* @Block(
* id = "cont_definition_block",
* admin_label = @Translation("ContDef block"),
* category = @Translation("ContDefBlock"),
* )
*/
class
ContBlock
extends
BlockBase
{
/**
* {@inheritdoc}
*/
public
function
build
(){
$context
=
EntityContext
::
fromEntityType
(
\Drupal
::
entityTypeManager
()
->
getDefinition
(
'user'
));
}
}
app/docroot/modules/custom/localtask/src/Controller/DrupalLocalTask.php
View file @
3e60c79b
...
...
@@ -30,6 +30,8 @@ public function swapi($node){
$id
=
$node
->
get
(
'field_swapi_id'
)
->
value
;
$conc
=
'https://swapi.dev/api/'
.
$type
.
'/'
.
$id
.
'/'
;
$request
=
$this
->
getResult
(
$conc
);
// $request = json_encode($request);
return
[
'#markup'
=>
$request
,
];
...
...
app/docroot/modules/custom/testblocklast/src/Plugin/Block/ConBlock.php
0 → 100644
View file @
3e60c79b
<?php
namespace
Drupal\testblocklast\Plugin\Block
;
use
Drupal\Core\Access\AccessResult
;
use
Drupal\Core\Block\BlockBase
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Session\AccountInterface
;
use
Psr\Container\ContainerInterface
;
/**
* Provides a 'Text' Block.
*
* @Block(
* id = "testblocklast_text_block_block",
* admin_label = @Translation("Text block last"),
* category = @Translation("TestLastBlock"),
* context_definitions = {
* "node" = @ContextDefinition("entity:node", required = FALSE, label = @Translation("Node")),
* "term" = @ContextDefinition("entity:taxonomy_term", required = FALSE, label = @Translation("Term"))
* }
* )
*/
class
ConBlock
extends
BlockBase
{
/**
* {@inheritdoc}
*/
public
function
build
()
{
$output
=
''
;
$node
=
$this
->
getContextValue
(
'node'
);
$term
=
$this
->
getContextValue
(
'term'
);
if
(
$node
!=
null
){
$view_builder
=
\Drupal
::
entityTypeManager
()
->
getViewBuilder
(
'node'
);
$rss_output
=
$view_builder
->
view
(
$node
,
'teaser'
);
$output
=
\Drupal
::
service
(
'renderer'
)
->
render
(
$rss_output
);
}
else
{
$view_builder
=
\Drupal
::
entityTypeManager
()
->
getViewBuilder
(
'taxonomy_term'
);
$rss_output
=
$view_builder
->
view
(
$term
,
'teaser'
);
$output
=
\Drupal
::
service
(
'renderer'
)
->
render
(
$rss_output
);
}
return
[
'#markup'
=>
$output
,
];
}
}
app/docroot/modules/custom/testblocklast/testblocklast.info.yml
0 → 100644
View file @
3e60c79b
name
:
TestBlockLast
package
:
Custom
type
:
module
core_version_requirement
:
^8.8 || ^9
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