Skip to content

Commit 475db66

Browse files
committed
code optimizations and readme
1 parent 087ebbf commit 475db66

File tree

10 files changed

+70
-12013
lines changed

10 files changed

+70
-12013
lines changed

Readme.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,51 @@
1-
# Open Saas Core
1+
# Override default php module Prestashop behaviours
2+
3+
Are you searching for a method that let you override php modules behaviours of Prestashop?
4+
5+
---
6+
7+
## Module Download
8+
9+
➡️ [Last release download](https://replaceme)
10+
11+
---
12+
13+
## What this module do
14+
15+
This module let you override every module .php files you want in your shop.
16+
17+
Native Prestashop override system, only let you override default .js and .tpl files via themes/modules sub-folders, or default Prestashop classes via override folder.
18+
19+
Thats way I decided to create a module that let you to override .php files too!
20+
21+
Sometimes you want to replace specific module behaviours and you don't want to touch original code, this module let you do exactly that!
22+
23+
---
24+
25+
## How it works
26+
27+
1. Download and install last module release
28+
2. Create a module structure you need to override inside the *module_overrides* folder, following the schema (You will duplicate existing sample as starter point)
29+
30+
```
31+
- module_name
32+
- module_version
33+
- .override
34+
- file_to_override_2.php
35+
- file_to_override_1.php
36+
- src
37+
- class_to_override.php
38+
```
39+
3. Go to module configuration page and switch from Active/Inactive override.
40+
41+
<span style="color:#ff4444">.override</span> file is mandatory and contain the override state.
42+
43+
The module automatically detect if is your first override and create *.original* file version that is used in case you want to reverse the changes.
44+
45+
Note that you will see only overrides of modules you have installed of the specific version you want to override.
46+
47+
---
48+
49+
## Report a bug
50+
51+
Please open an issue if you found a bug.

module_override.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ public function getContent()
101101
return $output;
102102
}
103103

104+
public function existOriginal($item)
105+
{
106+
return file_exists($item.".original");
107+
}
108+
109+
public function createOriginal($item)
110+
{
111+
file_put_contents($item.".original", file_get_contents($item));
112+
}
104113

105114
protected function toggleOverride()
106115
{
@@ -125,6 +134,7 @@ protected function toggleOverride()
125134
if(strpos($item, ".override") !== false) continue;
126135
if($new_overriden){
127136
if(strpos($item, ".original") !== false) continue;
137+
if(!$this->existOriginal($item)) $this->createOriginal($item);
128138
}else{
129139
if(strpos($item, ".original") === false) continue;
130140
$sub_path = str_replace(".original", "", $sub_path);

module_overrides/amazzingfilter/3.1.9/.override

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)