Skip to content

Commit

Permalink
Merge pull request #38 from doylejd/master
Browse files Browse the repository at this point in the history
Code Cleanup
  • Loading branch information
Jason Enter committed Aug 20, 2015
2 parents ddbf2ac + 59810c5 commit edf4b63
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 29 deletions.
14 changes: 0 additions & 14 deletions addthis.module
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,4 @@ function addthis_theme() {
];
}

/**
* Implementation to retrieve formatters for a given type of field.
*/
function _addthis_field_info_formatter_field_type($field_type = NULL) {
$formatters = \Drupal::Service('plugin.manager.field.formatter')
->getDefinitions();
foreach ($formatters as $key => $formatter) {
if (!in_array((!isset($field_type) ? 'addthis' : $field_type), $formatter['field_types'])) {
unset($formatters[$key]);
}
}
return $formatters;
}


11 changes: 4 additions & 7 deletions addthis_block/src/Plugin/Block/AddThisBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ public function defaultConfiguration() {
* {@inheritdoc}
*/
function blockForm($form, FormStateInterface $form_state) {

// The list of formatters.
$add_this_service = \Drupal::service('addthis.addthis');
$formatter_options = $add_this_service->getDisplayTypes();


$settings = $this->getConfiguration();

$type = $settings['type'];
Expand Down Expand Up @@ -74,7 +68,10 @@ function blockForm($form, FormStateInterface $form_state) {
'#type' => 'select',
'#title' => t('Formatter for @title', array('@title' => 'AddThis block')),
'#title_display' => 'invisible',
'#options' => $formatter_options,
'#options' => [
'addthis_basic_button',
'addthis_basic_toolbox'
],
'#default_value' => $settings['type'],
'#attributes' => array('class' => array('addthis-display-type')),
'#ajax' => array(
Expand Down
8 changes: 0 additions & 8 deletions src/AddThis.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,5 @@ private function getProfileIdQueryParameterPrefixedWithHash() {
}


public function getDisplayTypes() {
$displays = array();
foreach ($display_impl = _addthis_field_info_formatter_field_type() as $key => $display) {
$displays[$key] = t(SafeMarkup::checkPlain($display['label']));
}
return $displays;
}


}

0 comments on commit edf4b63

Please sign in to comment.