Skip to content
This repository was archived by the owner on Jan 5, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions config/schema/entity_browser.schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Schema for configuration files of the Entity browser module.

entity_browser.browser.*:
type: config_entity
label: 'Entity browser'
mapping:
name:
type: string
label: 'Machine name'
label:
type: label
label: 'Label'
display:
type: 'mapping'
label: 'Display'
mapping:
id:
type: string
uuid:
type: string
label:
type: string
settings:
type: entity_browser.browser.display.[%parent.id]
widgets:
type: sequence
label: 'Widgets'
sequence:
- type: mapping
mapping:
id:
type: string
uuid:
type: string
label:
type: string
weight:
type: integer
settings:
type: entity_browser.browser.widget.[%parent.id]
widget_selector:
type: mapping
mapping:
id:
type: string
uuid:
type: string
label:
type: string
settings:
type: entity_browser.browser.widget_selector.[%parent.id]
selection_display:
type: mapping
mapping:
id:
type: string
uuid:
type: string
label:
type: string
settings:
type: entity_browser.browser.selection_display.[%parent.id]
57 changes: 57 additions & 0 deletions entity_browser.api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

/**
* @file
* Hooks related to entity browser and it's plugins.
*/

/**
* @addtogroup hooks
* @{
*/

/**
* Alter the information provided in \Drupal\entity_browser\Annotation\EntityBrowserDisplay.
*
* @param $displays
* The array of display plugins, keyed on the machine-readable name.
*/
function hook_entity_browser_display_info_alter(&$displays) {
$displays['modal_display']['label'] = t('Superb fancy stuff!');
}

/**
* Alter the information provided in \Drupal\entity_browser\Annotation\EntityBrowserWidget.
*
* @param $widgets
* The array of widget plugins, keyed on the machine-readable name.
*/
function hook_entity_browser_widget_info_alter(&$widgets) {
$widgets['view_widget']['label'] = t('Views FTW!');
}

/**
* Alter the information provided in \Drupal\entity_browser\Annotation\EntityBrowserSelectionDisplay.
*
* @param $widgets
* The array of selection display plugins, keyed on the machine-readable name.
*/
function hook_entity_browser_selection_display_info_alter(&$selection_displays) {
$selection_displays['no_selection']['label'] = t('Nothing!');
}

/**
* Alter the information provided in \Drupal\entity_browser\Annotation\EntityBrowserWidgetSelector.
*
* @param $widget_selectors
* The array of widget selector plugins, keyed on the machine-readable name.
*/
function hook_entity_browser_widget_selector_info_alter(&$widgets) {
$widgets['tab_selector']['label'] = t('Tabs are for winners');
}



/**
* @} End of "addtogroup hooks".
*/
19 changes: 19 additions & 0 deletions entity_browser.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/**
* @file
* Allows to flexibly create, browse and select entites.
*/

/**
* Implements hook_permission().
*/
function entity_browser_permission() {
return array(
'administer entity browsers' => array(
'title' => t('Administer entity browsers'),
'description' => t('Create and modify entity browsers for generating browsing, creating and selecting entities.'),
'restrict access' => TRUE,
),
);
}
13 changes: 13 additions & 0 deletions entity_browser.services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
plugin.manager.entity_browser.display:
class: Drupal\entity_browser\EntityBrowserDisplayManager
parent: default_plugin_manager
plugin.manager.entity_browser.selection_display:
class: Drupal\entity_browser\EntityBrowserSelectionDisplayManager
parent: default_plugin_manager
plugin.manager.entity_browser.widget:
class: Drupal\entity_browser\EntityBrowserWidgetManager
parent: default_plugin_manager
plugin.manager.entity_browser.widget_selector:
class: Drupal\entity_browser\EntityBrowserWidgetSelectorManager
parent: default_plugin_manager
48 changes: 48 additions & 0 deletions src/Annotation/EntityBrowserDisplay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* @file
* Contains \Drupal\entity_browser\Annotation\EntityBrowserDisplay.
*/

namespace Drupal\entity_browser\Annotation;

use Drupal\Component\Annotation\Plugin;

/**
* Defines an entity browser display annotation object.
*
* @see hook_entity_browser_display_info_alter()
*
* @Annotation
*/
class EntityBrowserDisplay extends Plugin {

/**
* The plugin ID.
*
* @var string
*/
public $id;

/**
* The human-readable name of the display.
*
* @ingroup plugin_translatable
*
* @var \Drupal\Core\Annotation\Translation
*/
public $label;

/**
* A brief description of the display.
*
* This will be shown when adding or configuring this display.
*
* @ingroup plugin_translatable
*
* @var \Drupal\Core\Annotation\Translation (optional)
*/
public $description = '';

}
48 changes: 48 additions & 0 deletions src/Annotation/EntityBrowserSelectionDisplay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* @file
* Contains \Drupal\entity_browser\Annotation\EntityBrowserSelectionDisplay.
*/

namespace Drupal\entity_browser\Annotation;

use Drupal\Component\Annotation\Plugin;

/**
* Defines an entity browser selection display annotation object.
*
* @see hook_entity_browser_selection_display_info_alter()
*
* @Annotation
*/
class EntityBrowserSelectionDisplay extends Plugin {

/**
* The plugin ID.
*
* @var string
*/
public $id;

/**
* The human-readable name of the selection display.
*
* @ingroup plugin_translatable
*
* @var \Drupal\Core\Annotation\Translation
*/
public $label;

/**
* A brief description of the selection display.
*
* This will be shown when adding or configuring this selection display.
*
* @ingroup plugin_translatable
*
* @var \Drupal\Core\Annotation\Translation (optional)
*/
public $description = '';

}
48 changes: 48 additions & 0 deletions src/Annotation/EntityBrowserWidget.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* @file
* Contains \Drupal\entity_browser\Annotation\EntityBrowserWidget.
*/

namespace Drupal\entity_browser\Annotation;

use Drupal\Component\Annotation\Plugin;

/**
* Defines an entity browser widget annotation object.
*
* @see hook_entity_browser_widget_info_alter()
*
* @Annotation
*/
class EntityBrowserWidget extends Plugin {

/**
* The plugin ID.
*
* @var string
*/
public $id;

/**
* The human-readable name of the widget.
*
* @ingroup plugin_translatable
*
* @var \Drupal\Core\Annotation\Translation
*/
public $label;

/**
* A brief description of the widget.
*
* This will be shown when adding or configuring this widget.
*
* @ingroup plugin_translatable
*
* @var \Drupal\Core\Annotation\Translation (optional)
*/
public $description = '';

}
48 changes: 48 additions & 0 deletions src/Annotation/EntityBrowserWidgetSelector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* @file
* Contains \Drupal\entity_browser\Annotation\EntityBrowserWidgetSelector.
*/

namespace Drupal\entity_browser\Annotation;

use Drupal\Component\Annotation\Plugin;

/**
* Defines an entity browser widget selector annotation object.
*
* @see hook_entity_browser_widget_selector_info_alter()
*
* @Annotation
*/
class EntityBrowserWidgetSelector extends Plugin {

/**
* The plugin ID.
*
* @var string
*/
public $id;

/**
* The human-readable name of the widget selector.
*
* @ingroup plugin_translatable
*
* @var \Drupal\Core\Annotation\Translation
*/
public $label;

/**
* A brief description of the widget selector.
*
* This will be shown when adding or configuring this widget selector.
*
* @ingroup plugin_translatable
*
* @var \Drupal\Core\Annotation\Translation (optional)
*/
public $description = '';

}
Loading