Theme::update PHP Method

update() public method

When updating a theme, run the attributes through a validator first.
public update ( array $attributes = [], array $options = [] ) : void
$attributes array
$options array
return void
    public function update(array $attributes = array(), array $options = array())
    {
        // App::make('Components\\ThemeManager\\Validation\\ThemeValidator')->validateForUpdate($attributes);
        $attributes['updated_by'] = current_user()->id;
        return parent::update($attributes);
    }

Usage Example

Example #1
0
 public function processUpdate()
 {
     if (Tools::getIsset('id_theme') && Tools::getIsset('name') && Tools::getIsset('directory')) {
         $theme = new Theme((int) Tools::getValue('id_theme'));
         $theme->name = Tools::getValue('name');
         $theme->directory = Tools::getValue('directory');
         $theme->default_left_column = Tools::getValue('default_left_column');
         $theme->default_right_column = Tools::getValue('default_right_column');
         $nb_product_per_page = (int) Tools::getValue('product_per_page');
         if ($nb_product_per_page == 0) {
             $nb_product_per_page = 1;
         }
         $theme->product_per_page = $nb_product_per_page;
         if ($this->context->shop->id_theme == (int) Tools::getValue('id_theme')) {
             Configuration::updateValue('PS_PRODUCTS_PER_PAGE', $nb_product_per_page);
         }
         if (isset($_FILES['image_preview']) && $_FILES['image_preview']['error'] == 0) {
             if (@getimagesize($_FILES['image_preview']['tmp_name']) && !ImageManager::validateUpload($_FILES['image_preview'], 300000)) {
                 move_uploaded_file($_FILES['image_preview']['tmp_name'], _PS_ALL_THEMES_DIR_ . $theme->directory . '/preview.jpg');
             } else {
                 $this->errors[] = $this->l('Image not valid');
                 $this->display = 'form';
                 return false;
             }
         }
         $theme->update();
     }
     Tools::redirectAdmin(Context::getContext()->link->getAdminLink('AdminThemes') . '&conf=29');
 }
All Usage Examples Of Theme::update