Skip to main content
added 128 characters in body
Source Link
beth
  • 9.1k
  • 3
  • 37
  • 86

You don't use file[] = ... anymore. Instead, classes are autoloaded. For example, I have a module with the following file structure:

  • views_hybrid/
  • views_hybrid.info.yml
  • views_hybrid.module
  • src/
    • Plugin/
      • Field/
        • FieldFormatter/
          • HybridFormatter.php

HybridFormatter.php defines a class called HybridFormatter.

In my .module file, if I start typing in my IDE (NetBeans in this case) HybridFormatter it autocompletes to \Drupal\views_hybrid\Plugin\Field\FieldFormatter\HybridFormatter:: because it is autoloaded. Since I don't want that whole path littering my module, at the top I have placed the line,

use Drupal\views_hybrid\Plugin\Field\FieldFormatter\HybridFormatter;

along with use directives for other classes I am including for use with my module.

The namespace is defined in HybridFormatter.php like so:

namespace Drupal\views_hybrid\Plugin\Field\FieldFormatter;

class HybridFormatter extends FormatterBase { ... }

You don't use file[] = ... anymore. Instead, classes are autoloaded. For example, I have a module with the following file structure:

  • views_hybrid/
  • views_hybrid.info.yml
  • views_hybrid.module
  • src/
    • Plugin/
      • Field/
        • FieldFormatter/
          • HybridFormatter.php

HybridFormatter.php defines a class called HybridFormatter.

In my .module file, if I start typing in my IDE (NetBeans in this case) HybridFormatter it autocompletes to \Drupal\views_hybrid\Plugin\Field\FieldFormatter\HybridFormatter:: because it is autoloaded. Since I don't want that whole path littering my module, at the top I have placed the line,

use Drupal\views_hybrid\Plugin\Field\FieldFormatter\HybridFormatter;

along with use directives for other classes I am including for use with my module.

You don't use file[] = ... anymore. Instead, classes are autoloaded. For example, I have a module with the following file structure:

  • views_hybrid/
  • views_hybrid.info.yml
  • views_hybrid.module
  • src/
    • Plugin/
      • Field/
        • FieldFormatter/
          • HybridFormatter.php

HybridFormatter.php defines a class called HybridFormatter.

In my .module file, if I start typing in my IDE (NetBeans in this case) HybridFormatter it autocompletes to \Drupal\views_hybrid\Plugin\Field\FieldFormatter\HybridFormatter:: because it is autoloaded. Since I don't want that whole path littering my module, at the top I have placed the line,

use Drupal\views_hybrid\Plugin\Field\FieldFormatter\HybridFormatter;

along with use directives for other classes I am including for use with my module.

The namespace is defined in HybridFormatter.php like so:

namespace Drupal\views_hybrid\Plugin\Field\FieldFormatter;

class HybridFormatter extends FormatterBase { ... }
files !== classes
Source Link
beth
  • 9.1k
  • 3
  • 37
  • 86

You don't use file[] = ... anymore. Instead, filesclasses are autoloaded. For example, I have a module with the following file structure:

  • views_hybrid/
  • views_hybrid.info.yml
  • views_hybrid.module
  • Pluginsrc/
    • FieldPlugin/
      • FieldFormatterField/
        • HybridFormatter.phpFieldFormatter/
          • HybridFormatter.php

HybridFormatter.php defines a class called HybridFormatter.

In my .module file, if I start typing in my IDE (NetBeans in this case) HybridFormatter it autocompletes to \Drupal\views_hybrid\Plugin\Field\FieldFormatter\HybridFormatter:: because it is autoloaded. Since I don't want that whole path littering my module, at the top I have placed the line,

use Drupal\views_hybrid\Plugin\Field\FieldFormatter\HybridFormatter;

along with use directives for other classes I am including for use with my module.

You don't use file[] = ... anymore. Instead, files are autoloaded. For example, I have a module with the following file structure:

  • views_hybrid/
  • views_hybrid.info.yml
  • views_hybrid.module
  • Plugin/
    • Field/
      • FieldFormatter/
        • HybridFormatter.php

HybridFormatter.php defines a class called HybridFormatter.

In my .module file, if I start typing in my IDE (NetBeans in this case) HybridFormatter it autocompletes to \Drupal\views_hybrid\Plugin\Field\FieldFormatter\HybridFormatter:: because it is autoloaded. Since I don't want that whole path littering my module, at the top I have placed the line,

use Drupal\views_hybrid\Plugin\Field\FieldFormatter\HybridFormatter;

along with use directives for other classes I am including for use with my module.

You don't use file[] = ... anymore. Instead, classes are autoloaded. For example, I have a module with the following file structure:

  • views_hybrid/
  • views_hybrid.info.yml
  • views_hybrid.module
  • src/
    • Plugin/
      • Field/
        • FieldFormatter/
          • HybridFormatter.php

HybridFormatter.php defines a class called HybridFormatter.

In my .module file, if I start typing in my IDE (NetBeans in this case) HybridFormatter it autocompletes to \Drupal\views_hybrid\Plugin\Field\FieldFormatter\HybridFormatter:: because it is autoloaded. Since I don't want that whole path littering my module, at the top I have placed the line,

use Drupal\views_hybrid\Plugin\Field\FieldFormatter\HybridFormatter;

along with use directives for other classes I am including for use with my module.

Source Link
beth
  • 9.1k
  • 3
  • 37
  • 86

You don't use file[] = ... anymore. Instead, files are autoloaded. For example, I have a module with the following file structure:

  • views_hybrid/
  • views_hybrid.info.yml
  • views_hybrid.module
  • Plugin/
    • Field/
      • FieldFormatter/
        • HybridFormatter.php

HybridFormatter.php defines a class called HybridFormatter.

In my .module file, if I start typing in my IDE (NetBeans in this case) HybridFormatter it autocompletes to \Drupal\views_hybrid\Plugin\Field\FieldFormatter\HybridFormatter:: because it is autoloaded. Since I don't want that whole path littering my module, at the top I have placed the line,

use Drupal\views_hybrid\Plugin\Field\FieldFormatter\HybridFormatter;

along with use directives for other classes I am including for use with my module.