Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PoItem.php

function PoItem::setFromArray

Create the PoItem from a structured array.

Parameters

array $values: A structured array to create the PoItem from.

File

core/lib/Drupal/Component/Gettext/PoItem.php, line 190

Class

PoItem
PoItem handles one translation.

Namespace

Drupal\Component\Gettext

Code

public function setFromArray(array $values = []) {
    if (isset($values['context'])) {
        $this->setContext($values['context']);
    }
    if (isset($values['source'])) {
        $this->setSource($values['source']);
    }
    if (isset($values['translation'])) {
        $this->setTranslation($values['translation']);
    }
    if (isset($values['comment'])) {
        $this->setComment($values['comment']);
    }
    if (isset($this->source) && str_contains($this->source, self::DELIMITER)) {
        $this->setSource(explode(self::DELIMITER, $this->source));
        $this->setTranslation(explode(self::DELIMITER, $this->translation ?? ''));
        $this->setPlural(count($this->source) > 1);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal