Skip to main content
Rollback to Revision 1
Source Link
avpaderno
  • 98.1k
  • 15
  • 165
  • 284

The code shown in the question is using the following line.

namespace Drupal\Core\Block\BlockBase; 

That is wrong as that isn't a namespace a third-party module should use. It's the full, complete of namespace, name ofFix the BlockBase class implemented by Drupal core.namespaces:

Instead of that, use the following two lines.delete: namespace Drupal\Core\Block\BlockBase;

namespace Drupal\iai_tour\Plugin\Block; use Drupal\Core\Block\BlockBase; 

If iai_tour isn't the module machine name, replace it with the correct module machine name. That essentially is the name of the .module name without extension.add: namespace Drupal\MY_COOL_MODULE\Plugin\Block; use Drupal\Core\Block\BlockBase;

The code shown in the question is using the following line.

namespace Drupal\Core\Block\BlockBase; 

That is wrong as that isn't a namespace a third-party module should use. It's the full, complete of namespace, name of the BlockBase class implemented by Drupal core.

Instead of that, use the following two lines.

namespace Drupal\iai_tour\Plugin\Block; use Drupal\Core\Block\BlockBase; 

If iai_tour isn't the module machine name, replace it with the correct module machine name. That essentially is the name of the .module name without extension.

Fix the namespaces:

delete: namespace Drupal\Core\Block\BlockBase;

add: namespace Drupal\MY_COOL_MODULE\Plugin\Block; use Drupal\Core\Block\BlockBase;

made the answer more explicit
Source Link
avpaderno
  • 98.1k
  • 15
  • 165
  • 284

FixThe code shown in the namespaces:question is using the following line.

namespace Drupal\Core\Block\BlockBase; 

delete: namespace Drupal\Core\Block\BlockBase;That is wrong as that isn't a namespace a third-party module should use. It's the full, complete of namespace, name of the BlockBase class implemented by Drupal core.

add: namespace Drupal\MY_COOL_MODULE\Plugin\Block; use Drupal\Core\Block\BlockBase;Instead of that, use the following two lines.

namespace Drupal\iai_tour\Plugin\Block; use Drupal\Core\Block\BlockBase; 

If iai_tour isn't the module machine name, replace it with the correct module machine name. That essentially is the name of the .module name without extension.

Fix the namespaces:

delete: namespace Drupal\Core\Block\BlockBase;

add: namespace Drupal\MY_COOL_MODULE\Plugin\Block; use Drupal\Core\Block\BlockBase;

The code shown in the question is using the following line.

namespace Drupal\Core\Block\BlockBase; 

That is wrong as that isn't a namespace a third-party module should use. It's the full, complete of namespace, name of the BlockBase class implemented by Drupal core.

Instead of that, use the following two lines.

namespace Drupal\iai_tour\Plugin\Block; use Drupal\Core\Block\BlockBase; 

If iai_tour isn't the module machine name, replace it with the correct module machine name. That essentially is the name of the .module name without extension.

Source Link

Fix the namespaces:

delete: namespace Drupal\Core\Block\BlockBase;

add: namespace Drupal\MY_COOL_MODULE\Plugin\Block; use Drupal\Core\Block\BlockBase;