__construct() публичный Метод

public __construct ( array $elements = [], array $args = [] )
$elements array
$args array
Пример #1
0
 /**
  * @param array $posts
  * @param array $args
  */
 function __construct($posts, $args = array())
 {
     if (isset($posts) && is_array($posts)) {
         $args = wp_parse_args($args, array('list_owner' => 'WPLib_Posts'));
         /**
          * @var WPLib_Posts $list_owner
          */
         $list_owner = $args['list_owner'];
         foreach ($posts as $index => $post) {
             $posts[$index] = $list_owner::make_new_item($post, $args);
         }
     }
     parent::__construct($posts, $args);
 }
Пример #2
0
 /**
  * @param array $posts
  * @param array $args
  */
 function __construct($posts, $args = array())
 {
     if (isset($posts) && is_array($posts)) {
         $args = wp_parse_args($args, array('list_owner' => false));
         /**
          * @var WPLib_Posts $list_owner
          */
         $list_owner = $args['list_owner'];
         if (!$list_owner) {
             foreach ($posts as $index => $post) {
                 $posts[$index] = $list_owner::make_new_item($post, $args);
             }
         } else {
             foreach ($posts as $index => $post) {
                 $list_owner = $args['list_owner'] = WPLib_Posts::get_post_type_class($post->post_type);
                 $posts[$index] = $list_owner::make_new_item($post, $args);
             }
         }
     }
     parent::__construct($posts, $args);
 }