Skip to content

Commit

Permalink
Merge pull request #4 from Invertus/feature/demo-reusability
Browse files Browse the repository at this point in the history
loaded web component code
  • Loading branch information
tomas862 authored Nov 27, 2023
2 parents ba34a43 + baa1fb3 commit 185f5f1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
14 changes: 12 additions & 2 deletions prestashopdevcon.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,22 @@ public function install()
&& $this->registerHook('displayHome')
&& $this->registerHook('displayCheckoutSummaryTop')
&& $this->registerHook('actionDispatcherBefore')
&& $this->registerHook('displayShoppingCartFooter');
&& $this->registerHook('displayShoppingCartFooter')
&& $this->registerHook('header');
}

public function get($serviceName)
{
return (new ServiceProvider())->getService($serviceName);
}

public function hookHeader()
{
return $this->context->smarty->fetch(
"{$this->getLocalPath()}/views/templates/header.tpl"
);
}

public function hookActionDispatcherBefore()
{
include_once _PS_MODULE_DIR_ . $this->name . '/' . "vendor/autoload.php";
Expand All @@ -36,7 +44,9 @@ public function hookActionDispatcherBefore()

public function hookDisplayHome()
{
return "Hello from {$this->name}!";
return $this->context->smarty->fetch(
"{$this->getLocalPath()}/views/templates/home.tpl"
);
}

public function hookDisplayCheckoutSummaryTop()
Expand Down
1 change: 1 addition & 0 deletions views/templates/header.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script type="module" src="https://cdn.skypack.dev/invertus-prestashopdevcon2023-sample"></script>
3 changes: 3 additions & 0 deletions views/templates/home.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<inv-counter>
This button is loaded using web components. Your number is:
</inv-counter>

0 comments on commit 185f5f1

Please sign in to comment.