示例#1
0
 /**
  * Convert an array of Wordpress term objects to array of Term objects.
  *
  * @param  \stdClass[]                  $terms    Wordpress term objects
  * @param  \Tev\Taxonomy\Model\Taxonomy $taxonomy Parent taxonomy
  * @return \Tev\Term\Model\Term[]                 Term objects
  */
 private function convertTermsArray($terms, Taxonomy $taxonomy)
 {
     $res = array();
     foreach ($terms as $t) {
         $res[] = $this->termFactory->create($t, $taxonomy);
     }
     return $res;
 }
示例#2
0
 /**
  * Return array of direct child terms of this term.
  *
  * @return \Tev\Term\Model\Term[]
  */
 public function getChildren()
 {
     $children = array();
     $wpTerms = get_terms($this->taxonomy->getName(), array('hide_empty' => false, 'parent' => (int) $this->getId()));
     foreach ($wpTerms as $termData) {
         $children[] = $this->termFactory->create($termData, $this->taxonomy);
     }
     return $children;
 }
示例#3
0
 /**
  * Get Term or array of Terms.
  *
  * @return \Tev\Term\Model\Term|\Tev\Term\Model\Term[]|null
  */
 public function getValue()
 {
     $terms = $this->base['value'];
     if (is_array($terms)) {
         $ret = array();
         foreach ($terms as $t) {
             $ret[] = $this->termFactory->create($t, $this->taxonomy());
         }
         return $ret;
     } elseif (is_object($terms)) {
         return $this->termFactory->create($terms, $this->taxonomy());
     } else {
         if ($this->base['multiple'] || $this->base['field_type'] === 'multi_select' || $this->base['field_type'] === 'checkbox') {
             return array();
         } else {
             return null;
         }
     }
 }