0

First of all, this is not a duplicate of this question, as I can't see my block even though I click Place Block.

Below is my block class. To the best of my knowledge, it should appear in the list, but it doesn't. What am I doing wrong? There is another block class, and that can be discovered.

<?php

namespace Drupal\tcmb\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
 * Provides a 'Tcmb Currency' block.
 *
 * @Block(
 *  id = "tcmb_currency_block",
 *  admin_label = @Translation("Tcmb: currency"),
 *  category = @Translation("Tcmb")
 * )
 */

/**
 * Display TCMB currencies as a block.
 */
class TcmbCurrencyBlock extends BlockBase {
  • Can you provide the folder path and the name of the file you put this code in? Your issue may be here. Make sure you're following this – No Sssweat Apr 19 '19 at 9:10
  • DRUPAL_ROOT/modules/custom/tcmb/src/Plugin/Block/TcmbCurrencyBlock.php – Kartagis Apr 19 '19 at 9:16
  • So far looks good. Do you have a public function build() { ? Did you clear the cache? Is the tcmb module enabled? Are you sure you're looking at the correct site? If you're not developing locally, did you make sure your file changes uploaded to the server? – No Sssweat Apr 19 '19 at 9:21
  • All of them are yes, but one thing caught my eye. When I open my own file and webform's block class in vim, webform's @Block annotation is blue, whereas mine is green. Could that mean something? – Kartagis Apr 19 '19 at 9:30
  • That was because @Block and the following ( had a space in between, and I fixed that, followed by drush cr and still no. – Kartagis Apr 19 '19 at 9:33
2

The problem was me creating a document block above the class, creating an interference between the class and annotation. Another lesson learned the hard way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.