Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twig base plugins generator #161

Merged
merged 2 commits into from
Jul 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions src/Resources/skeleton/module/src/Plugin/Block/block.php.twig
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
<?php
/**
* @file
* Contains \Drupal\{{module}}\Plugin\Block\{{class_name}}.php
*/
{% extends "base/class.php.twig" %}

{% block file_path %}
Drupal\{{module}}\Plugin\Block\{{class_name}}.
{% endblock %}

{% block namespace_class %}
namespace Drupal\{{module}}\Plugin\Block;
{% endblock %}

{% block use_class %}
use Drupal\block\BlockBase;
{% if services is not empty %}
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
{% include 'skeleton/module/shared/services-use-operator.php.twig' %}
use Symfony\Component\DependencyInjection\ContainerInterface;
{% endif %}
{% endblock %}

{% block class_declaration %}
/**
* Provides a '{{class_name}}' block.
*
Expand All @@ -20,9 +25,11 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
* admin_label = @Translation("{{plugin_label}}")
* )
*/
class {{class_name}} extends BlockBase {% if services is not empty %}implements ContainerFactoryPluginInterface{% endif %} {{"\n"}}{
class {{class_name}} extends BlockBase {% if services is not empty %}implements ContainerFactoryPluginInterface {% endif %}
{% endblock %}

{% block class_construct %}
{% if services is not empty %}
{% include 'skeleton/module/shared/services-class-properties-declaration.php.twig' %}
/**
* Construct.
*
Expand All @@ -40,9 +47,14 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
{{ servicesAsParameters(services)|join(', \n\t') }}
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
{% include 'skeleton/module/shared/services-class-properties-initialization.php.twig' %}
{{ serviceClassInitialization(services) }}
}

{% endif %}
{% endblock %}

{% block class_create %}
{% if services is not empty %}
/**
* {@inheritdoc}
*/
Expand All @@ -52,11 +64,14 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
$configuration,
$plugin_id,
$plugin_definition,
{% include 'skeleton/module/shared/services-class-properties-injection.php.twig' %}
{{ serviceClassInjection(services) }}
);
}

{% endif %}
{% endblock %}

{% block class_methods %}
/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -94,4 +109,4 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
{% endfor %}
}
{% endif %}
}
{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<?php
/**
*@file
* Contains \Drupal\{{module}}\Plugin\ImageEffect\{{class_name}}.php
*/
{% extends "base/class.php.twig" %}

{% block file_path %}
Drupal\{{module}}\Plugin\ImageEffect\{{class_name}}.
{% endblock %}

{% block namespace_class %}
namespace Drupal\{{module}}\Plugin\ImageEffect;
{% endblock %}

{% block use_class %}
use Drupal\Core\Image\ImageInterface;
use Drupal\image\ImageEffectBase;
{% endblock %}

{% block class_declaration %}
/**
* Provides a '{{class_name}}' image effect.
*
Expand All @@ -18,13 +23,15 @@ use Drupal\image\ImageEffectBase;
* description = @Translation("{{description}}")
* )
*/
class {{ class_name }} extends ImageEffectBase {
class {{ class_name }} extends ImageEffectBase
{% endblock %}

{% block class_methods %}
/**
* {@inheritdoc}
*/
public function applyEffect(ImageInterface $image) {
// Implement Image Effect
return imagefilter($image->getToolkit()->getResource());
}
}
{% endblock %}