Entity Ref Bootstrap Accordion / Tab Formatter:

Simple Bootstrap Accordion / Tab Field formatter for field types "entity_reference , entity_reference_revisions".
So it will be available Paragraphs module as well.

It's a fork to https://www.drupal.org/project/entity_ref_tab_formatter

Library used except Bootstrap :

Bootstrap Responsive Tabs : https://openam.github.io/bootstrap-responsive-tabs/
Use of 3 fields including a type field that has as possible value:
- accordion | Accordion with first open
- accordion_closed | Accordion closed
- tab | Tabs

Project link

https://www.drupal.org/project/entity_bs_accordion_tab_formatter

Git instructions

git clone --branch 8.x-1.x https://git.drupalcode.org/project/entity_bs_accordion_tab_formatter.git

PAReview checklist

https://pareview.sh/pareview/https-git.drupal.org-project-entity_bs_acco...

Comments

netsliver created an issue. See original summary.

netsliver’s picture

Issue summary: View changes
rksyravi’s picture

Issue summary: View changes

Hi @netsliver,

Thank you for contribution!!!
Give us time for manual testing.

vuil’s picture

Status: Needs review » Needs work

Thank you for the contribution!

Please fix the following issues:

1. Please update your js/bootstrap-responsive-tabs/README.md file - each row can not be exceeds 80 chars per line.

More info: Drupal Coding Standard

2. ESLint has been found some issues related to Javascript coding standard:

/var/vhosts/c214000000/site1101/web/vendor/drupal/pareviewsh/pareview_temp/js/bootstrap-responsive-tabs/.eslintrc:
	Configuration for rule "consistent-return" is invalid:
	Severity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed 'true').

Error: /var/vhosts/c214000000/site1101/web/vendor/drupal/pareviewsh/pareview_temp/js/bootstrap-responsive-tabs/.eslintrc:
	Configuration for rule "consistent-return" is invalid:
	Severity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed 'true').

    at validateRuleOptions (/var/vhosts/c214000000/site1101/web/vendor/drupal/pareviewsh/node_modules/eslint/lib/config/config-validator.js:109:15)
    at Object.keys.forEach.id (/var/vhosts/c214000000/site1101/web/vendor/drupal/pareviewsh/node_modules/eslint/lib/config/config-validator.js:156:13)
    at Array.forEach ()
    at Object.validate (/var/vhosts/c214000000/site1101/web/vendor/drupal/pareviewsh/node_modules/eslint/lib/config/config-validator.js:155:35)
    at Object.load (/var/vhosts/c214000000/site1101/web/vendor/drupal/pareviewsh/node_modules/eslint/lib/config/config-file.js:559:19)
    at loadConfig (/var/vhosts/c214000000/site1101/web/vendor/drupal/pareviewsh/node_modules/eslint/lib/config.js:63:33)
    at getLocalConfig (/var/vhosts/c214000000/site1101/web/vendor/drupal/pareviewsh/node_modules/eslint/lib/config.js:130:29)
    at Config.getConfig (/var/vhosts/c214000000/site1101/web/vendor/drupal/pareviewsh/node_modules/eslint/lib/config.js:260:26)
    at processText (/var/vhosts/c214000000/site1101/web/vendor/drupal/pareviewsh/node_modules/eslint/lib/cli-engine.js:224:33)
    at processFile (/var/vhosts/c214000000/site1101/web/vendor/drupal/pareviewsh/node_modules/eslint/lib/cli-engine.js:303:18)

3. Please remove implements ContainerFactoryPluginInterface because it exists in the extended FormatterBase.

The class declaration above is in Drupal\entity_bs_accordion_tab_formatter\Plugin\Field\FieldFormatter\EntityBSAccordionTabFormatter.

4. Please add the two parameters ($entity_type_id, $bundle) in the PHPDoc (annotation) because they are missing:

/**
   * Helper function.
   */
  private function getEntityFields($entity_type_id, $bundle) {

5. You can simply use (in public function settingsSummary()):

    return [];

instead of:

    $summary = [];
    // Implement settings summary.
    return $summary;

until you decide the future solution.

6. It is better to handle all possible exceptions which will be raised (eventually) in method viewElements.

7. Please don't use deprecated classes / interfaces as Drupal\Core\Entity\EntityManagerInterface which is deprecated in Drupal 8.0 and is removed from Drupal 9.0.

Please see https://www.drupal.org/node/2549139

8. Please replace your parameter $plugin_definitions to be a parameter:

\Drupal\Core\Field\FieldDefinitionInterface $field_definition

instead of FieldConfig $field_definition.

All points from 3. to 8. are in plugin class EntityBSAccordionTabFormatter.

netsliver’s picture

Hi,

I made the changes:

1 - 2 : I have moved the library to libraries folder
3 : I have removed the implements
4 : I have changed the PHPDoc
5 : I have Simply used your example
6 : try ... catch all the function with logger exception
7 : I have changed the class
8 : I have change the prototype

ankush_03’s picture

Fix below issue also :

ankushgautam@GGN-199732-C02ZT1F1MD6V contrib % drupal-check -ad entity_bs_accordion_tab_formatter
4/4 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

------ -------------------------------------------
Line entity_bs_accordion_tab_formatter.install
------ -------------------------------------------
17 Function libraries_get_path not found.
------ -------------------------------------------

------ --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Line src/Plugin/Field/FieldFormatter/EntityBSAccordionTabFormatter.php
------ --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
76 Unsafe usage of new static().
💡 Consider making the class or the constructor final.
179 Method Drupal\entity_bs_accordion_tab_formatter\Plugin\Field\FieldFormatter\EntityBSAccordionTabFormatter::viewElements() should return array but return statement is missing.
201 Call to an undefined method Drupal\Core\Entity\EntityInterface::get().
207 Call to an undefined method Drupal\Core\Entity\EntityInterface::get().
212 Call to an undefined method Drupal\Core\Entity\EntityInterface::get().
214 Variable $style might not be defined.
224 Variable $style might not be defined.
225 Variable $style might not be defined.
237 Variable $style might not be defined.
238 Variable $style might not be defined.
244 Variable $style might not be defined.
254 Variable $style might not be defined.
256 Variable $component_id might not be defined.
257 Variable $style might not be defined.
260 Variable $style might not be defined.
265 Variable $style might not be defined.
266 Variable $component_id might not be defined.
269 Variable $style might not be defined.
270 Variable $style might not be defined.
273 Variable $style might not be defined.
275 Variable $style might not be defined.
281 Variable $style might not be defined.
291 Variable $style might not be defined.
301 Variable $delta might not be defined.
305 Variable $component_id might not be defined.
308 Variable $style might not be defined.
309 Variable $delta might not be defined.
310 Variable $delta might not be defined.
------ --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[ERROR] Found 29 errors

netsliver’s picture

Everything is ok except Call to an undefined method Drupal\Core\Entity\EntityInterface::get() which I don't understand because the code works.

$content = $this->entityTypeManager->getStorage($entity_type_id)->load($id);
...
$title = $content->get($title_field)->getValue()[0]['value'];
avpaderno’s picture

Status: Needs work » Closed (duplicate)
Related issues: +#2902793: [D8] Entity Ref Bootstrap Accordion / Tab Formatter

There was already an application opened using the same project. I am closing this as duplicate, and re-opening the other one.