/**
  * Constructor
  *
  * @param \phpbb\cache\driver\driver_interface			$cache					Cache driver interface
  * @param \blitze\sitemaker\services\blocks\factory		$block_factory			Blocks factory object
  * @param \blitze\sitemaker\model\mapper_factory		$mapper_factory			Mapper factory object
  */
 public function __construct(\phpbb\cache\driver\driver_interface $cache, \blitze\sitemaker\services\blocks\factory $block_factory, \blitze\sitemaker\model\mapper_factory $mapper_factory)
 {
     $this->cache = $cache;
     $this->block_factory = $block_factory;
     $this->block_mapper = $mapper_factory->create('blocks', 'blocks');
     $this->route_mapper = $mapper_factory->create('blocks', 'routes');
 }
 protected function _force_get_route($route_data, $has_blocks = false)
 {
     $route_mapper = $this->mapper_factory->create('blocks', 'routes');
     if (($route = $route_mapper->load($route_data)) === null) {
         $route_data['has_blocks'] = $has_blocks;
         $entity = $route_mapper->create_entity($route_data);
         $route = $route_mapper->save($entity);
     }
     return $route;
 }
 /**
  * @return array
  */
 protected function get_menu_options()
 {
     $collection = $this->mapper_factory->create('menus', 'menus')->find();
     $options = array();
     foreach ($collection as $entity) {
         $options[$entity->get_menu_id()] = $entity->get_menu_name();
     }
     return $options;
 }
 public function main()
 {
     $menu_id = $this->request->variable('menu_id', 0);
     $menu_mapper = $this->mapper_factory->create('menus', 'menus');
     // Get all menus
     $collection = $menu_mapper->find();
     if ($collection->valid()) {
         $menu = isset($collection[$menu_id]) ? $collection[$menu_id] : $collection->current();
         $menu_id = $menu->get_menu_id();
         foreach ($collection as $entity) {
             $id = $entity->get_menu_id();
             $this->template->assign_block_vars('menu', array('ID' => $id, 'NAME' => $entity->get_menu_name(), 'S_ACTIVE' => $id == $menu_id ? true : false));
         }
     }
     nestedset::load_scripts($this->util);
     $this->util->add_assets(array('js' => array('@blitze_sitemaker/assets/menu/admin.min.js'), 'css' => array('@blitze_sitemaker/assets/menu/admin.min.css')));
     $this->template->assign_vars(array('S_MENU' => true, 'MENU_ID' => $menu_id, 'ICON_PICKER' => $this->icon->picker(), 'T_PATH' => $this->phpbb_root_path, 'UA_MENU_ID' => $menu_id, 'UA_AJAX_URL' => "{$this->phpbb_root_path}app.{$this->php_ext}/menu/admin/"));
     $this->tpl_name = 'acp_menu';
     $this->page_title = 'ACP_MENU';
 }
 /**
  * @return array|mixed
  */
 protected function _get_all_routes()
 {
     if (($all_routes = $this->cache->get('sitemaker_block_routes')) === false) {
         $route_mapper = $this->mapper_factory->create('blocks', 'routes');
         $collection = $route_mapper->find();
         $all_routes = array();
         foreach ($collection as $entity) {
             $route = $entity->get_route();
             $style = $entity->get_style();
             $all_routes[$style][$route] = $entity->to_array();
         }
         $this->cache->put('sitemaker_block_routes', $all_routes);
     }
     return $all_routes;
 }