/** * Test fetching results from a qurey with a two custom formatters * * @return void */ public function testQueryWithStackedFormatters() { $table = TableRegistry::get('authors'); $query = new Query($this->connection, $table); $query->select()->formatResults(function ($results) { $this->assertInstanceOf('Cake\\ORM\\ResultSet', $results); return $results->indexBy('id'); }); $query->formatResults(function ($results) { return $results->extract('name'); }); $expected = [1 => 'mariano', 2 => 'nate', 3 => 'larry', 4 => 'garrett']; $this->assertEquals($expected, $query->toArray()); }
/** * Get allowed cache key. * * @param Query $actions * @param Aro $aro * @return string */ protected function _getAllowedCacheKey(Query $actions, Aro $aro) { $key = implode('_', ['allowed_role-' . $aro->get('id'), 'user-' . $this->_user->get('id', Role::PUBLIC_ID), 'acos-' . implode('-', array_keys($actions->toArray()))]); if (!Configure::read('debug')) { return md5($key); } return $key; }