flexible-shipping
/
vendor_prefixed
/
wpdesk
/
wp-plugin-flow-common
/
src
/
Initialization
/
Simple
/
SimpleFactory.php
flexible-shipping
/
vendor_prefixed
/
wpdesk
/
wp-plugin-flow-common
/
src
/
Initialization
/
Simple
Last commit date
SimpleFactory.php
2 weeks ago
SimpleFreeStrategy.php
2 weeks ago
SimplePaidStrategy.php
2 weeks ago
SimpleFactory.php
40 lines
| 1 | <?php |
| 2 | |
| 3 | namespace FSVendor\WPDesk\Plugin\Flow\Initialization\Simple; |
| 4 | |
| 5 | use FSVendor\WPDesk\Plugin\Flow\Initialization\InitializationFactory; |
| 6 | use FSVendor\WPDesk\Plugin\Flow\Initialization\InitializationStrategy; |
| 7 | /** |
| 8 | * Can decide if strategy is for free plugin or paid plugin |
| 9 | */ |
| 10 | class SimpleFactory implements InitializationFactory |
| 11 | { |
| 12 | /** @var bool */ |
| 13 | private $free; |
| 14 | /** @var bool */ |
| 15 | private $tracker_enabled; |
| 16 | /** |
| 17 | * @param bool $free True for free/repository plugin |
| 18 | * @param bool $tracker_enabled True when tracker should be initialized |
| 19 | */ |
| 20 | public function __construct($free = \false, $tracker_enabled = \true) |
| 21 | { |
| 22 | $this->free = $free; |
| 23 | $this->tracker_enabled = $tracker_enabled; |
| 24 | } |
| 25 | /** |
| 26 | * Create strategy according to the given flag |
| 27 | * |
| 28 | * @param \WPDesk_Plugin_Info $info |
| 29 | * |
| 30 | * @return InitializationStrategy |
| 31 | */ |
| 32 | public function create_initialization_strategy(\FSVendor\WPDesk_Plugin_Info $info) |
| 33 | { |
| 34 | if ($this->free) { |
| 35 | return new SimpleFreeStrategy($info, $this->tracker_enabled); |
| 36 | } |
| 37 | return new SimplePaidStrategy($info); |
| 38 | } |
| 39 | } |
| 40 |