public function save() { $containers = $this->request->post('containers'); $this->request->post('containers', array()); $page_block_template_id = $this->request->param('id'); Model_Page_Block_Template_Container::save_template($page_block_template_id, $containers); parent::save(); }
public static function save_template($page_block_template_id, $containers = NULL) { $ids = Model_Page_Block_Template_Container::container_ids($page_block_template_id); $has_containers = $containers and is_array($containers); if ($has_containers) { foreach ($containers as $container_id) { $exists = in_array($container_id, $ids); if (!$exists) { $model = Model_Page_Block_Template_Container::factory('Page_Block_Template_Container'); $model->container_id = $container_id; $model->page_block_template_id = $page_block_template_id; $model->create(); } } } foreach ($ids as $container_id) { if (!$has_containers or !in_array($container_id, $containers)) { Model_Page_Block_Template_Container::remove_template($page_block_template_id, $container_id); } } }