/** * @param RequestInterface $request A PSR-7 compatible Request instance. * @param ResponseInterface $response A PSR-7 compatible Response instance. * @return ResponseInterface */ public function run(RequestInterface $request, ResponseInterface $response) { unset($request); $climate = $this->climate(); $climate->underline()->out('List objects'); $this->setData(['obj_type' => $this->argOrInput('obj-type'), 'page' => $climate->arguments->get('page'), 'num_per_page' => $climate->arguments->get('num')]); $model = $this->modelFactory()->create($this->objType()); $loader = new CollectionLoader(['logger' => $this->logger, 'factory' => $this->modelFactory()]); $loader->setModel($model); $loader->setPagination(['page' => $this->page(), 'num_per_page' => $this->numPerPage()]); $collection = $loader->load(); $collection = $this->collection(); $table = []; $rows = $this->objectRows(); foreach ($collection as $c) { $obj = []; $props = $model->properties(); foreach ($props as $property_ident => $unused) { $prop = $c->p($property_ident); $label = (string) $prop->label(); $val = (string) $prop->displayVal(); $obj[$label] = $val; } $table[] = $obj; } $climate->table($table); return $response; }