Loading js_component.api.php +6 −4 Original line number Diff line number Diff line <?php use Drupal\Core\Form\FormStateInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; /** * @file * Define the JS component API documentation. Loading @@ -20,12 +22,12 @@ * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state instance. */ function hook_js_component_form_alter(array &$form, array $configuration, Drupal\Core\Form\FormStateInterface $form_state) { function hook_js_component_form_alter(array &$form, array $configuration, FormStateInterface $form_state) { $form['resource'] = [ '#type' => 'select', '#title' => new Drupal\Core\StringTranslation\TranslatableMarkup('Resource'), '#title' => new TranslatableMarkup('Resource'), '#options' => [], '#empty_option' => new Drupal\Core\StringTranslation\TranslatableMarkup('- None -'), '#empty_option' => new TranslatableMarkup('- None -'), '#default_value' => $configuration['resource'] ?? NULL, ]; } Loading @@ -40,7 +42,7 @@ function hook_js_component_form_alter(array &$form, array $configuration, Drupal */ function hook_js_component_form_submit( array &$values, Drupal\Core\Form\FormStateInterface $form_state FormStateInterface $form_state ) { if ($resource = $form_state->getValue('resource')) { $values['resource'] = $resource; Loading js_component.info.yml +1 −2 Original line number Diff line number Diff line type: module name: JS Component description: Define JS components as custom blocks from a theme or module. core: 8.x core_version_requirement: ^8 || ^9 core_version_requirement: ^9.3 || ^10 package: Other src/Event/BuildComponentDataEvent.php +1 −1 Original line number Diff line number Diff line Loading @@ -2,8 +2,8 @@ namespace Drupal\js_component\Event; use Symfony\Contracts\EventDispatcher\Event; use Drupal\js_component\Plugin\JSComponent; use Symfony\Component\EventDispatcher\Event; /** * Build component data event object. Loading src/Plugin/Block/JSComponentBlockType.php +2 −2 Original line number Diff line number Diff line Loading @@ -611,8 +611,8 @@ class JSComponentBlockType extends BlockBase implements ContainerFactoryPluginIn ); return ($this->eventDispatcher->dispatch( Events::BUILD_COMPONENT_DATA, $component_data_event $component_data_event, Events::BUILD_COMPONENT_DATA ))->build(); } Loading src/Plugin/JSComponent.php +1 −1 Original line number Diff line number Diff line Loading @@ -316,7 +316,7 @@ class JSComponent extends PluginBase implements JSComponentInterface, ContainerF * @throws \Exception */ public function getProviderPath() { return drupal_get_path($this->getProviderType(), $this->provider()); return \Drupal::service('extension.path.resolver')->getPath($this->getProviderType(), $this->provider()); } /** Loading Loading
js_component.api.php +6 −4 Original line number Diff line number Diff line <?php use Drupal\Core\Form\FormStateInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; /** * @file * Define the JS component API documentation. Loading @@ -20,12 +22,12 @@ * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state instance. */ function hook_js_component_form_alter(array &$form, array $configuration, Drupal\Core\Form\FormStateInterface $form_state) { function hook_js_component_form_alter(array &$form, array $configuration, FormStateInterface $form_state) { $form['resource'] = [ '#type' => 'select', '#title' => new Drupal\Core\StringTranslation\TranslatableMarkup('Resource'), '#title' => new TranslatableMarkup('Resource'), '#options' => [], '#empty_option' => new Drupal\Core\StringTranslation\TranslatableMarkup('- None -'), '#empty_option' => new TranslatableMarkup('- None -'), '#default_value' => $configuration['resource'] ?? NULL, ]; } Loading @@ -40,7 +42,7 @@ function hook_js_component_form_alter(array &$form, array $configuration, Drupal */ function hook_js_component_form_submit( array &$values, Drupal\Core\Form\FormStateInterface $form_state FormStateInterface $form_state ) { if ($resource = $form_state->getValue('resource')) { $values['resource'] = $resource; Loading
js_component.info.yml +1 −2 Original line number Diff line number Diff line type: module name: JS Component description: Define JS components as custom blocks from a theme or module. core: 8.x core_version_requirement: ^8 || ^9 core_version_requirement: ^9.3 || ^10 package: Other
src/Event/BuildComponentDataEvent.php +1 −1 Original line number Diff line number Diff line Loading @@ -2,8 +2,8 @@ namespace Drupal\js_component\Event; use Symfony\Contracts\EventDispatcher\Event; use Drupal\js_component\Plugin\JSComponent; use Symfony\Component\EventDispatcher\Event; /** * Build component data event object. Loading
src/Plugin/Block/JSComponentBlockType.php +2 −2 Original line number Diff line number Diff line Loading @@ -611,8 +611,8 @@ class JSComponentBlockType extends BlockBase implements ContainerFactoryPluginIn ); return ($this->eventDispatcher->dispatch( Events::BUILD_COMPONENT_DATA, $component_data_event $component_data_event, Events::BUILD_COMPONENT_DATA ))->build(); } Loading
src/Plugin/JSComponent.php +1 −1 Original line number Diff line number Diff line Loading @@ -316,7 +316,7 @@ class JSComponent extends PluginBase implements JSComponentInterface, ContainerF * @throws \Exception */ public function getProviderPath() { return drupal_get_path($this->getProviderType(), $this->provider()); return \Drupal::service('extension.path.resolver')->getPath($this->getProviderType(), $this->provider()); } /** Loading