-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #824 from droptica/develop
Release 3.1.0-rc2
- Loading branch information
Showing
28 changed files
with
516 additions
and
19 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
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
add_license: false | ||
minifier: 4 | ||
minifier: 5 | ||
ratio_max: 0.9 | ||
ratio_min: 0.1 | ||
ratio_min: 0.1 |
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
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
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
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
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
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
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,15 @@ | ||
services: | ||
droopler.paragraph_generator: | ||
class: Drupal\d_p\Generators\ParagraphModuleGenerator | ||
tags: | ||
- { name: drush.generator } | ||
|
||
droopler.setting_plugin_generator: | ||
class: Drupal\d_p\Generators\SettingPluginGenerator | ||
tags: | ||
- { name: drush.generator } | ||
|
||
droopler.setting_class_plugin_generator: | ||
class: Drupal\d_p\Generators\SettingClassPluginGenerator | ||
tags: | ||
- { name: drush.generator } |
59 changes: 59 additions & 0 deletions
59
modules/custom/d_p/src/Generators/ParagraphModuleGenerator.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,59 @@ | ||
<?php | ||
|
||
namespace Drupal\d_p\Generators; | ||
|
||
use DrupalCodeGenerator\Command\BaseGenerator; | ||
use DrupalCodeGenerator\Utils; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Question\ConfirmationQuestion; | ||
|
||
/** | ||
* The class that adds Droopler Paragraph generator to Drush. | ||
*/ | ||
class ParagraphModuleGenerator extends BaseGenerator { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $name = 'droopler-paragraph-module'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $description = 'Generates a Droopler Paragraph module.'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $alias = 'dropar'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $templatePath = __DIR__; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function interact(InputInterface $input, OutputInterface $output) { | ||
$questions = Utils::moduleQuestions(); | ||
$questions['preprocess'] = new ConfirmationQuestion('Would you like to create a sample preprocess function to read paragraph settings?', TRUE); | ||
|
||
$vars = &$this->collectVars($input, $output, $questions); | ||
$vars['template'] = 'paragraph--' . str_replace('_', '-', $vars['machine_name']); | ||
|
||
$this->addFile() | ||
->path('{machine_name}.module') | ||
->template('paragraph-module.twig'); | ||
|
||
$this->addFile() | ||
->path('{machine_name}.info.yml') | ||
->template('paragraph-info.twig'); | ||
|
||
$this->addFile() | ||
->path('templates/{template}.html.twig') | ||
->template('paragraph-template.twig'); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
modules/custom/d_p/src/Generators/SettingClassPluginGenerator.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,48 @@ | ||
<?php | ||
|
||
namespace Drupal\d_p\Generators; | ||
|
||
use DrupalCodeGenerator\Command\BaseGenerator; | ||
use DrupalCodeGenerator\Utils; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* The class that adds Droopler Class Setting Plugin generator to Drush. | ||
*/ | ||
class SettingClassPluginGenerator extends BaseGenerator { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $name = 'droopler-setting-class-plugin'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $description = 'Generates a Droopler Class Setting plugin.'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $alias = 'drosec'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $templatePath = __DIR__; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function interact(InputInterface $input, OutputInterface $output) { | ||
$questions = Utils::moduleQuestions() + Utils::pluginQuestions(); | ||
|
||
$vars = &$this->collectVars($input, $output, $questions); | ||
|
||
$this->addFile() | ||
->path('src/Plugin/ParagraphSetting/{class}.php') | ||
->template('setting-class-plugin.twig'); | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
modules/custom/d_p/src/Generators/SettingPluginGenerator.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,47 @@ | ||
<?php | ||
|
||
namespace Drupal\d_p\Generators; | ||
|
||
use DrupalCodeGenerator\Command\BaseGenerator; | ||
use DrupalCodeGenerator\Utils; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* The class that adds Droopler Setting Plugin generator to Drush. | ||
*/ | ||
class SettingPluginGenerator extends BaseGenerator { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $name = 'droopler-setting-plugin'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $description = 'Generates a Droopler Setting plugin.'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $alias = 'drosep'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $templatePath = __DIR__; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function interact(InputInterface $input, OutputInterface $output) { | ||
$questions = Utils::moduleQuestions() + Utils::pluginQuestions(); | ||
$vars = &$this->collectVars($input, $output, $questions); | ||
|
||
$this->addFile() | ||
->path('src/Plugin/ParagraphSetting/{class}.php') | ||
->template('setting-plugin.twig'); | ||
} | ||
|
||
} |
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,8 @@ | ||
name: {{ name }} | ||
type: module | ||
description: The {{ machine_name }} paragraph. | ||
package: Paragraphs | ||
core: 8.x | ||
core_version_requirement: ^8 || ^9 | ||
dependencies: | ||
- paragraphs:paragraphs |
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,40 @@ | ||
<?php | ||
/** | ||
* @file | ||
* A module with {{ name }} paragraph. | ||
*/ | ||
{% if preprocess %} | ||
use Drupal\d_p\Exception\MissingConfigurationStorageFieldException; | ||
use Drupal\d_p\Plugin\Field\FieldType\ConfigurationStorage; | ||
{% endif %} | ||
/** | ||
* Implements hook_theme(). | ||
*/ | ||
function {{ machine_name }}_theme($existing, $type, $theme, $path): array { | ||
return [ | ||
'paragraph__{{ machine_name }}' => [ | ||
'base hook' => 'paragraph', | ||
], | ||
]; | ||
} | ||
{% if preprocess %} | ||
/** | ||
* Implements hook_preprocess_HOOK(). | ||
*/ | ||
function {{ machine_name }}_preprocess_paragraph__{{ machine_name }}(array &$variables) { | ||
$paragraph = $variables['paragraph']; | ||
try { | ||
/** @var \Drupal\d_p\Plugin\Field\ConfigurationStorageFieldItemListInterface $setting_field */ | ||
$setting_field = ConfigurationStorage::getSettingsFieldFromEntity($paragraph); | ||
$variables['foo'] = $setting_field->getSettingValue('foo'); | ||
} | ||
catch (MissingConfigurationStorageFieldException $exception) { | ||
\Drupal::logger('{{ machine_name }}')->error($exception->getMessage()); | ||
} | ||
} | ||
{% endif %} |
15 changes: 15 additions & 0 deletions
15
modules/custom/d_p/src/Generators/paragraph-preprocess.twig
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,15 @@ | ||
/** | ||
* Implements hook_preprocess_HOOK(). | ||
*/ | ||
function {{ machine_name }}_preprocess_paragraph__{{ machine_name }}(array &$variables) { | ||
$paragraph = $variables['paragraph']; | ||
try { | ||
/** @var \Drupal\d_p\Plugin\Field\ConfigurationStorageFieldItemListInterface $setting_field */ | ||
$setting_field = ConfigurationStorage::getSettingsFieldFromEntity($paragraph); | ||
|
||
$variables['foo'] = $setting_field->getSettingValue('foo'); | ||
} | ||
catch (MissingConfigurationStorageFieldException $exception) { | ||
\Drupal::logger('{{ machine_name }}')->error($exception->getMessage()); | ||
} | ||
} |
Oops, something went wrong.