You are here

LingotekContentEntityActionBase.php in Lingotek Translation 3.0.x

File

src/Plugin/Action/LingotekContentEntityActionBase.php
View source
<?php

namespace Drupal\lingotek\Plugin\Action;

use Drupal\Core\Action\Plugin\Action\EntityActionBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\lingotek\LingotekContentTranslationServiceInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class LingotekContentEntityActionBase extends EntityActionBase {

  /**
   * The Lingotek content translation service.
   *
   * @var \Drupal\lingotek\LingotekContentTranslationServiceInterface
   */
  protected $translationService;

  /**
   * Constructs a new UploadToLingotekAction action.
   *
   * @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 \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   * @param \Drupal\lingotek\LingotekContentTranslationServiceInterface $translation_service
   *   The Lingotek content translation service.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, LingotekContentTranslationServiceInterface $translation_service) {
    parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager);
    $this->translationService = $translation_service;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('entity_type.manager'), $container
      ->get('lingotek.content_translation'));
  }

  /**
   * {@inheritdoc}
   */
  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
    return TRUE;

    /** @var \Drupal\node\NodeInterface $object */
    $result = $object
      ->access('update', $account, TRUE)
      ->andIf($object
      ->getOwner()
      ->access('edit', $account, TRUE));
    return $return_as_object ? $result : $result
      ->isAllowed();
  }

}