Initial commit
This commit is contained in:
91
local/Beds24/Hook/BackHookManager.php
Normal file
91
local/Beds24/Hook/BackHookManager.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Beds24\Hook;
|
||||
|
||||
use Beds24\Beds24;
|
||||
use Beds24\Model\Beds24ProductInfoQuery;
|
||||
use Thelia\Core\Event\Hook\HookRenderEvent;
|
||||
use Thelia\Core\Hook\BaseHook;
|
||||
|
||||
/**
|
||||
* Class HookManager
|
||||
*
|
||||
* @package Cheque\Hook
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class BackHookManager extends BaseHook {
|
||||
|
||||
public function onProductEditRightColumnBottom(HookRenderEvent $event)
|
||||
{
|
||||
if (null !== $room = Beds24ProductInfoQuery::create()->findOneByProductId($event->getArgument('product_id'))) {
|
||||
$roomId = $room->getRoomId();
|
||||
} else {
|
||||
$roomId = '';
|
||||
}
|
||||
|
||||
$event->add(
|
||||
$this->render(
|
||||
"product-edit.html",
|
||||
[
|
||||
'room_id' => $roomId
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function onOrderEditCartBottom(HookRenderEvent $event)
|
||||
{
|
||||
$event->add(
|
||||
$this->render(
|
||||
"order-edit.html",
|
||||
$event->getArguments()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param HookRenderEvent $event
|
||||
* @throws Beds24\Beds24Exception
|
||||
*/
|
||||
public function onModuleConfiguration(HookRenderEvent $event)
|
||||
{
|
||||
$args = [
|
||||
'api_key' => Beds24::getConfigValue('api_key'),
|
||||
];
|
||||
|
||||
$api = new Beds24\Beds24Request();
|
||||
|
||||
$properties = $api->getPropertyList();
|
||||
|
||||
if ($api->hasError($properties)) {
|
||||
foreach ($properties as &$property) {
|
||||
$varName = 'prop_key_' . $property['id'];
|
||||
|
||||
$property['key'] = Beds24::getConfigValue($varName);
|
||||
}
|
||||
|
||||
$args['properties'] = $properties;
|
||||
} else {
|
||||
$args['properties'] = false;
|
||||
}
|
||||
|
||||
$event->add(
|
||||
$this->render(
|
||||
"module-configuration.html",
|
||||
$args
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user