Chris@0: isNew)) { Chris@0: // We mark the string as not new if it is a complete translation. Chris@0: // This will work when loading from database, otherwise the storage Chris@0: // controller that creates the string object must handle it. Chris@0: $this->isNew = !$this->isTranslation(); Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Sets the string as customized / not customized. Chris@0: * Chris@0: * @param bool $customized Chris@0: * (optional) Whether the string is customized or not. Defaults to TRUE. Chris@0: * Chris@0: * @return \Drupal\locale\TranslationString Chris@0: * The called object. Chris@0: */ Chris@0: public function setCustomized($customized = TRUE) { Chris@0: $this->customized = $customized ? LOCALE_CUSTOMIZED : LOCALE_NOT_CUSTOMIZED; Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function isSource() { Chris@0: return FALSE; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function isTranslation() { Chris@0: return !empty($this->lid) && !empty($this->language) && isset($this->translation); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getString() { Chris@0: return isset($this->translation) ? $this->translation : ''; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function setString($string) { Chris@0: $this->translation = $string; Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function isNew() { Chris@0: return $this->isNew; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function save() { Chris@0: parent::save(); Chris@0: $this->isNew = FALSE; Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function delete() { Chris@0: parent::delete(); Chris@0: $this->isNew = TRUE; Chris@0: return $this; Chris@0: } Chris@0: Chris@0: }