當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Base::asApiArray方法代碼示例

本文整理匯總了PHP中Base::asApiArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP Base::asApiArray方法的具體用法?PHP Base::asApiArray怎麽用?PHP Base::asApiArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Base的用法示例。


在下文中一共展示了Base::asApiArray方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: asApiArray

 public function asApiArray($args = array())
 {
     $attributes = parent::asApiArray();
     if (isset($attributes['metadata'])) {
         $upload_dir = wp_get_attachment_image_src($this->_actual_model_id, 'full');
         $md = $attributes['metadata'];
         if (!is_array($md)) {
             $md = array();
         }
         $md['url'] = $upload_dir[0];
         $attributes['metadata'] = $md;
         if (isset($attributes['metadata']['sizes']) && is_array($attributes['metadata']['sizes'])) {
             foreach ($attributes['metadata']['sizes'] as $key => &$md) {
                 // $upload_dir = wp_get_attachment_image_src( $this->_actual_model_id, $key);
                 // $md['url'] = $upload_dir[0];
                 $medium_array = image_downsize($this->_actual_model_id, $key);
                 $md['url'] = $medium_array[0];
                 if (isset($md['get_attachment_metadata is'])) {
                     unset($md['get_attachment_metadata is']);
                 }
                 if (isset($md['array is'])) {
                     unset($md['array is']);
                 }
                 //$md['array is'] = $medium_array;
                 //$md['get_attachment_metadata is'] = wp_get_attachment_metadata($this->_actual_model_id);
             }
         }
     }
     return $attributes;
 }
開發者ID:borisdiakur,項目名稱:woocommerce-json-api,代碼行數:30,代碼來源:Image.php

示例2: asApiArray

 public function asApiArray($args = array())
 {
     $attrs = parent::asApiArray();
     $attrs['order_items'] = $this->order_items;
     $attrs['notes'] = $this->notes;
     $attrs['tax_items'] = $this->tax_items;
     $attrs['coupon_items'] = $this->coupon_items;
     return $attrs;
 }
開發者ID:borisdiakur,項目名稱:woocommerce-json-api,代碼行數:9,代碼來源:Order.php

示例3: asApiArray

 public function asApiArray($args = array())
 {
     $attributes_to_send = parent::asApiArray();
     $attributes_to_send['metadata'] = get_metadata('order_item', $this->_actual_model_id, '', false);
     foreach ($attributes_to_send['metadata'] as $key => &$value) {
         $value = $value[0];
     }
     if (isset($attributes_to_send['metadata']['_variation_id']) && !empty($attributes_to_send['metadata']['_variation_id'])) {
         $pid = $attributes_to_send['metadata']['_variation_id'];
     } else {
         if (isset($attributes_to_send['metadata']['_product_id'])) {
             $pid = $attributes_to_send['metadata']['_product_id'];
         }
     }
     if (isset($pid)) {
         $product = Product::find($pid);
         if ($product->isValid()) {
             $attributes_to_send['product'] = $product->asApiArray();
         } else {
             $attributes_to_send['product'] = null;
         }
     }
     return $attributes_to_send;
 }
開發者ID:borisdiakur,項目名稱:woocommerce-json-api,代碼行數:24,代碼來源:OrderItem.php

示例4: asApiArray

 public function asApiArray($args = array())
 {
     include WCAPIDIR . "/_globals.php";
     $attributes_to_send = parent::asApiArray($args);
     if (!isset($args['include']) || !is_array($args['include'])) {
         $args['include'] = array();
     }
     foreach (array('categories', 'tags', 'reviews', 'variations', 'images', 'featured_image') as $assoc) {
         if (!isset($args['include'][$assoc])) {
             $args['include'][$assoc] = true;
         }
         if ($args['include'][$assoc] == true) {
             $attributes_to_send[$assoc] = $this->{$assoc};
         }
     }
     if ($attributes_to_send['type'] == 'product_variation' && empty($attributes_to_send['featured_image'])) {
         $parent_product = Product::find($attributes_to_send['parent_id']);
         if ($parent_product->isValid()) {
             $attributes_to_send['featured_image'] = $parent_product->featured_image;
         }
     }
     // $attributes_to_send['categories'] = $this->categories;
     // $attributes_to_send['tags'] = $this->tags;//wp_get_post_terms($this->_actual_model_id,'product_tag');
     // $attributes_to_send['reviews'] = $this->reviews;
     // $attributes_to_send['variations'] = $this->variations;
     // $attributes_to_send['images'] = $this->images;
     // $attributes_to_send['featured_image'] = $this->featured_image;
     if (is_array($attributes_to_send['attributes'])) {
         $has_string_keys = false;
         foreach ($attributes_to_send['attributes'] as $k => $v) {
             if (is_string($k)) {
                 $has_string_keys = true;
                 break;
             }
         }
         if (!$has_string_keys) {
             $attributes_to_send['attributes'] = new \stdClass();
         }
     } else {
         if (is_string($attributes_to_send['attributes'])) {
             $attributes_to_send['attributes'] = new \stdClass();
         }
     }
     return $attributes_to_send;
 }
開發者ID:borisdiakur,項目名稱:woocommerce-json-api,代碼行數:45,代碼來源:Product.php


注:本文中的Base::asApiArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。