Ejemplo n.º 1
0
 protected function _delete_route($route, $style_id)
 {
     $entity = $this->route_mapper->load(array('route' => $route, 'style' => $style_id));
     if ($entity) {
         $this->route_mapper->delete($entity);
     }
 }
Ejemplo n.º 2
0
 protected function _update_or_remove(\blitze\sitemaker\model\blocks\entity\route $entity, array $route_prefs)
 {
     // route has blocks, so update it
     if ($this->_route_has_blocks($entity)) {
         $this->_update_route($entity, $route_prefs);
     } else {
         $this->route_mapper->delete($entity);
     }
 }
Ejemplo n.º 3
0
 protected function _update_route(array $blocks_to_update, $route_entity)
 {
     $has_blocks = sizeof($blocks_to_update) ? true : false;
     if (!$has_blocks && !$this->_route_is_customized($route_entity->to_array())) {
         $this->route_mapper->delete($route_entity);
     } else {
         $route_entity->set_has_blocks($has_blocks);
         $this->route_mapper->save($route_entity);
     }
 }
Ejemplo n.º 4
0
 protected function _update_route($blocks_to_update, $route)
 {
     $ex_positions = $route->get_ex_positions();
     $hiding_blocks = $route->get_hide_blocks();
     $has_blocks = sizeof($blocks_to_update) ? true : false;
     if (!$has_blocks && !$hiding_blocks && !sizeof($ex_positions)) {
         $this->route_mapper->delete($route);
     } else {
         $route->set_has_blocks($has_blocks);
         $this->route_mapper->save($route);
     }
 }
 public function execute($style_id)
 {
     $this->route_mapper = $this->mapper_factory->create('blocks', 'routes');
     $route = array('route' => $this->request->variable('route', ''), 'style' => $style_id);
     $route_prefs = array('hide_blocks' => $this->request->variable('hide_blocks', false), 'ex_positions' => array_filter($this->request->variable('ex_positions', array(0 => ''))));
     // user has made choices that differ from defaults
     if ($this->_route_is_customized($route_prefs)) {
         // create/update route regardless of whether it has blocks or not
         $entity = $this->_force_get_route($route);
         $this->_update_route($entity, $route_prefs);
     } else {
         if ($entity = $this->route_mapper->load($route)) {
             // route has blocks, so update it
             if ($this->_route_has_blocks($entity)) {
                 $this->_update_route($entity, $route_prefs);
             } else {
                 $this->route_mapper->delete($entity);
             }
         }
     }
     return array('message' => $this->user->lang('ROUTE_UPDATED'));
 }