示例#1
0
 /**
  * Set the translation method
  *
  * @param   string $translationMethod Translation method
  * @param   int    $ordering          Ordering for that translation method
  *
  * @return NenoContentElementTranslation
  */
 public function addTranslationMethod($translationMethod, $ordering = null)
 {
     $translationMethod = NenoHelper::getTranslationMethodById($translationMethod);
     if (!is_array($this->translationMethods) || empty($this->translationMethods)) {
         $this->translationMethods = array($translationMethod);
     } else {
         $found = false;
         foreach ($this->translationMethods as $translationMethodAdded) {
             if ($translationMethodAdded->id === $translationMethod->id) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             if ($ordering === null) {
                 $this->translationMethods[] = $translationMethod;
             } else {
                 array_splice($this->translationMethods, $ordering - 1, 0, $translationMethod);
             }
         }
     }
     return $this;
 }
示例#2
0
文件: job.php 项目: andresmaeso/neno
 /**
  * Constructor
  *
  * @param   mixed $data Data
  */
 public function __construct($data)
 {
     parent::__construct($data);
     if (is_string($this->createdTime)) {
         $this->createdTime = new DateTime($this->createdTime);
     }
     if (!empty($this->translationMethod)) {
         $this->translationMethod = NenoHelper::getTranslationMethodById($this->translationMethod);
     }
 }