abstract class crumbs_EntityPlugin_Field_Abstract in Crumbs, the Breadcrumbs suite 7.2
Hierarchy
- class \crumbs_EntityPlugin_Field_Abstract implements crumbs_EntityPlugin
Expanded class hierarchy of crumbs_EntityPlugin_Field_Abstract
File
- lib/
EntityPlugin/ Field/ Abstract.php, line 3
View source
abstract class crumbs_EntityPlugin_Field_Abstract implements crumbs_EntityPlugin {
/**
* @var string
*/
protected $fieldKey;
/**
* @var array
*/
protected $bundlesByType;
/**
* @param string $field_key
* @param array $bundles_by_type
*/
function __construct($field_key, array $bundles_by_type) {
$this->fieldKey = $field_key;
$this->bundlesByType = $bundles_by_type;
}
/**
* {@inheritdoc}
*/
function describe($api, $entity_type, $keys) {
if (!empty($this->bundlesByType[$entity_type])) {
if ('user' === $entity_type) {
$instance = field_info_instance('user', $this->fieldKey, 'user');
foreach ($keys as $key => $title) {
$api
->addRule($key, $title);
}
$api
->descWithLabel($instance['label'], t('Field'));
}
foreach ($this->bundlesByType[$entity_type] as $bundle_name) {
if (isset($keys[$bundle_name])) {
$instance = field_info_instance($entity_type, $this->fieldKey, $bundle_name);
$api
->addRule($bundle_name, $keys[$bundle_name]);
$api
->descWithLabel($instance['label'], t('Field'), $bundle_name);
}
}
// $api->addDescription('(' . $this->fieldKey . ')');
}
}
/**
* {@inheritdoc}
*/
function entityFindCandidate($entity, $entity_type, $distinction_key) {
$items = field_get_items($entity_type, $entity, $this->fieldKey);
if (is_array($items) && !empty($items)) {
return $this
->fieldFindCandidate($items);
}
return NULL;
}
/**
* @param array $items
* @return string
*/
protected abstract function fieldFindCandidate(array $items);
/**
* @return array
*/
protected function getFieldInfo() {
return field_info_field($this->fieldKey);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
crumbs_EntityPlugin_Field_Abstract:: |
protected | property | ||
crumbs_EntityPlugin_Field_Abstract:: |
protected | property | ||
crumbs_EntityPlugin_Field_Abstract:: |
function |
Overrides crumbs_EntityPlugin:: |
||
crumbs_EntityPlugin_Field_Abstract:: |
function |
Overrides crumbs_EntityPlugin:: |
||
crumbs_EntityPlugin_Field_Abstract:: |
abstract protected | function | 5 | |
crumbs_EntityPlugin_Field_Abstract:: |
protected | function | ||
crumbs_EntityPlugin_Field_Abstract:: |
function |