-
Notifications
You must be signed in to change notification settings - Fork 9
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
Jorr.it
committed
Oct 5, 2021
1 parent
f4416fe
commit 5ef44cb
Showing
12 changed files
with
147 additions
and
95 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
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
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
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,93 @@ | ||
<?php | ||
|
||
/* | ||
* Nexxus Stock Keeping (online voorraad beheer software) | ||
* Copyright (C) 2018 Copiatek Scan & Computer Solution BV | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see licenses. | ||
* | ||
* Copiatek - [email protected] - Postbus 547 2501 CM Den Haag | ||
*/ | ||
|
||
/* | ||
* This file is taken from the Symfony WebpackEncoreBundle package. | ||
* by Fabien Potencier <[email protected]> | ||
*/ | ||
|
||
namespace AppBundle\Helper; | ||
|
||
use Twig\Extension\AbstractExtension; | ||
use Twig\TwigFunction; | ||
use Symfony\Component\HttpKernel\KernelInterface; | ||
|
||
class EncoreTwigExtension extends AbstractExtension | ||
{ | ||
private $relativeBuildPath = "/js/build/"; | ||
|
||
public function getName() | ||
{ | ||
return "app.encoretwig"; | ||
} | ||
|
||
public function getFunctions(): array | ||
{ | ||
return [ | ||
new TwigFunction('encore_entry_js_files', [$this, 'getWebpackJsFiles']), | ||
new TwigFunction('encore_entry_css_files', [$this, 'getWebpackCssFiles']), | ||
new TwigFunction('encore_entry_script_tags', [$this, 'renderWebpackScriptTags'], ['is_safe' => ['html']]), | ||
new TwigFunction('encore_entry_link_tags', [$this, 'renderWebpackLinkTags'], ['is_safe' => ['html']]), | ||
]; | ||
} | ||
|
||
public function getWebpackJsFiles(string $entryName): array | ||
{ | ||
return $this->getWebpackFiles($entryName, "js"); | ||
} | ||
|
||
public function getWebpackCssFiles(string $entryName): array | ||
{ | ||
return $this->getWebpackFiles($entryName, "css"); | ||
} | ||
|
||
private function getWebpackFiles(string $entryName, string $fileType): array | ||
{ | ||
$fullpath = dirname(__FILE__) . "/../../../web/" . $this->relativeBuildPath . "entrypoints.json"; | ||
$entrypoints = json_decode(file_get_contents($fullpath), true); | ||
return $entrypoints['entrypoints'][$entryName][$fileType]; | ||
} | ||
|
||
public function renderWebpackScriptTags(string $entryName): string | ||
{ | ||
$tags = array(); | ||
|
||
foreach ($this->getWebpackJsFiles($entryName) as $file) | ||
{ | ||
$tags[] = '<script src="'.$file.'"></script>'; | ||
} | ||
|
||
return implode(PHP_EOL, $tags); | ||
} | ||
|
||
public function renderWebpackLinkTags(string $entryName): string | ||
{ | ||
$tags = array(); | ||
|
||
foreach ($this->getWebpackCssFiles($entryName) as $file) | ||
{ | ||
$tags[] = '<link rel="stylesheet" href="'.$file.'">'; | ||
} | ||
|
||
return implode(PHP_EOL, $tags); | ||
} | ||
} |
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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
<template> | ||
|
||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'App', | ||
data() { | ||
var dataElement = document.querySelector('div#product-stock'); | ||
var products = dataElement.dataset.products; | ||
return { | ||
products | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
|
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,4 @@ | ||
import Vue from 'vue' | ||
import App from './App.vue' | ||
|
||
new Vue({ render: h => h(App) }).$mount('#product-stock') |
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