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
Comment #1
Sylvain Lecoy CreditAttribution: Sylvain Lecoy commentedFor the record by adding the following lines:
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 :-)
Comment #2
Sylvain Lecoy CreditAttribution: Sylvain Lecoy commentedNot to mention
admin/structure/block-types/manage/BUNDLE/fields
is broken and leads to a 404 error when defining PSR-0 classes for block.Comment #3
indytechcook CreditAttribution: indytechcook commentedI 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.
Comment #4
indytechcook CreditAttribution: indytechcook commentedadding bean 2 tag.
Comment #5
Sylvain Lecoy CreditAttribution: Sylvain Lecoy commentedWe 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.