public function modulesForUserAction()
 {
     $params = $this->params();
     $query = $params->fromQuery('query', null);
     $page = (int) $params->fromQuery('page', 1);
     $owner = $params->fromRoute('owner');
     $modules = $this->moduleMapper->pagination($page, 10, $owner, 'created_at', 'DESC');
     return new ViewModel(['modules' => $modules, 'query' => $query]);
 }
 /**
  * RSS feed for recently added modules
  * @return FeedModel
  */
 public function feedAction()
 {
     $url = $this->plugin('url');
     // Prepare the feed
     $feed = new Feed();
     $feed->setTitle('ZF2 Modules');
     $feed->setDescription('Recently added ZF2 modules');
     $feed->setFeedLink($url->fromRoute('feed', [], ['force_canonical' => true]), 'atom');
     $feed->setLink($url->fromRoute('home', [], ['force_canonical' => true]));
     // Get the recent modules
     $page = 1;
     $modules = $this->moduleMapper->pagination($page, self::MODULES_PER_PAGE, null, 'created_at', 'DESC');
     // Load them into the feed
     $mapper = new Mapper\ModuleToFeed($feed, $url);
     $mapper->addModules($modules);
     // Render the feed
     $feedmodel = new FeedModel();
     $feedmodel->setFeed($feed);
     return $feedmodel;
 }
 public function testPaginationMatchesEntitiesWhereAllWordsExist()
 {
     $value = 'foo bar baz qux';
     $query = 'foo baz';
     $module = $this->module();
     $module->setDescription($value);
     $this->mapper->insert($module);
     $moduleFoo = $this->module();
     $moduleFoo->setDescription('foo');
     $this->mapper->insert($moduleFoo);
     $moduleBaz = $this->module();
     $moduleBaz->setDescription('baz');
     $this->mapper->insert($moduleBaz);
     $paginator = $this->mapper->pagination(1, 100, $query);
     /* @var Db\ResultSet\HydratingResultSet $resultSet */
     $resultSet = $paginator->getCurrentItems();
     $this->assertCount(1, $resultSet);
     /* @var Entity\Module $result */
     $result = $resultSet->current();
     $this->assertInstanceOf(Entity\Module::class, $result);
     $this->assertSame($result->getDescription(), $module->getDescription());
 }