Exemplo n.º 1
0
 /**
  * Constructs a new CountryCode 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 \CommerceGuys\Addressing\Repository\CountryRepositoryInterface $country_repository
  *   The country repository.
  * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
  *   The entity type manager.
  * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
  *   The entity field manager.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, CountryRepositoryInterface $country_repository, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->countryRepository = $country_repository;
     $this->entityTypeManager = $entity_type_manager;
     $this->entityFieldManager = $entity_field_manager;
 }
Exemplo n.º 2
0
 /**
  * @inheritDoc
  */
 public function getValueOptions()
 {
     foreach ($this->categoryStorage->loadByProperties() as $id => $category) {
         $this->valueOptions[$id] = $category->getName();
     }
     return parent::getValueOptions();
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function query()
 {
     if (is_array($this->value) && in_array('_active', $this->value)) {
         $active = \Drupal::entityQuery('uc_order_status')->condition('weight', 0, '>=')->execute();
         $this->value = array_merge($this->value, $active);
     }
     parent::query();
 }
Exemplo n.º 4
0
 /**
  * Override ensureMyTable so we can control how this joins in.
  * The operator actually has influence over joining.
  */
 public function ensureMyTable()
 {
     // Defer to helper if the operator specifies it.
     $info = $this->operators();
     if (isset($info[$this->operator]['ensure_my_table']) && $info[$this->operator]['ensure_my_table'] == 'helper') {
         return $this->helper->ensureMyTable();
     }
     return parent::ensureMyTable();
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function query()
 {
     // Don't filter by language in case the site is not multilingual, because
     // there is no point in doing so.
     if (!$this->languageManager->isMultilingual()) {
         return;
     }
     parent::query();
 }
 /**
  * Constructs a new instance.
  *
  * @param mixed[] $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\StringTranslation\TranslationInterface $string_translation
  * @param \Drupal\payment\Plugin\Payment\Method\PaymentMethodManagerInterface
  */
 public function __construct($configuration, $plugin_id, $plugin_definition, TranslationInterface $string_translation, PaymentMethodManagerInterface $payment_method_manager)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->paymentMethodManager = $payment_method_manager;
     $this->stringTranslation = $string_translation;
 }
Exemplo n.º 7
0
 public function adminSummary()
 {
     // set up $this->valueOptions for the parent summary
     $this->valueOptions = array();
     if ($this->value) {
         $result = entity_load_multiple_by_properties('user', array('uid' => $this->value));
         foreach ($result as $account) {
             if ($account->id()) {
                 $this->valueOptions[$account->id()] = $account->label();
             } else {
                 $this->valueOptions[$account->id()] = 'Anonymous';
                 // Intentionally NOT translated.
             }
         }
     }
     return parent::adminSummary();
 }
Exemplo n.º 8
0
 public function adminSummary()
 {
     // set up $this->valueOptions for the parent summary
     $this->valueOptions = array();
     if ($this->value) {
         $result = \Drupal::entityTypeManager()->getStorage('user')->loadByProperties(['uid' => $this->value]);
         foreach ($result as $account) {
             if ($account->id()) {
                 $this->valueOptions[$account->id()] = $account->label();
             } else {
                 $this->valueOptions[$account->id()] = 'Anonymous';
                 // Intentionally NOT translated.
             }
         }
     }
     return parent::adminSummary();
 }
Exemplo n.º 9
0
 /**
  * Constructs a new instance.
  *
  * @param mixed[] $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\currency\FormHelperInterface
  *   The form helper.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, FormHelperInterface $form_helper)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->formHelper = $form_helper;
 }
Exemplo n.º 10
0
 /**
  * Overrides \Drupal\views\Plugin\views\filter\InOperator::query().
  */
 public function query()
 {
     // Make sure that the entity base table is in the query.
     $this->ensureMyTable();
     parent::query();
 }
Exemplo n.º 11
0
 /**
  * {@inheritdoc}
  */
 public function calculateDependencies()
 {
     $dependencies = parent::calculateDependencies();
     $bundle_entity_type = $this->entityType->getBundleEntityType();
     $bundle_entity_storage = $this->entityManager->getStorage($bundle_entity_type);
     foreach (array_keys($this->value) as $bundle) {
         if ($bundle_entity = $bundle_entity_storage->load($bundle)) {
             $dependencies[$bundle_entity->getConfigDependencyKey()][] = $bundle_entity->getConfigDependencyName();
         }
     }
     return $dependencies;
 }
Exemplo n.º 12
0
  /**
   * {@inheritdoc}
   */
  public function getCacheMaxAge() {
    $cache_max_age = Cache::mergeMaxAges(parent::getCacheMaxAge(), $this->view->storage->getCacheMaxAge());

    return $cache_max_age;
  }
Exemplo n.º 13
0
 /**
  * {@inheritdoc}
  */
 public function submitOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::submitOptionsForm($form, $form_state);
     $subform = $form['entity_reference_selection'];
     $subform_state = new ViewsHandlerFormState($form_state);
     $entity_reference_selection_selector = $this->getPluginSelector($form_state);
     $entity_reference_selection_selector->submitSelectorForm($subform, $subform_state);
     // Views magically sets all submitted form values as plugin options. We must
     // therefore unset any values submitted by the entity reference selection
     // plugin form, and add the ID and configuration of the selected plugin.
     $entity_reference_selection = $entity_reference_selection_selector->getSelectedPlugin();
     $form_state->setValue(['options', 'entity_reference_selection_id'], $entity_reference_selection->getPluginId());
     $entity_reference_selection_handler_settings = $form_state->getValue(['options', 'entity_reference_selection', 'container', 'plugin_form']);
     $form_state->setValue(['options', 'entity_reference_selection_handler_settings'], $entity_reference_selection_handler_settings);
     $form_state->unsetValue(['options', 'entity_reference_selection']);
 }