/**
  * Display a list of mappings
  *
  * @param Network_Mapping[] $mappings Mapping objects to show
  * @param array $options
  */
 protected function display($mappings, $options)
 {
     $defaults = array('format' => 'table', 'fields' => array('id', 'domain', 'network', 'active'));
     $options = wp_parse_args($options, $defaults);
     $mapper = function (Network_Mapping $mapping) {
         $data = array('id' => (int) $mapping->get_id(), 'domain' => $mapping->get_domain(), 'network' => (int) $mapping->get_network_id(), 'active' => $mapping->is_active() ? __('Active', 'mercator') : __('Inactive', 'mercator'));
         return apply_filters('mercator.cli.mapping.fields', $data, $mapping);
     };
     $display_items = Utils\iterator_map($mappings, $mapper);
     $formatter = new Formatter($options);
     $formatter->display_items($display_items);
 }
Пример #2
0
 /**
  * Display items via the formatter
  *
  * @param array $items
  * @param array $assoc_args
  */
 protected function display_items($items, $assoc_args)
 {
     if (empty($assoc_args['format'])) {
         $assoc_args['format'] = 'table';
     }
     if ($assoc_args['format'] !== 'json') {
         $items = \WP_CLI\Utils\iterator_map($items, function ($post) {
             $data = $post->getRawData();
             return $data;
         });
     } else {
         $items = \WP_CLI\Utils\iterator_map($items, function ($post) {
             return $post->getRawData();
         });
     }
     $this->obj_fields = array('ID', 'title', 'slug', 'date', 'status');
     $formatter = $this->get_formatter($assoc_args);
     $formatter->display_items($items);
 }
Пример #3
0
 /**
  * Display items via the formatter
  *
  * @param array $items
  * @param array $assoc_args
  */
 protected function display_items($items, $assoc_args)
 {
     if (empty($assoc_args['format'])) {
         $assoc_args['format'] = 'table';
     }
     if ($assoc_args['format'] !== 'json') {
         $items = \WP_CLI\Utils\iterator_map($items, function ($user) {
             $data = $user->getRawData();
             unset($data['meta']);
             $data['roles'] = implode(',', $data['roles']);
             if (!empty($data['capabilities'])) {
                 $data['capabilities'] = array_filter($data['capabilities']);
                 $data['capabilities'] = implode(',', array_keys($data['capabilities']));
             }
             return $data;
         });
     } else {
         $items = \WP_CLI\Utils\iterator_map($items, function ($user) {
             return $user->getRawData();
         });
     }
     $this->obj_fields = array('ID', 'username', 'name', 'email', 'roles');
     $formatter = $this->get_formatter($assoc_args);
     $formatter->display_items($items);
 }