When defining a block type like this:

<?php


/**
 * Implements hook_bean_types().
 */
function disney_block_bean_types() {
  $plugins = array();

  $plugins['text_display'] = array(
    'label' => t('Text with Display'),
    'description' => t('A block containing text, along with a reference to arbitrary content.'),
    'handler' => array(
      'class' => 'Disney\Block\Type\TextBlock',
      'parent' => 'bean',
    ),
  );

  return $plugins;
}
?>

Bean is unable to load the class while defined and loaded through the class loader module.

It has to follow the ctools convention which is a great blocker for me and to general software good practices development.

Bean should not rely on ctools and provides his own mechanism, thus allowing PSR-0 class to be loaded easily thanks to modules such as classloader (and then being forward compatible with Drupal 8) and deal with the class registry limitation of drupal 7 if people not using classloader (that is declaring classes in .info files).

I'll work on a patch, if not i'll fork this project to removes the evil dependency. :-)

Comments

Sylvain Lecoy’s picture

Category: bug » feature
Priority: Major » Normal

For the record by adding the following lines:

<?php

    'path' => drupal_get_path('module', 'disney_block') . '/lib/Disney/Block/Type',
    'file' => 'TextBlock.php',

?

It does the quick fix.

The issue aims to remove these lines and allows auto loader to find the file.

Note: it will also allows the removing of files[] = '...' in info files. DRY principle :-)

Sylvain Lecoy’s picture

Category: feature » bug
Priority: Normal » Major

Not to mention admin/structure/block-types/manage/BUNDLE/fields is broken and leads to a 404 error when defining PSR-0 classes for block.

indytechcook’s picture

Category: feature » bug
Priority: Normal » Major

I totally agree with you. I'd rather not use ctools at all as it doesn't really provide that much functionality.

This would be in a 2.x branch.

I actually like the https://drupal.org/project/xautoload to handle the autoloading but either xautoload or classloader is a huge improvement over ctools or d7 core's class loading.

indytechcook’s picture

Issue tags: +bean 2

adding bean 2 tag.

Sylvain Lecoy’s picture

We can have an optional dependency, the simple fact of registering your classes as PSR-0 would work out of the box with either XAutoload or classloader, letting the developer the responsibility to tell the dependency on his .info file declaring the dependency.

I am happy you react favorably to this so I take it as a go to start working on a patch.