Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
feature/INREL-1445 submodule for imagepin
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenx committed Oct 11, 2017
1 parent 94fda4f commit 82389e6
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 0 deletions.
7 changes: 7 additions & 0 deletions PATCHES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This file was automatically generated by Composer Patches (https://github.com/cweagans/composer-patches)
Patches applied to this directory:

add shop the look
Source: https://patch-diff.githubusercontent.com/raw/BurdaMagazinOrg/infinite-module/pull/49.diff


7 changes: 7 additions & 0 deletions modules/infinite_imagepin/infinite_imagepin.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: Infinite Imagepin
type: module
description: Impagepin related customizations
core: 8.x
package: Infinite
dependencies:
- imagepin
25 changes: 25 additions & 0 deletions modules/infinite_imagepin/infinite_imagepin.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/**
* Alter the list of allowed widget plugins per view mode and entity type.
*
* Use this hook to restrict or allow the usage
* of given plugins in the widgets form.
*
* @param array &$plugin_definitions
* The array of plugin definitions.
* Keys are plugin ids, values are plugin labels.
* @param string &$default_plugin
* The default plugin id to use on the widgets form.
* @param array $context
* Consists of following keys:
* - 'view_mode': The machine name of the given view mode.
* - 'belonging_entity_type': The given entity type id.
*/
function infinite_imagepin_allowed_widget_plugins_alter(array &$plugin_definitions, &$default_plugin, array $context) {
// Don't include the default text widget.
#unset($plugin_definitions['text']);
#$default_plugin = 'product';
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Drupal\imagepin\Plugin\imagepin\Widget;

use Drupal\Core\Form\FormStateInterface;
use Drupal\imagepin\Plugin\WidgetBase;

/**
* The text widget plugin.
*
* @Widget(
* id = "product",
* label = @Translation("Product"),
* )
*/
class ProductWidget extends WidgetBase {

/**
* {@inheritdoc}
*/
public function formNewElement(array &$form, FormStateInterface $form_state) {
$element = [];

// TODO Required fields currently don't work.
// Form API documentation lacks here, again.
$element['product'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'advertising_product',
'#title' => t('Product'),
'#required' => FALSE,
'#weight' => 10,
];

return $element;
}

/**
* {@inheritdoc}
*/
public function previewContent($value) {
return ['#markup' => '<p>xxx' . $value['product'] . '</p>'];
}

/**
* {@inheritdoc}
*/
public function viewContent($value) {
return ['#markup' => '<p>xxcd' . $value['product'] . '</p>'];
}

}

0 comments on commit 82389e6

Please sign in to comment.