generated from baraja-core/template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
740721e
commit 75d97cb
Showing
6 changed files
with
103 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Template | ||
======== | ||
Shop | ||
==== | ||
|
||
This is a template package. | ||
Common shop description and meta package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
extensions: | ||
shop: Baraja\Shop\ShopExtension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Baraja\Shop; | ||
|
||
|
||
use Nette\DI\CompilerExtension; | ||
|
||
final class ShopExtension extends CompilerExtension | ||
{ | ||
public function beforeCompile(): void | ||
{ | ||
$builder = $this->getContainerBuilder(); | ||
// OrmAnnotationsExtension::addAnnotationPathToManager($builder, 'Baraja\Shop\Address\Entity', __DIR__ . '/Entity'); | ||
|
||
$builder->addDefinition($this->prefix('shopInfo')) | ||
->setFactory(ShopInfo::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Baraja\Shop; | ||
|
||
|
||
use Baraja\DynamicConfiguration\Configuration; | ||
use Baraja\DynamicConfiguration\ConfigurationSection; | ||
|
||
final class ShopInfo | ||
{ | ||
private ConfigurationSection $configuration; | ||
|
||
|
||
public function __construct(Configuration $configuration) | ||
{ | ||
$this->configuration = $configuration->getSection('shop'); | ||
} | ||
|
||
|
||
public function getShopName(): string | ||
{ | ||
$name = $this->configuration->get('name'); | ||
if ($name === null) { | ||
throw new \LogicException('Shop name must exist.'); | ||
} | ||
|
||
return $name; | ||
} | ||
|
||
|
||
public function getDefaultManufacturer(): string | ||
{ | ||
return $this->configuration->get('default-manufacturer') ?? $this->getShopName(); | ||
} | ||
|
||
|
||
public function getShopDescription(): ?string | ||
{ | ||
return $this->configuration->get('description'); | ||
} | ||
|
||
|
||
public function getContactPersonName(): ?string | ||
{ | ||
return $this->configuration->get('contact-person-name'); | ||
} | ||
|
||
|
||
public function getSupportEmail(): ?string | ||
{ | ||
return $this->configuration->get('support-email'); | ||
} | ||
|
||
|
||
public function getOrderEmail(): ?string | ||
{ | ||
return $this->configuration->get('order-email') ?? $this->getSupportEmail(); | ||
} | ||
|
||
|
||
public function getSupportPhone(): ?string | ||
{ | ||
return $this->configuration->get('support-phone'); | ||
} | ||
|
||
|
||
public function getBankAccount(): ?string | ||
{ | ||
return $this->configuration->get('bank-account'); | ||
} | ||
} |