i have a Problem extending a BookNavigationBlock Plugin. When I extend BlockBase it works, but when trying to extend BookNavigationBlock, it fails when placing the block, without any error messages. What am I missing here? (The Code is inside modules/ifg_book_navigation/src/Plugin/Block/IfgBookNavigationBlock.php)

namespace Drupal\ifg_book_navigation\Plugin\Block;

use Drupal\book\Plugin\Block;
 * Provides a fully expanded 'Book navigation' block.
 * @Block(
 *   id = "ifg_book_navigation",
 *   admin_label = @Translation("Expanded Book navigation"),
 *   category = @Translation("Menus")
 * )
class IfgBookNavigationBlock extends BookNavigationBlock {

   * {@inheritdoc}
  public function build() {
    return array(
      '#markup' => $this->t('Hello, World!'),


UPDATE: I could trace the Problem to the Plugin Factory. In the getPluginClass method of DefaultFactory it is checked if the class exists:

if (!class_exists($class)) {
  throw new PluginException(sprintf('Plugin (%s) instance class "%s" does not exist.', $plugin_id, $class));

The value of $class is Drupal\ifg_book_navigation\Plugin\Block\IfgBookNavigationBlock which seems to be correct. However class_exists() itself seems to fail, not even returning false. This could have something to do with autoloading, as by default class_exists() tries this by default ...

UPDATE: It seems like the behaviour is the same for other existing blocks, just tested UserLoginBlock

  • it fails when trying to Place the blog I suppose you meant block? May 9, 2016 at 8:13
  • exactly – edited May 9, 2016 at 10:06
  • For what it's worth I have encountered exactly the same problem with a class that extends ContactBlock which in turn extends BlockBase. The problem occurs when placing the block in the block admin UI. I also see the failure at the call to class_exists - i.e. no return value. The parameter to class_exists looks ok. As a second test I modified a working block class that derived directly from BlockBase and instead derived it from ContactBlock. The error then occurred. It seems that deriving from a class that derives from BlockBase seems to cause the class to not autoload. Sep 23, 2016 at 19:43

1 Answer 1


The actual class has to be included in the use statement.

use Drupal\book\Plugin\Block\BookNavigationBlock;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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