Skip to content

Commit

Permalink
convert php annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Aug 29, 2024
1 parent d448b7a commit 1b099a6
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 44 deletions.
20 changes: 11 additions & 9 deletions src/Plugin/Block/BookForwardBackBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@

namespace Drupal\stanford_fields\Plugin\Block;

use Drupal\Core\Block\Attribute\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Provides a 'Book navigation' block.
*
* @Block(
* id = "book_forward_back",
* admin_label = @Translation("Book Forward & Back"),
* category = @Translation("Book"),
* context_definitions = {
* "node" = @ContextDefinition("entity:node", label = @Translation("Node"), required = FALSE)
* }
* )
*/
#[Block(
id: "book_forward_back",
admin_label: new TranslatableMarkup("Book Forward & Back"),
category: new TranslatableMarkup("book"),
context_definitions: [
'node' => new ContextDefinition(data_type: 'entity:node', label: new TranslatableMarkup("Node"), required: FALSE),
]
)]
class BookForwardBackBlock extends BlockBase implements ContainerFactoryPluginInterface {

/**
Expand Down
15 changes: 7 additions & 8 deletions src/Plugin/Field/FieldFormatter/EntityTitleHeading.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@

namespace Drupal\stanford_fields\Plugin\Field\FieldFormatter;

use Drupal\Core\Field\Attribute\FieldFormatter;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link;
use Drupal\Core\Path\PathMatcherInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Provide a string field to be used as a heading.
*
* @FieldFormatter(
* id = "entity_title_heading",
* label = @Translation("Heading"),
* field_types = {
* "string"
* }
* )
*/
#[FieldFormatter(
id: 'entity_title_heading',
label: new TranslatableMarkup('Heading'),
field_types: ['string'],
)]
class EntityTitleHeading extends FormatterBase implements ContainerFactoryPluginInterface {

/**
Expand Down
15 changes: 7 additions & 8 deletions src/Plugin/Field/FieldWidget/DateYearOnlyWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@

namespace Drupal\stanford_fields\Plugin\Field\FieldWidget;

use Drupal\Core\Field\Attribute\FieldWidget;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\datetime\Plugin\Field\FieldWidget\DateTimeDatelistWidget;

/**
* Plugin to provide a date widget that only collects the year.
*
* @FieldWidget(
* id = "datetime_year_only",
* label = @Translation("Year Only"),
* field_types = {
* "datetime"
* }
* )
*/
#[FieldWidget(
id: 'datetime_year_only',
label: new TranslatableMarkup('Year Only'),
field_types: ['datetime'],
)]
class DateYearOnlyWidget extends DateTimeDatelistWidget {

/**
Expand Down
15 changes: 7 additions & 8 deletions src/Plugin/Field/FieldWidget/LocalistUrlWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Field\Attribute\FieldWidget;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element\Url as UrlElement;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Url;
use Drupal\link\Plugin\Field\FieldWidget\LinkWidget;
use GuzzleHttp\ClientInterface;
Expand All @@ -17,15 +19,12 @@

/**
* Plugin implementation of the 'localist_url' widget.
*
* @FieldWidget(
* id = "localist_url",
* label = @Translation("Localist"),
* field_types = {
* "link"
* }
* )
*/
#[FieldWidget(
id: 'localist_url',
label: new TranslatableMarkup('Localist URL'),
field_types: ['link'],
)]
class LocalistUrlWidget extends LinkWidget {

/**
Expand Down
6 changes: 6 additions & 0 deletions src/Plugin/Field/FieldWidget/TaxonomyLabelHierarchyWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen

/**
* Ajax callback to add another.
*
* @codeCoverageIgnore
*/
public static function addMoreCallback(array &$form, FormStateInterface $form_state) {
$trigger = $form_state->getTriggeringElement();
Expand All @@ -119,6 +121,8 @@ public static function addMoreCallback(array &$form, FormStateInterface $form_st

/**
* Form callback to add another.
*
* @codeCoverageIgnore
*/
public static function addOne(array &$form, FormStateInterface $form_state) {
$trigger = $form_state->getTriggeringElement();
Expand All @@ -129,6 +133,8 @@ public static function addOne(array &$form, FormStateInterface $form_state) {

/**
* {@inheritdoc}
*
* @codeCoverageIgnore
*/
public static function validateElement(array $element, FormStateInterface $form_state) {
$value = [];
Expand Down
23 changes: 12 additions & 11 deletions src/Plugin/views/display/ViewFieldBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@

namespace Drupal\stanford_fields\Plugin\views\display;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\views\Attribute\ViewsDisplay;
use Drupal\views\Plugin\views\display\Block;

/**
* The plugin that handles a block.
*
* @ingroup views_display_plugins
*
* @ViewsDisplay(
* id = "viewfield_block",
* title = @Translation("View Field Block"),
* help = @Translation("Identical to a block, but allows for granular viewfield settings."),
* theme = "views_view",
* register_theme = FALSE,
* uses_hook_block = TRUE,
* contextual_links_locations = {"block"},
* admin = @Translation("Block")
* )
*
* @see \Drupal\views\Plugin\Block\ViewsBlock
* @see \Drupal\views\Plugin\Derivative\ViewsBlock
*/
#[ViewsDisplay(
id: "viewfield_block",
title: new TranslatableMarkup("View Field Block"),
admin: new TranslatableMarkup("Block"),
help: new TranslatableMarkup("Identical to a block, but allows for granular viewfield settings."),
theme: "views_view",
contextual_links_locations: ["block"],
register_theme: FALSE,
uses_hook_block: TRUE,
)]
class ViewFieldBlock extends Block {

/**
Expand Down

0 comments on commit 1b099a6

Please sign in to comment.