当前位置: 首页>>代码示例>>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;未经允许,请勿转载。