I have issues autoloading classes found in subfolders of my module with xautoload.
my module is called myentity
Here is my hook_entity_info
function myentity_entity_info() {
$return['myentity'] = array(
'label' => t('My entity'),
// The entity class and controller class extend the classes provided by the
// Entity API
'entity class' => 'Drupal/myentity/class/MyEntity',
'controller class' => 'Drupal/myentity/controller/MyEntityController',
'base table' => 'myentity',
'fieldable' => TRUE,
'entity keys' => array(
'id' => 'me_id',
),
'bundles' => array(
'myentity' => array(
'label' => 'myentity',
// Information below is used by the Field UI - they "attach" themselves here and lets us
// do the standard field management that all the core entities enjoy.
'admin' => array(
'path' => 'admin/structure/myentity/manage',
'access arguments' => array('administer myentity'),
),
),
),
'label callback' => 'entity_class_label',
'uri callback' => 'entity_class_uri',
'module' => 'myentity',
'view modes' => array(
'full' => array(
'label' => t('Default'),
'custom settings' => FALSE,
),
'teaser' => array(
'label' => t('Teaser'),
'custom settings' => FALSE,
),
),
'metatags' => TRUE,
);
return $return;
}
My class and controller are found in
sites\all\modules\myentity\lib\Drupal\class\MyEntity.php
with the following content
<?php
namespace Drupal\myentity\class\MyEntity;
/**
* The class used for model entities
*/
class MyEntity extends Entity {
public function __construct($values = array()) {
parent::__construct($values, 'myentity');
}
protected function defaultLabel() {
return $this->name;
}
protected function defaultUri() {
return array('path' => 'myentity/' . $this->identifier());
}
}
and
sites\all\modules\myentity\lib\Drupal\controller\MyEntityController.php
Drupal\myentity\class\MyEntity
it will autoloadsites\all\modules\Drupal\myentity\class\MyEntity.php
I believe you can tell it to look in a different folder, but the same sort of "structure" will apply.