public function find(array $params, $onlyActive = true, $all = false) { if (empty($params)) { throw new \Exception('Params cannot be empty.'); } $query = $this->constructQuery($params, $onlyActive); $executableArray = $this->constructExecutableArray($params); $stmt = $this->db()->prepare($query); $stmt->execute($executableArray); $block = $stmt->fetch(\PDO::FETCH_OBJ, $all); if ($all) { $blocks = []; foreach ($block as $b) { $blocks[] = BlockFactory::make($b); } usort($blocks, function ($a, $b) { return strcasecmp($a->getPageTitle(), $b->getPageTitle()); }); return $blocks; } return BlockFactory::make($block); }
private function getBlocksByActiveStatus($active = false) { $blocksRepository = Injector::call('\\Nanozen\\Repositories\\BlockRepository'); $blocks = $blocksRepository->all($active); $blocksRepository = []; foreach ($blocks as $block) { $blocksRepository[] = BlockFactory::make($block); } return $blocksRepository; }