elements = $elements; $this->basket_name = (string) $basket_name; $this->translators = $translators; $this->deadline = $deadline; } /** * @return WPML_TM_Translation_Batch_Element[] */ public function get_elements() { return $this->elements; } public function add_element( WPML_TM_Translation_Batch_Element $element ) { $this->elements[] = $element; } /** * @param string $type * * @return WPML_TM_Translation_Batch_Element[] */ public function get_elements_by_type( $type ) { $result = array(); foreach ( $this->get_elements() as $element ) { if ( $element->get_element_type() === $type ) { $result[] = $element; } } return $result; } /** * @return string */ public function get_basket_name() { return $this->basket_name; } /** * @return array */ public function get_translators() { return $this->translators; } public function get_translator( $lang ) { return $this->translators[ $lang ]; } /** * @return DateTime */ public function get_deadline() { return $this->deadline; } /** * @return array */ public function get_target_languages() { $result = array(); foreach ( $this->get_elements() as $element ) { $result[] = array_keys( $element->get_target_langs() ); } return array_values( array_unique( call_user_func_array( 'array_merge', $result ) ) ); } /** * @return array */ public function get_remote_target_languages() { return array_values( array_filter( $this->get_target_languages(), array( $this, 'is_remote_target_language', ) ) ); } private function is_remote_target_language( $lang ) { return isset( $this->translators[ $lang ] ) && ! is_numeric( $this->translators[ $lang ] ); } /** * @return array */ public function get_batch_options() { return array( 'basket_name' => $this->get_basket_name(), 'deadline_date' => $this->get_deadline() ? $this->get_deadline()->format( 'Y-m-d' ) : '', ); } }