This repository has been archived by the owner on Jun 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature/INREL-1445 submodule for imagepin
- Loading branch information
Showing
4 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
} | ||
|
||
|
51 changes: 51 additions & 0 deletions
51
modules/infinite_imagepin/src/Plugin/imagepin/Widget/ProductWidget.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>']; | ||
} | ||
|
||
} |