<commit_before>{% extends "base/class.php.twig" %}

{% block file_path %}
    Drupal\{{module_name}}\Plugin\rest\resource\{{module_name}}.
{% endblock %}

{% block namespace_class %}
    namespace Drupal\{{module_name}}\Plugin\rest\resource;
{% endblock %}

{% block use_class %}
    use Drupal\Core\Session\AccountProxyInterface;
    use Drupal\rest\Plugin\ResourceBase;
    use Drupal\rest\ResourceResponse;
    use Symfony\Component\DependencyInjection\ContainerInterface;
    use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
    use Symfony\Component\HttpKernel\Exception\HttpException;
    use Psr\Log\LoggerInterface;
{% endblock %}

{% block class_declaration %}
    /**
    * Provides a resource to get view modes by entity and bundle.
    *
    * @RestResource(
    *   id = "{{ plugin_id }}",
    *   label = @Translation("{{ plugin_label }}"),
    *   uri_paths = {
    *     "canonical" = "/{{ plugin_url }}"
    *   }
    * )
    */
    class {{ class_name }} extends ResourceBase {% endblock %}

{% block class_variables %}
    /**
    * A current user instance.
    *
    * @var \Drupal\Core\Session\AccountProxyInterface
    */
    protected $currentUser;

{% endblock %}

{% block class_construct %}
    /**
    * Constructs a Drupal\rest\Plugin\ResourceBase object.
    *
    * @param array $configuration
    *   A configuration array containing information about the plugin instance.
    * @param string $plugin_id
    *   The plugin_id for the plugin instance.
    * @param mixed $plugin_definition
    *   The plugin implementation definition.
    * @param array $serializer_formats
    *   The available serialization formats.
    * @param \Psr\Log\LoggerInterface $logger
    *   A logger instance.
    * @param \Drupal\Core\Session\AccountProxyInterface $current_user
    *   A current user instance.
    */
    public function __construct(
    array $configuration,
    $plugin_id,
    $plugin_definition,
    array $serializer_formats,
    LoggerInterface $logger,
    AccountProxyInterface $current_user) {
    parent::__construct($configuration, $plugin_id, $plugin_definition, $serializer_formats, $logger);

    $this->currentUser = $current_user;
    }

{% endblock %}

{% block class_create %}
    /**
    * {@inheritdoc}
    */
    public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static(
    $configuration,
    $plugin_id,
    $plugin_definition,
    $container->getParameter('serializer.formats'),
    $container->get('logger.factory')->get('rest'),
    $container->get('current_user')
    );
    }

{% endblock %}

{% block class_methods %}
    {% for state in plugin_states %}
        /**
        * Responds to {{ state }} requests.
        *
        * Returns a list of bundles for specified entity.
        *
        * @throws \Symfony\Component\HttpKernel\Exception\HttpException
        *   Throws exception expected.
        */
        public function {{ state|lower }}() {

            // You must to implement the logic of your REST Resource here.
            // Use current user after pass authentication to validate access.

            return new ResourceResponse("Implement REST State {{ state }}!");

            /*if(!$this->currentUser->hasPermission($permission)) {
                throw new AccessDeniedHttpException();
            }*/

            // Throw an exception if it is required.
            // throw new HttpException(t('Throw an exception if it is required.'));
        }
    {% endfor %}
{% endblock %}<commit_msg>#646 Remove extra spaces<commit_after>{% extends "base/class.php.twig" %}

{% block file_path %}
Drupal\{{module_name}}\Plugin\rest\resource\{{module_name}}.
{% endblock %}

{% block namespace_class %}
namespace Drupal\{{module_name}}\Plugin\rest\resource;
{% endblock %}

{% block use_class %}
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\rest\Plugin\ResourceBase;
use Drupal\rest\ResourceResponse;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Psr\Log\LoggerInterface;
{% endblock %}

{% block class_declaration %}
/**
 * Provides a resource to get view modes by entity and bundle.
 *
 * @RestResource(
 *   id = "{{ plugin_id }}",
 *   label = @Translation("{{ plugin_label }}"),
 *   uri_paths = {
 *     "canonical" = "/{{ plugin_url }}"
 *   }
 * )
 */
class {{ class_name }} extends ResourceBase {% endblock %}

{% block class_variables %}
  /**
   * A current user instance.
   *
   * @var \Drupal\Core\Session\AccountProxyInterface
   */
  protected $currentUser;

{% endblock %}

{% block class_construct %}
  /**
   * Constructs a Drupal\rest\Plugin\ResourceBase object.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param array $serializer_formats
   *   The available serialization formats.
   * @param \Psr\Log\LoggerInterface $logger
   *   A logger instance.
   * @param \Drupal\Core\Session\AccountProxyInterface $current_user
   *   A current user instance.
   */
  public function __construct(
    array $configuration,
    $plugin_id,
    $plugin_definition,
    array $serializer_formats,
    LoggerInterface $logger,
    AccountProxyInterface $current_user) {
    parent::__construct($configuration, $plugin_id, $plugin_definition, $serializer_formats, $logger);

    $this->currentUser = $current_user;
  }

{% endblock %}

{% block class_create %}
  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static(
      $configuration,
      $plugin_id,
      $plugin_definition,
      $container->getParameter('serializer.formats'),
      $container->get('logger.factory')->get('rest'),
      $container->get('current_user')
    );
  }

{% endblock %}

{% block class_methods %}
{% for state in plugin_states %}
  /**
   * Responds to {{ state }} requests.
   *
   * Returns a list of bundles for specified entity.
   *
   * @throws \Symfony\Component\HttpKernel\Exception\HttpException
   *   Throws exception expected.
   */
  public function {{ state|lower }}() {

    // You must to implement the logic of your REST Resource here.
    // Use current user after pass authentication to validate access.

    /*
    if(!$this->currentUser->hasPermission($permission)) {
        throw new AccessDeniedHttpException();
    }
    */

    // Throw an exception if it is required.
    // throw new HttpException(t('Throw an exception if it is required.'));
    return new ResourceResponse("Implement REST State {{ state }}!");
  }
{% endfor %}
{% endblock %}
{'fraction_non_alphanumeric': 0.12356486796785304, 'fraction_numerical': 0.00043053960964408724, 'mean_word_length': 3.1556350626118066, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6342292', 'n_tokens_mistral': 2031, 'n_tokens_neox': 1945, 'n_words': 479}