Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UHF-X: import old documents #529

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ parameters:
- install
- theme
paths:
- ./public/modules/custom/paatokset_submenus
- ./public/modules/custom/paatokset_ahjo_openid
- ./public/modules/custom/paatokset_ahjo_api/src/Plugin/QueueWorker
- ./public/modules/custom/paatokset_ahjo_api/src/Plugin/Deriver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class PolicymakerService {
/**
* Cut off date for old meetings.
*/
const MEETING_START_DATE = '2018-04-01';
const MEETING_START_DATE = '2017-01-01';

/**
* Policymaker roles for trustees (not decisionmaker organizations).
Expand Down Expand Up @@ -112,7 +112,7 @@ class PolicymakerService {
* Language manager service.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* Entity type manager.
* @param Drupal\Core\Config\ConfigFactoryInterface $config
* @param \Drupal\Core\Config\ConfigFactoryInterface $config
* Config service.
* @param \Drupal\Core\Routing\RouteMatchInterface $routeMatch
* Route match service.
Expand Down Expand Up @@ -199,7 +199,7 @@ public function query(array $params = []) : array {
* @param string|null $langcode
* Translation to get. Leave null to return active translation.
*
* @return Drupal\node\NodeInterface|null
* @return \Drupal\node\NodeInterface|null
* Policymaker node or NULL.
*/
public function getPolicyMaker(?string $id = NULL, ?string $langcode = NULL): ?Node {
Expand Down Expand Up @@ -244,7 +244,7 @@ public function setPolicyMaker(string $id): void {
/**
* Set policy maker node.
*
* @param Drupal\node\NodeInterface $node
* @param \Drupal\node\NodeInterface $node
* Policy maker ID.
*/
public function setPolicyMakerNode(NodeInterface $node): void {
Expand All @@ -266,7 +266,7 @@ public function setPolicyMakerNode(NodeInterface $node): void {
* Set policymaker from current path.
*
* @return bool
* TRUE if setting pm was succesful.
* TRUE if setting pm was successful.
*/
public function setPolicyMakerByPath(): bool {
$node = $this->routeMatch->getParameter('node');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
<?php

declare(strict_types=1);

namespace Drupal\paatokset_submenus\Plugin\Block;

use Drupal\Core\Block\Attribute\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\node\NodeInterface;
use Drupal\paatokset_policymakers\Service\PolicymakerService;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Provides Agendas Submenu Block.
*
* @Block(
* id = "agendas_submenu",
* admin_label = @Translation("Agendas Submenu"),
* category = @Translation("Paatokset custom blocks")
* )
*/
#[Block(
id: 'agendas_submenu',
admin_label: new TranslatableMarkup('Agendas Submenu'),
category: new TranslatableMarkup('Paatokset custom blocks')
)]
class AgendasSubmenuBlock extends BlockBase implements ContainerFactoryPluginInterface {

/**
* {@inheritDoc}
*/
public function __construct(
final public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
private PolicymakerService $policymakerService,
private readonly PolicymakerService $policymakerService,
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->policymakerService->setPolicyMakerByPath();
Expand All @@ -47,7 +50,7 @@ public static function create(ContainerInterface $container, array $configuratio
/**
* Build the attributes.
*/
public function build() {
public function build(): array {
$list = $this->policymakerService->getAgendasListFromElasticSearch(NULL, TRUE);
$years = array_keys($list);

Expand All @@ -61,7 +64,7 @@ public function build() {
/**
* Get cache tags.
*/
public function getCacheTags() {
public function getCacheTags(): array {
$policymaker = $this->policymakerService->getPolicyMaker();
if ($policymaker instanceof NodeInterface && $policymaker->hasField('field_policymaker_id')) {
$policymaker_id = $policymaker->get('field_policymaker_id')->value;
Expand All @@ -73,7 +76,7 @@ public function getCacheTags() {
/**
* Get cache contexts.
*/
public function getCacheContexts() {
public function getCacheContexts(): array {
return ['url.path', 'url.query_args'];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
<?php

declare(strict_types=1);

namespace Drupal\paatokset_submenus\Plugin\Block;

use Drupal\Core\Block\Attribute\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\node\NodeInterface;
use Drupal\paatokset_policymakers\Service\PolicymakerService;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Provides Agendas Submenu Documents Block.
*
* @Block(
* id = "agendas_submenu_documents",
* admin_label = @Translation("Paatokset policymaker documents"),
* category = @Translation("Paatokset custom blocks")
* )
*/
#[Block(
id: 'agendas_submenu_documents',
admin_label: new TranslatableMarkup('Paatokset policymaker documents'),
category: new TranslatableMarkup('Paatokset custom blocks')
)]
class DocumentsBlock extends BlockBase implements ContainerFactoryPluginInterface {

/**
* {@inheritDoc}
*/
public function __construct(
final public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
private PolicymakerService $policymakerService,
private readonly PolicymakerService $policymakerService,
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->policymakerService->setPolicyMakerByPath();
Expand All @@ -45,9 +48,9 @@ public static function create(ContainerInterface $container, array $configuratio
}

/**
* Build the attributes.
* {@inheritDoc}
*/
public function build() {
public function build(): array {
$list = $this->policymakerService->getApiMinutesFromElasticSearch(NULL, TRUE);

return [
Expand All @@ -58,9 +61,9 @@ public function build() {
}

/**
* Get cache tags.
* {@inheritDoc}
*/
public function getCacheTags() {
public function getCacheTags(): array {
$policymaker = $this->policymakerService->getPolicyMaker();
if ($policymaker instanceof NodeInterface && $policymaker->hasField('field_policymaker_id')) {
$policymaker_id = $policymaker->get('field_policymaker_id')->value;
Expand All @@ -70,9 +73,9 @@ public function getCacheTags() {
}

/**
* Get cache contexts.
* {@inheritDoc}
*/
public function getCacheContexts() {
public function getCacheContexts(): array {
return ['url.path', 'url.query_args'];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
<?php

declare(strict_types=1);

namespace Drupal\paatokset_submenus\Plugin\Block;

use Drupal\Core\Block\Attribute\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\paatokset_policymakers\Service\PolicymakerService;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Provides Agendas Submenu Documents Block.
*
* @Block(
* id = "paatokset_minutes_of_discussion",
* admin_label = @Translation("Paatokset minutes of discussion block"),
* category = @Translation("Paatokset custom blocks")
* )
*/
#[Block(
id: 'paatokset_minutes_of_discussion',
admin_label: new TranslatableMarkup('Paatokset minutes of discussion block'),
category: new TranslatableMarkup('Paatokset custom blocks')
)]
class MinutesOfDiscussionBlock extends BlockBase implements ContainerFactoryPluginInterface {

/**
* {@inheritDoc}
*/
public function __construct(
final public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
private PolicymakerService $policymakerService,
private readonly PolicymakerService $policymakerService,
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->policymakerService->setPolicyMakerByPath();
Expand All @@ -44,9 +47,9 @@ public static function create(ContainerInterface $container, array $configuratio
}

/**
* Build the attributes.
* {@inheritDoc}
*/
public function build() {
public function build(): array {
$minutes = $this->policymakerService->getMinutesOfDiscussion(NULL, TRUE);

return [
Expand All @@ -56,19 +59,19 @@ public function build() {
}

/**
* Get cache tags.
* {@inheritDoc}
*/
public function getCacheTags() {
public function getCacheTags(): array {
return [
'media_list:minutes_of_the_discussion',
'node_list:meeting',
];
}

/**
* Get cache contexts.
* {@inheritDoc}
*/
public function getCacheContexts() {
public function getCacheContexts(): array {
return ['url.path', 'url.query_args'];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
<?php

declare(strict_types=1);

namespace Drupal\paatokset_submenus\Plugin\Block;

use Drupal\Core\Block\Attribute\Block;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Url;

/**
* Provides Agendas Submenu Block.
*
* @Block(
* id = "policymaker_side_nav_mobile",
* admin_label = @Translation("Policymaker mobile navigation"),
* category = @Translation("Paatokset custom blocks")
* )
*/
#[Block(
id: 'policymaker_side_nav_mobile',
admin_label: new TranslatableMarkup('Policymaker mobile navigation'),
category: new TranslatableMarkup('Paatokset custom blocks')
)]
class PolicymakerMobileNav extends PolicymakerSideNav {

/**
* {@inheritdoc}
*/
public function build() {
public function build(): array {
$options = $this->itemsToOptions();

return [
Expand All @@ -33,12 +36,12 @@ public function build() {
* @return array
* Array of options + current option
*/
private function itemsToOptions() {
private function itemsToOptions(): array {
if (!is_array($this->items)) {
return [];
}

$currentPath = $currentPath = Url::fromRoute('<current>')->toString();
$currentPath = Url::fromRoute('<current>')->toString();
$currentOption = NULL;
$options = [];
foreach ($this->items as $option) {
Expand Down
Loading
Loading