/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/system/libraries/drivers/Cache/Apcu.php
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* apcu-based Cache driver.
*
* $Id: apcu.php 4046 2009-03-05 19:23:29Z Shadowhand $
*
* @package Cache
* @author Kohana Team
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class Cache_Apcu_Driver implements Cache_Driver {
private $prefix;
public function __construct($prefix)
{
if ( ! extension_loaded('apcu'))
throw new Kohana_Exception('cache.extension_not_loaded', 'apcu');
$this->prefix = $prefix;
}
public function get($id)
{
$value = apcu_fetch($this->create_key($id));
if( $value === false )
{
return null;
}
return $value;
}
public function set($id, $data, ?array $tags, $lifetime)
{
if ( ! empty($tags))
{
logger()->error('Cache: tags are unsupported by the apcu driver');
Arguments
"cache.extension_not_loaded"
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/system/libraries/Cache.php
$config += Kohana::config('cache.default');
}
else
{
// Load the default group
$config = Kohana::config('cache.default');
}
// Cache the config in the object
$this->config = $config;
// Set driver name
$driver = 'Cache_'.ucfirst($this->config['driver']).'_Driver';
// Load the driver
if ( ! Kohana::auto_load($driver))
throw new Kohana_Exception('core.driver_not_found', $this->config['driver'], get_class($this));
// Initialize the driver
$this->driver = new $driver($this->config['params']);
// Validate the driver
if ( ! ($this->driver instanceof Cache_Driver))
throw new Kohana_Exception('core.driver_implements', $this->config['driver'], get_class($this), 'Cache_Driver');
logger()->debug('Cache Library initialized');
if (Cache::$loaded !== TRUE)
{
$this->config['requests'] = (int) $this->config['requests'];
if ($this->config['requests'] > 0 AND mt_rand(1, $this->config['requests']) === 1)
{
// Do garbage collection
$this->driver->delete_expired();
logger()->debug('Cache: Expired caches deleted.');
}
// Cache has been loaded once
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/system/libraries/Cache.php
protected static $loaded;
// Configuration
protected $config;
// Driver object
protected $driver;
/**
* Returns a singleton instance of Cache.
*
* @param string configuration [apc | apcu | eacclerator | file | memcache | sqlite | xcache]
* @return Cache_Core
*/
public static function & instance($config = FALSE)
{
if ( ! isset(Cache::$instances[$config]))
{
// Create a new instance
Cache::$instances[$config] = new Cache($config);
}
return Cache::$instances[$config];
}
/**
* Loads the configured driver and validates it.
*
* @param array|string custom configuration or config group name
* @return void
*/
public function __construct($config = FALSE)
{
if (is_string($config))
{
$name = $config;
// Test the config group name
if (($config = Kohana::config('cache.'.$config)) === NULL)
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/modules/core/libraries/CacheListing.php
/**
* @param "update"|null $action
*
* @return array<int,Setting_Model>
*
* @throws Kohana_Exception
*/
public static function settings($action = null)
{
if ($action == 'update') {
self::$_settings = null;
Cache::instance('apcu')->set('settings', self::$_settings);
}
if (self::$_settings !== null) {
return self::$_settings;
}
$settings = Cache::instance('apcu')->get('settings');
if ($settings !== null) {
self::$_settings = $settings;
return self::$_settings;
}
$select_settings = ORM::factory('setting')->orderby('name', 'ASC')->find_all();
foreach ($select_settings as $setting) {
self::$_settings[ $setting->id ] = $setting;
}
Cache::instance('apcu')->set('settings', self::$_settings);
return self::$_settings;
}
/**
* @param int|string|null $setting_id Typicky states.setting_id, který je nullovatelný.
*
* @return Setting_Model
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/modules/core/libraries/CacheListing.php
$add = $pre;
}
if (is_string($pre)) {
$add[''] = __('document.select');
}
$return_value = $add;
foreach (self::settings() as $setting) {
$return_value[ $setting->id ] = $setting->name;
}
return $add + $return_value;
}
public static function setting_alias($alias)
{
$setting = null;
$settings = self::settings();
foreach ($settings as $setting_model) {
if ($setting_model->alias == $alias) {
$setting = $setting_model;
}
}
if ($setting === null) {
return self::setting_main();
} else {
return $setting;
}
return false;
}
public static function categories($action = null)
{
if ($action == 'update') {
self::$_categories = null;
Cache::instance('apcu')->set('categories', self::$_categories);
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/modules/core/libraries/Settings.php
if ($alias == null) {
$alias = 'main';
}
if (isset(Settings::$_instances[$alias])) {
return Settings::$_instances[$alias];
}
// Create a new instance
return Settings::$_instances[$alias] = new Settings($alias);
}
/**
* Toto je trida SingleTon, jedina mozna inicializace je pres metodu instance()
* @param string $alias
*/
protected function __construct($alias)
{
$this->_alias = $alias;
//$this->_model = ORM::factory('setting')->where('alias', $alias)->find();
$this->_model = CacheListing::setting_alias($alias);
}
/**
* Jedina mozna inicializace objectu je pres metodu instance()
*/
protected function __clone()
{
}
/**
* Vrátí požadovanou hodnotu z pole dáné instance
* @param string $name
* @return mixed
*/
public function __get($name)
{
return $this->_model->$name;
}
// Při výpisu zboží se bude používat kod dodavatele
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/modules/core/libraries/Settings.php
}
/**
* Returns a SingleTon instance of Settings.
* @param string|null $alias Unikatni nazev nastaveni
* @return Settings
*/
public static function instance($alias = null)
{
// defaultni nastaveni je pod aliasem main
// @todo defaultni nastaveni se bude brat z configu
if ($alias == null) {
$alias = 'main';
}
if (isset(Settings::$_instances[$alias])) {
return Settings::$_instances[$alias];
}
// Create a new instance
return Settings::$_instances[$alias] = new Settings($alias);
}
/**
* Toto je trida SingleTon, jedina mozna inicializace je pres metodu instance()
* @param string $alias
*/
protected function __construct($alias)
{
$this->_alias = $alias;
//$this->_model = ORM::factory('setting')->where('alias', $alias)->find();
$this->_model = CacheListing::setting_alias($alias);
}
/**
* Jedina mozna inicializace objectu je pres metodu instance()
*/
protected function __clone()
{
}
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/modules/core/models/customer.php
}
}
/**
* Vrati zakodovane heslo
* @param string $password
* @return string
*/
public function hash_password($password)
{
return Customer::hash_password($password);
}
/**
* Vrati singleton knihovnu settings pro praci s nastavenim pro uzivatele
* @return Settings
*/
public function settings_instance()
{
return Settings::instance($this->setting_alias);
}
/* tot je mnohem přesnější kvůli daním.
*
*/
public function get_setting_id($delivery_address_id = null, $country = null)
{
$country = strtolower(trim($this->country)); // Pokud je zakaznik cizinec, ale jeho doručení je v česku, tak by se mělo vše řídit českem.
if ($delivery_address_id != null) {
$delivery_address = ORM::factory('delivery_address')->where('id', $delivery_address_id)->find();
if (is_null($delivery_address->state_id)) {
$country = '';
} elseif (trim($delivery_address->state_id) != '') {
$country = strtolower($delivery_address->state_id);
}
}
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/modules/core/models/customer.php
* @throws Kohana_Exception
*/
public function vat($vat_type = null)
{
// Pokud je zakaznik osvobozen od DPH, pak ma DPH vzdy 0
if ($this->is_vat_free()) {
return 0;
}
switch ($vat_type) {
case 'none':
case 'zero':
return 0;
case 'low':
return (int) $this->low_vat();
case 'hi':
case 'hight':
return (int) $this->hi_vat();
default:
return $this->settings_instance()->default_vat();
}
}
public function get_setting($value = '')
{
if ($value != '') {
if ($this->country == '') {
$this->country = 'cz';
}
$state = ORM::factory('state')->where('shortcut', $this->country)->find();
$setting = ORM::factory('setting')->where('alias', $state->setting)->find();
if ($value == -1) {
return $setting;
}
return $setting->$value;
}
/www/hosting/vkrtechnologies.com/shop/vendor/macros/presenter/libraries/PresenterPrice.php
}
// 100 nasobek kvuli halirum
if (! $force_zero && ((int) ($price * 100) === 0)) {
return __('presenter_price.zero_price', [':price' => h($formated_price), ':currency' => h($currency_sign)]);
}
return __('presenter_price.price', [':price' => h($formated_price), ':currency' => h($currency_sign)]);
}
/**
* Vrati vychozi DPH zakaznika koncoveho shopu.
* Parametry zde jsou pouze kvuli nadrazene funkci, takze se zde nevyuzivaji.
* @param type $defaultDPH
* @param type $customer_id
* @return int
*/
public static function getDPH($defaultDPH = null, $customer_id = null)
{
return loggedCustomer()->vat();
}
/**
* Funkce vrati nazev sloupecku s cenou koncoveho zakaznika
*/
public static function getPriceName()
{
return GoodPriceSettings::priceColname(PresenterAcl::instance()->goods_price_setting()->pk());
}
/**
* Funkce vrati nazev sloupecku slevy koncoveho zakaznika
*/
public static function getDiscountName()
{
return GoodPriceSettings::discountColname(PresenterAcl::instance()->goods_price_setting()->pk());
}
/**
/www/hosting/vkrtechnologies.com/shop/vendor/macros/presenter/models/presenter_transport.php
*
* @throws Kohana_Exception
*/
public function price($use_dph = null, $use_exchange = true, $total_price = null, $total_price_without_dph = null, $weight = null, $oversize = null)
{
$presenterPayment = app()->make(PresenterPayment::class);
if ($total_price !== null) {
$price = $presenterPayment->getTransportPrice($this->id, false, $total_price, $oversize ?? false) ?? $presenterPayment->getTransportPrice($this->id, true, $total_price_without_dph, $oversize ?? false);
} else {
$price = $presenterPayment->getBasketTransportPrice($this->id);
}
$weight_price = ($weight !== null) ? $presenterPayment->getTransportWeightPrice($this->id, $weight, $oversize) : $presenterPayment->getBasketTransportWeightPrice($this->id);
if (null === $use_dph) {
$use_dph = (boolean) $this->useDphByDefault($total_price, $total_price_without_dph);
}
$priceCZK = new Money(0, 'CZK');
$dph = PresenterPrice::getDPH();
if ($price !== null) {
$priceCZK = $price->priceAsMoneyCZK($use_dph, $dph)
->assertCurrencyIs('CZK');
}
if ($weight_price !== null) {
$priceCZK = Money::max($priceCZK, $weight_price->priceAsMoneyCZK($use_dph, $dph)->assertCurrencyIs('CZK'));
}
// Zavolame ES pro dodatecnou individualni upravu ceny za posvotne
$esPrice = External_source::basket('presenter_transport_price', $this, [
'price_czk' => $priceCZK,
'basket_price_vat' => $total_price,
'basket_price' => $total_price_without_dph,
'weight' => $weight,
'oversize' => $oversize,
]);
if ($esPrice || $esPrice === 0) {
/www/hosting/vkrtechnologies.com/shop/vendor/macros/presenter/helpers/document_helper_presenter_basket_transport.php
$specification = $this->specification();
switch ($this->type()) {
case 'branch':
return 'Pobočka: ' . ORM::factory('Branch', $this->document()->settings_get('order.branch_id'))->preview();
case 'packeta':
return ($specification && isset($specification['name'])) ? $specification['name'] : '';
case 'dispensing':
return 'Výdejní místo: ' . ORM::factory('payment_transport_specification', $this->document()->settings_get('order.payment_transport_specification_id'))->preview();
}
return parent::description();
}
public function specification()
{
return $this->customerData->getTransportSpecification($this->id());
}
public function price_pc()
{
return $this->model()->price(false, false);
}
}
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/modules/document/helpers/document_helper_item_price.php
*/
protected $_item;
/**
* Cena polozky za jeden kus bez slevy a DPH
* @return DocumentPriceFormat
*/
public function per_piece()
{
$exchange = $this->_item->document()->exchange()->exchange();
return new DocumentPriceFormat($this->per_piece_CZK()->asMoney()->convert(Price::get_currency($exchange), Price::getExchange($exchange)));
}
/**
* Cena polozky za jeden kus v CZK bez slevy a DPH
* @return DocumentPriceFormat
*/
public function per_piece_CZK()
{
return new DocumentPriceFormat($this->_item->price_pc()->assertCurrencyIs('CZK'));
}
/**
* Cena polozky za jeden kus vc. slevy bez DPH
* @return DocumentPriceFormat
*/
public function per_piece_with_discount()
{
$exchange = $this->_item->document()->exchange()->exchange();
// Vypocet ceny se slevou musi probehnout v CZK, protoze i sleva je definovana v CZK
$priceCZK = Price::getPrice($this->per_piece_CZK()->asFloat(), null, null, $this->_item->discount(), null, false);
return new DocumentPriceFormat(decimalToMoney($priceCZK)->convert(Price::get_currency($exchange), Price::getExchange($exchange)));
}
/**
* Cena polozky za jeden kus vc. slevy vc. DPH
*/
public function per_piece_with_vat_with_discount(): DocumentPriceFormat
{
$exchange = $this->_item->document()->exchange()->exchange();
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/modules/document/helpers/document_helper_item_price.php
}
/**
* Cena polozky za jeden kus v CZK bez slevy a DPH
* @return DocumentPriceFormat
*/
public function per_piece_CZK()
{
return new DocumentPriceFormat($this->_item->price_pc()->assertCurrencyIs('CZK'));
}
/**
* Cena polozky za jeden kus vc. slevy bez DPH
* @return DocumentPriceFormat
*/
public function per_piece_with_discount()
{
$exchange = $this->_item->document()->exchange()->exchange();
// Vypocet ceny se slevou musi probehnout v CZK, protoze i sleva je definovana v CZK
$priceCZK = Price::getPrice($this->per_piece_CZK()->asFloat(), null, null, $this->_item->discount(), null, false);
return new DocumentPriceFormat(decimalToMoney($priceCZK)->convert(Price::get_currency($exchange), Price::getExchange($exchange)));
}
/**
* Cena polozky za jeden kus vc. slevy vc. DPH
*/
public function per_piece_with_vat_with_discount(): DocumentPriceFormat
{
$exchange = $this->_item->document()->exchange()->exchange();
$price = Price::getPrice($this->per_piece_with_discount()->asFloat(), null, $this->_item->vat(), null, null, false);
return new DocumentPriceFormat(decimalToMoney($price, Price::get_currency($exchange)));
}
/**
* Cena polozky bez DPH vc. slevy v poctu kusu, ktery byl nastaven
* @return DocumentPriceFormat
*/
public function without_vat()
{
return new DocumentPriceFormat($this->per_piece_with_discount()->asMoney()->multiply($this->_item->count()));
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/modules/document/helpers/document_helper_item_price.php
return new DocumentPriceFormat(decimalToMoney($priceCZK)->convert(Price::get_currency($exchange), Price::getExchange($exchange)));
}
/**
* Cena polozky za jeden kus vc. slevy vc. DPH
*/
public function per_piece_with_vat_with_discount(): DocumentPriceFormat
{
$exchange = $this->_item->document()->exchange()->exchange();
$price = Price::getPrice($this->per_piece_with_discount()->asFloat(), null, $this->_item->vat(), null, null, false);
return new DocumentPriceFormat(decimalToMoney($price, Price::get_currency($exchange)));
}
/**
* Cena polozky bez DPH vc. slevy v poctu kusu, ktery byl nastaven
* @return DocumentPriceFormat
*/
public function without_vat()
{
return new DocumentPriceFormat($this->per_piece_with_discount()->asMoney()->multiply($this->_item->count()));
}
/**
* Cena polozky bez DPH bez slevy v poctu kusu, ktery byl nastaven
* @return DocumentPriceFormat
*/
public function without_vat_without_discount()
{
return new DocumentPriceFormat($this->per_piece()->asMoney()->multiply($this->_item->count()));
}
/**
* Cena polozky vc. DPH a slevy v poctu kusu, ktery byl nastaven
* @return DocumentPriceFormat
*/
public function with_vat()
{
$withoutVat = $this->without_vat();
$priceWithVat = round(Price::getPrice($withoutVat->asFloat(), null, $this->_item->vat(), null, null, false), $this->_item->document()->item_vat_decimals());
return new DocumentPriceFormat(decimalToMoney($priceWithVat, $withoutVat->asMoney()->currency()));
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/modules/document/helpers/document_helper_price.php
* @var \document_helper
*/
protected $_document;
/**
* Cena dokumentu bez DPH
* @return \DocumentPriceFormat
*/
public function without_vat($use_payment_and_transport = true)
{
/** @var Money $price */
$price = $this->_document->items()->reduce(function (Money $carry, document_helper_item $item) {
return $carry->add($item->price()->without_vat()->asMoney());
}, decimalToMoney(0, Price::get_currency($this->_document->exchange()->exchange())));
if ($use_payment_and_transport) {
// Pripocteme cenu za dopravu a dalsi poplatky
foreach ($this->_document->transportItems() as $item) {
$price = $price->add($item->price()->without_vat()->asMoney());
}
}
return new DocumentPriceFormat($price);
}
/**
* Prehled cen vc. DPH rozdelenych dle DPH
* @return array
*/
public function separate_by_vat($use_payment_and_transport = true)
{
// Nejprve se sectou jednotlive ceny bez DPH
// a posleze se vynasobi DPH
$prices = $this->_document->items()->sumByVat(function (document_helper_item $item) {
return $item->price()->without_vat()->asMoney();
});
if ($use_payment_and_transport) {
// Pripocteme cenu za dopravu a dalsi poplatky
foreach ($this->_document->transportItems() as $item) {
/www/hosting/vkrtechnologies.com/shop/vendor/macros/presenter/libraries/PresenterBasket.php
'_basket' => $this->data(),
];
}
/**
* Vrati data predana prohlizeci pro praci s kosikem a zobrazenim jeho aktualniho stavu
*
* @return array{count: int, price: float, priceVat: float, finalPrice: float, finalPriceVat: float, currency: string, currencySign: string, transportId: int|null, paymentId: int|null, transports: array, payments: array, address: array, deliveryAddress: array }
*
* @throws Kohana_Exception
*/
public function data()
{
$handlingFeeItem = $this->documentHelper()->handlingFee();
return [
'count' => $this->count(),
'price' => $this->price()->without_vat(false)->asFloat(),
'priceVat' => $this->price()->with_vat(false)->asFloat(),
'finalPrice' => $this->price()->without_vat(true)->asFloat(),
'finalPriceVat' => $this->price()->with_vat(true)->asFloat(),
'currency' => $this->documentHelper()->exchangeModel()->shortcut,
'currencySign' => $this->documentHelper()->exchangeModel()->get_currency_sign(),
'transportId' => Presenter::basket()->documentHelper()->transport()->id(),
'transports' => array_map(function (Payment_Transport_Model $transport) {
return [
'id' => $transport->id,
'name' => $transport->name,
'type' => $transport->type(),
'price' => moneyToDecimal($transport->price(false)),
'priceVat' => moneyToDecimal($transport->price(true)),
'shipper' => $transport->shipper->alias,
'transportSpecificationChoices' => app(PresenterTransport::class)->transportSpecificationChoices($transport),
'priceZeroDescription' => app(PresenterTransport::class)->freePriceDescription($transport),
'useDphByDefault' => $transport->useDphByDefault(),
];
}, app(PresenterPayment::class)->transports()),
'transportType' => $this->documentHelper()->transport()->type(),
'transportSpecifications' => $this->customerData()->transportSpecifications,
'paymentId' => $this->documentHelper()->payment()->id(),
/www/hosting/vkrtechnologies.com/shop/vendor/macros/presenter/libraries/PresenterBasket.php
}
/**
* Vrati pocet zbozi v kosiku dle nastaveneho parametru good_id
* @param int $good_id Id zbozi
* @return int
*/
public function getItemCountByGoodId($good_id)
{
$item = $this->documentHelper()->items()->find_by_good_id($good_id);
return $item ? $item->count() : 0;
}
public function joinInitScript(?Web $web = null)
{
if (! $web) {
$web = presenter()->web();
}
$web->addInlineScript(' try { PresenterData.basket = ' . json_encode($this->data()) . '; } catch (error) { console.log("No exist PresenterData.basket ") } ');
return $this;
}
/**
* Data pro response pri uprave kosiku, aby se aktualizovali moduly, ktere jsou na nej navazane
* @return array[]
*/
public function ajaxData()
{
return [
'_basket' => $this->data(),
];
}
/**
* Vrati data predana prohlizeci pro praci s kosikem a zobrazenim jeho aktualniho stavu
*
* @return array{count: int, price: float, priceVat: float, finalPrice: float, finalPriceVat: float, currency: string, currencySign: string, transportId: int|null, paymentId: int|null, transports: array, payments: array, address: array, deliveryAddress: array }
*
* @throws Kohana_Exception
/www/hosting/vkrtechnologies.com/shop/vendor/macros/presenter/src/Libraries/Layout.php
return $this;
}
public function render()
{
return $this->build()
->render();
}
protected function init()
{
}
protected function initLayout(\View &$layout)
{
}
protected function initStylesAndScripts()
{
presenter()->basket()->joinInitScript($this->web);
// Na koncovem webu chceme vzdy zobrazit potvrzeni se souhlasem s pouzitim cookies
presenter()->web()->withCookieConsent();
// Google analytics
if ($googleAnalyticsUid = presenter()->config('google_analytics_uid')) {
presenter()->web()->addGoogleAnalytics($googleAnalyticsUid);
}
// Toplist
if ($toplistUid = presenter()->config('toplist_uid')) {
presenter()->web()->addToplist($toplistUid);
}
}
protected function joinFlashMessage()
{
$s = \Session::instance();
if ( ! $s->hasFlash()) {
/www/hosting/vkrtechnologies.com/shop/vendor/macros/presenter/src/Libraries/Layout.php
}
public function set($key, $value = null)
{
if (is_array($key)) {
foreach ($key as $k => $v) {
$this->{$k} = $v;
}
} else {
$this->{$key} = $value;
}
return $this;
}
public function __construct()
{
$this->web = new Web();
$this->initStylesAndScripts();
$this->init();
}
}
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/system/macros/Traits/ContainerTrait.php
* @throws ReflectionException
*/
public function resolveInstance($class, array $args = [])
{
$className = ($class instanceof ReflectionClass) ? $class->getName() : $class;
if (is_scalar($className) && array_key_exists($className, $this->bindings)) {
return $this->call($this->bindings[$className], $args);
}
if (! class_exists($className)) {
throw new \RuntimeException("Class {$className} does not exist");
}
$reflectionClass = ($class instanceof ReflectionClass) ? $class : new ReflectionClass($class);
$constructor = $reflectionClass->getConstructor();
if ($constructor === null) {
return $reflectionClass->newInstance();
}
$params = $this->resolveParams($constructor, $args);
return $reflectionClass->newInstanceArgs($params);
}
/**
* Resolve reflection method arguments
*/
public function resolveParams(ReflectionFunctionAbstract $reflectionFn, array $args = [])
{
$params = [];
foreach ($reflectionFn->getParameters() as $index => $param) {
$arg = null;
if (array_key_exists($param->getName(), $args)) {
$arg = $args[$param->getName()];
} elseif (array_key_exists($index, $args)) {
$arg = $args[$index];
}
$params[] = $this->resolveReflectionParam($param, $arg);
}
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/system/macros/Traits/ContainerTrait.php
*
* @template TObject of object
*
* @param class-string<TObject> $className
* @param array $args
*
* @return TObject
*/
public function make($className, array $args = [])
{
if (isset($this->aliases[$className])) {
return $this->make($this->aliases[$className], $args);
}
if (isset($this->instances[$className])) {
return $this->instances[$className];
}
if (isset($this->singletons[$className])) {
return $this->instances[$className] = $this->singletons[$className]($this, $args);
}
return $this->resolveInstance($className, $args);
}
}
/www/hosting/vkrtechnologies.com/shop/vendor/macros/presenter/src/Provider.php
});
}
private function registerAliases(array $aliases): void
{
foreach ($aliases as $alias => $class) {
$this->app->bind($alias, function () use ($class) {
return $this->app->make($class);
});
}
}
private function registerSingletons(array $singletons): void
{
foreach ($singletons as $name => $class) {
if ($name === $class) {
$this->app->singleton($class);
} else {
$this->app->singleton($name, function () use ($class) {
return $this->app->make($class);
});
}
}
}
}
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/system/macros/Traits/ContainerTrait.php
/**
* Resolve and create new class instance
*
* @template TObject of object
*
* @param class-string<TObject> $className
* @param array $args
*
* @return TObject
*/
public function make($className, array $args = [])
{
if (isset($this->aliases[$className])) {
return $this->make($this->aliases[$className], $args);
}
if (isset($this->instances[$className])) {
return $this->instances[$className];
}
if (isset($this->singletons[$className])) {
return $this->instances[$className] = $this->singletons[$className]($this, $args);
}
return $this->resolveInstance($className, $args);
}
}
/www/hosting/vkrtechnologies.com/shop/vendor/macros/presenter/src/Provider.php
$this->registerSingletons((array) config('presenter.singletons'));
$this->app->singleton('presenter.profiler', function () {
return new \Profiler();
});
// Fixes macros app bug
$this->app->bind(\ORM::class, function ($arg) {
if ($arg instanceof \ORM) {
return $arg;
}
return \ORM::factory($arg);
});
}
private function registerAliases(array $aliases): void
{
foreach ($aliases as $alias => $class) {
$this->app->bind($alias, function () use ($class) {
return $this->app->make($class);
});
}
}
private function registerSingletons(array $singletons): void
{
foreach ($singletons as $name => $class) {
if ($name === $class) {
$this->app->singleton($class);
} else {
$this->app->singleton($name, function () use ($class) {
return $this->app->make($class);
});
}
}
}
}
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/system/macros/Traits/ContainerTrait.php
*
* @param callable $callback
* @param array $args
*
* @throws ReflectionException
*/
public function call($callback, array $args = [])
{
$reflectionFn = $this->makeReflectionFn($callback);
$params = $this->resolveParams($reflectionFn, $args);
if ($reflectionFn instanceof ReflectionMethod) {
$instance = null;
if (is_array($callback) && isset($callback[0]) && is_object($callback[0])) {
$instance = $callback[0];
} elseif (is_object($callback) && ! $callback instanceof Closure) {
$instance = $callback;
}
return $reflectionFn->invokeArgs($instance, $params);
}
return $reflectionFn->invokeArgs($params);
}
/**
* @param mixed $fn
*
* @return ReflectionFunctionAbstract
*
* @throws ReflectionException
*/
public function makeReflectionFn($fn)
{
if ($fn instanceof ReflectionFunctionAbstract) {
return $fn;
}
if (is_array($fn)) {
return new ReflectionMethod($fn[0], $fn[1]);
}
if (is_object($fn) && ! $fn instanceof \Closure && method_exists($fn, '__invoke')) {
return new ReflectionMethod($fn, '__invoke');
}
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/system/macros/Traits/ContainerTrait.php
});
$this->instances[$className] = $instance;
}
/**
* Creates new class instance and resolve constructor arguments
*
* @param string|ReflectionClass $className
* @param array $args
*
* @return object
*
* @throws ReflectionException
*/
public function resolveInstance($class, array $args = [])
{
$className = ($class instanceof ReflectionClass) ? $class->getName() : $class;
if (is_scalar($className) && array_key_exists($className, $this->bindings)) {
return $this->call($this->bindings[$className], $args);
}
if (! class_exists($className)) {
throw new \RuntimeException("Class {$className} does not exist");
}
$reflectionClass = ($class instanceof ReflectionClass) ? $class : new ReflectionClass($class);
$constructor = $reflectionClass->getConstructor();
if ($constructor === null) {
return $reflectionClass->newInstance();
}
$params = $this->resolveParams($constructor, $args);
return $reflectionClass->newInstanceArgs($params);
}
/**
* Resolve reflection method arguments
*/
public function resolveParams(ReflectionFunctionAbstract $reflectionFn, array $args = [])
{
$params = [];
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/system/macros/Traits/ContainerTrait.php
*
* @template TObject of object
*
* @param class-string<TObject> $className
* @param array $args
*
* @return TObject
*/
public function make($className, array $args = [])
{
if (isset($this->aliases[$className])) {
return $this->make($this->aliases[$className], $args);
}
if (isset($this->instances[$className])) {
return $this->instances[$className];
}
if (isset($this->singletons[$className])) {
return $this->instances[$className] = $this->singletons[$className]($this, $args);
}
return $this->resolveInstance($className, $args);
}
}
/www/hosting/vkrtechnologies.com/shop/vendor/macros/presenter/src/Presenter.php
{
return app()->make(LoggerInterface::class);
}
/**
* @return Web&\Web
*/
public function web(): Web
{
/** @var Web */
return app()->make('presenter.web');
}
/**
* @return Web&\Web
*/
public function layout(): Layout
{
/** @var Layout */
return app()->make('presenter.layout');
}
public function category(): \PresenterCategory
{
return PresenterCategory::instance();
}
/**
* Vrati driver pro menu nadefinovane v configu presenter_menu pod klicem s nazvem $name
* @param string $name
* @return PresenterMenu
*/
public function menu($name, $config = null)
{
return app()->make(PresenterMenu::class, [
'name' => $name,
'config' => $config,
]);
}
/www/hosting/vkrtechnologies.com/shop/vendor/macros/presenter/src/Controllers/BaseController.php
* Cesta k pohledu layoutu
* @var string
*/
protected $_layout_name = '@layout';
/**
* @var Layout
*/
protected $_layout;
/**
* @var Breadcrumbs_PresenterModule
*/
protected $_breadcrumbs;
public function __construct()
{
parent::__construct();
$this->_layout = presenter()->layout();
$this->_breadcrumbs = presenter()->module('Breadcrumbs');
$can_access = $this->check_permissions();
if (! $can_access || ($can_access instanceof PresenterPermissionException)) {
return ($can_access instanceof PresenterPermissionException) ? $this->permissions_denied($can_access->getMessage()) : $this->permissions_denied();
}
$this->default_settings();
$this->before_action();
Event::add('system.post_controller', [$this, '_render']);
}
protected function setup()
{
parent::setup();
/www/hosting/vkrtechnologies.com/shop/vendor/macros/presenter/controllers/homepage.php
<?php
class Homepage_Controller extends PresenterController
{
public function __construct()
{
parent::__construct();
// Check system config
Presenter::checkAppSettings();
}
public function index()
{
PresenterCategory::instance()->setActiveId(null);
Presenter::backToShopUrl(url::current());
return view("homepage");
}
}
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/system/macros/Traits/ContainerTrait.php
* @throws ReflectionException
*/
public function resolveInstance($class, array $args = [])
{
$className = ($class instanceof ReflectionClass) ? $class->getName() : $class;
if (is_scalar($className) && array_key_exists($className, $this->bindings)) {
return $this->call($this->bindings[$className], $args);
}
if (! class_exists($className)) {
throw new \RuntimeException("Class {$className} does not exist");
}
$reflectionClass = ($class instanceof ReflectionClass) ? $class : new ReflectionClass($class);
$constructor = $reflectionClass->getConstructor();
if ($constructor === null) {
return $reflectionClass->newInstance();
}
$params = $this->resolveParams($constructor, $args);
return $reflectionClass->newInstanceArgs($params);
}
/**
* Resolve reflection method arguments
*/
public function resolveParams(ReflectionFunctionAbstract $reflectionFn, array $args = [])
{
$params = [];
foreach ($reflectionFn->getParameters() as $index => $param) {
$arg = null;
if (array_key_exists($param->getName(), $args)) {
$arg = $args[$param->getName()];
} elseif (array_key_exists($index, $args)) {
$arg = $args[$index];
}
$params[] = $this->resolveReflectionParam($param, $arg);
}
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/system/libraries/Router.php
try {
// Start validation of the controller
if (class_exists($controller) && strpos($controller, '\\') !== false) {
$class = new ReflectionClass($controller);
} else {
$class = new ReflectionClass(ucfirst($controller) . '_Controller');
}
} catch (ReflectionException $e) {
// Controller does not exist
abort(404);
}
if ($class->isAbstract() or (in_production() and $class->getConstant('ALLOW_PRODUCTION') == false)) {
// Controller is not allowed to run in production
abort(404);
}
// Create a new controller instance
$_controller = app()->resolveInstance($class);
// Controller constructor has been executed
if ($uri === null) {
Event::run('system.post_controller_constructor');
}
try {
// Load the controller method
$_method = $class->getMethod($method);
// Method exists
if ($method[0] === '_') {
// Do not allow access to hidden methods
abort(404);
}
if ($_method->isProtected() or $_method->isPrivate()) {
// Do not attempt to invoke protected methods
throw new ReflectionException('protected controller method');
}
/www/hosting/vkrtechnologies.com/shop/vendor/macros/macros/system/macros/Application.php
{
debugbar()->measure('SETUP ROUTER', function () {
self::loadRoutes();
\Router::find_uri();
\Router::setup();
});
debugbar()->measure('INIT SYSTEM', function () {
// Prepare the system
Event::run('system.ready');
// Determine routing
Event::run('system.routing');
});
if ($this->isDebugEnabled() && str_contains($_SERVER['HTTP_ACCEPT'] ?? '', 'text/html')) {
ob_start();
}
\Router::execute();
if ($this->isDebugEnabled() && str_contains($_SERVER['HTTP_ACCEPT'] ?? '', 'text/html')) {
$output = ob_get_clean();
$debugbar = $this->make(DebugBarInterface::class);
if (defined('APP_START')) {
$debugbar->addMeasure('TOTAL', APP_START, microtime(true));
}
if (strpos($output, '</body>') !== false) {
$output = str_replace('</body>', $debugbar->render() . '</body>', $output);
}
echo $output;
}
// Clean up and exit
Event::run('system.shutdown');
}
/www/hosting/vkrtechnologies.com/shop/public/index.php
<?php
declare(strict_types=1);
$root = dirname(__DIR__);
require $root . '/vendor/autoload.php';
$app = \Macros\Macros\ApplicationFactory::create($root);
try {
// Spusti aplikaci
$app->run();
} catch (\Exception $e) {
\Macros\Macros\ExceptionHandler::factory($app)->handleException($e);
}