/var/www/html/modules/Product/Api/Guest.php
* @throws \FOSSBilling\Exception
*/
public function get($data)
{
if (!isset($data['id']) && !isset($data['slug'])) {
throw new \FOSSBilling\Exception('Product ID or slug is missing');
}
$id = $data['id'] ?? null;
$slug = $data['slug'] ?? null;
$service = $this->getService();
if ($id) {
$model = $service->findOneActiveById($id);
} else {
$model = $service->findOneActiveBySlug($slug);
}
if (!$model instanceof \Model_Product) {
throw new \FOSSBilling\Exception('Product not found');
}
return $service->toApiArray($model);
}
/**
* Get paginated list of product categories.
*
* @return array
*/
public function category_get_list($data)
{
$data['status'] = 'enabled';
$service = $this->getService();
[$sql, $params] = $service->getProductCategorySearchQuery($data);
$per_page = $data['per_page'] ?? $this->di['pager']->getDefaultPerPage();
$pager = $this->di['pager']->getPaginatedResultSet($sql, $params, $per_page);
foreach ($pager['list'] as $key => $item) {
$category = $this->di['db']->getExistingModelById('ProductCategory', $item['id'], 'Product category not found');
$pager['list'][$key] = $this->getService()->toProductCategoryApiArray($category, true, $this->getIdentity());
Arguments
/var/www/html/library/Api/Handler.php
$api->setDi($this->di);
$api->setMod($bb_mod);
$api->setIdentity($this->identity);
$api->setIp($this->di['request']->getClientIp());
if ($bb_mod->hasService()) {
$api->setService($this->di['mod_service']($mod));
}
if (!method_exists($api, $method_name) || !is_callable([$api, $method_name])) {
$reflector = new ReflectionClass($api);
if (!$reflector->hasMethod('__call')) {
throw new FOSSBilling\Exception(':type API call :method does not exist in module :module', [':type' => ucfirst((string) $this->type), ':method' => $method_name, ':module' => $mod], 740);
}
}
$data = is_array($arguments) ? $arguments : [];
$this->validateRequiredParams($api, $method_name, $data);
return $api->{$method_name}($arguments);
}
/**
* Validate required parameters for an API method using attributes.
*
* @param Api_Abstract $api The API instance
* @param string $method_name The method name
* @param array $data The data array passed to the method
*
* @throws FOSSBilling\InformationException If required parameters are missing
*/
public function validateRequiredParams(Api_Abstract $api, string $method_name, array $data): void
{
try {
$reflection = new ReflectionMethod($api, $method_name);
} catch (ReflectionException) {
// Method doesn't exist, skip validation
return;
}
Arguments
array:1 [
"slug" => "basic-wordpress"
]
/var/www/html/modules/Order/Controller/Client.php
}
public function register(\Box_App &$app): void
{
$app->get('/order', 'get_products', [], static::class);
$app->get('/order/service', 'get_orders', [], static::class);
$app->get('/order/:id', 'get_configure_product', ['id' => '[0-9]+'], static::class);
$app->get('/order/:slug', 'get_configure_product_by_slug', ['slug' => '[a-z0-9-]+'], static::class);
$app->get('/order/service/manage/:id', 'get_order', ['id' => '[0-9]+'], static::class);
}
public function get_products(\Box_App $app): string
{
return $app->render('mod_order_index');
}
public function get_configure_product_by_slug(\Box_App $app, $slug): string
{
$api = $this->di['api_guest'];
$product = $api->product_get(['slug' => $slug]);
$tpl = 'mod_service' . $product['type'] . '_order';
if ($api->system_template_exists(['file' => $tpl . '.html.twig'])) {
return $app->render($tpl, ['product' => $product]);
}
return $app->render('mod_order_product', ['product' => $product]);
}
public function get_configure_product(\Box_App $app, $id): string
{
$api = $this->di['api_guest'];
$product = $api->product_get(['id' => $id]);
$tpl = 'mod_service' . $product['type'] . '_order';
if ($api->system_template_exists(['file' => $tpl . '.html.twig'])) {
return $app->render($tpl, ['product' => $product]);
}
return $app->render('mod_order_product', ['product' => $product]);
}
Arguments
"product_get"
array:1 [
"slug" => "basic-wordpress"
]
[internal]
Arguments
Box_AppClient {#184}
"basic-wordpress"
/var/www/html/library/Box/App.php
$timeCollector->startMeasure('executeShared', 'Reflecting module controller (shared mapping)');
$class = new $classname();
if ($class instanceof InjectionAwareInterface) {
$class->setDi($this->di);
}
$reflection = new ReflectionMethod($class::class, $methodName);
$args = [];
$args[] = $this; // first param always app instance
foreach ($reflection->getParameters() as $param) {
if (isset($params[$param->name])) {
$args[$param->name] = $params[$param->name];
} elseif ($param->isDefaultValueAvailable()) {
$args[$param->name] = $param->getDefaultValue();
}
}
$timeCollector->stopMeasure('executeShared');
return $reflection->invokeArgs($class, $args);
}
protected function execute($methodName, $params, $classname = null): string
{
/** @var TimeDataCollector $timeCollector */
$timeCollector = $this->debugBar->getCollector('time');
$timeCollector->startMeasure('execute', 'Reflecting module controller');
$reflection = new ReflectionMethod(static::class, $methodName);
$args = [];
foreach ($reflection->getParameters() as $param) {
if (isset($params[$param->name])) {
$args[$param->name] = $params[$param->name];
} elseif ($param->isDefaultValueAvailable()) {
$args[$param->name] = $param->getDefaultValue();
}
}
Arguments
Box\Mod\Order\Controller\Client {#387}
array:2 [
0 => Box_AppClient {#184}
"slug" => "basic-wordpress"
]
/var/www/html/library/Box/App.php
return '';
}
return $this->render('mod_system_maintenance');
}
}
/** @var TimeDataCollector $timeCollector */
$timeCollector = $this->debugBar->getCollector('time');
$timeCollector->startMeasure('sharedMapping', 'Checking shared mappings');
$sharedCount = count($this->shared);
for ($i = 0; $i < $sharedCount; ++$i) {
$mapping = $this->shared[$i];
$url = new Box_UrlHelper($mapping[0], $mapping[1], $mapping[3], $this->url);
if ($url->match) {
$timeCollector->stopMeasure('sharedMapping');
return $this->executeShared($mapping[4], $mapping[2], $url->params);
}
}
$timeCollector->stopMeasure('sharedMapping');
// this class mappings
$timeCollector->startMeasure('mapping', 'Checking mappings');
$mappingsCount = count($this->mappings);
for ($i = 0; $i < $mappingsCount; ++$i) {
$mapping = $this->mappings[$i];
$url = new Box_UrlHelper($mapping[0], $mapping[1], $mapping[3], $this->url);
if ($url->match) {
$timeCollector->stopMeasure('mapping');
return $this->execute($mapping[2], $url->params);
}
}
$timeCollector->stopMeasure('mapping');
$e = new FOSSBilling\InformationException('Page :url not found', [':url' => $this->url], 404);
Arguments
"Box\Mod\Order\Controller\Client"
"get_configure_product_by_slug"
array:1 [
"slug" => "basic-wordpress"
]
/var/www/html/library/Box/App.php
}
public function run(): string
{
/** @var TimeDataCollector $timeCollector */
$timeCollector = $this->debugBar->getCollector('time');
$timeCollector->startMeasure('registerModule', 'Registering module routes');
$this->registerModule();
$timeCollector->stopMeasure('registerModule');
$timeCollector->startMeasure('init', 'Initializing the app');
$this->init();
$timeCollector->stopMeasure('init');
$timeCollector->startMeasure('checkperm', 'Checking access to module');
$this->checkPermission();
$timeCollector->stopMeasure('checkperm');
return $this->processRequest();
}
/**
* @param string $path
*/
public function redirect($path): never
{
$location = $this->di['url']->link($path);
header("Location: $location");
exit;
}
public function render($fileName, $variableArray = []): string
{
return 'Rendering ' . $fileName;
}
public function sendFile($filename, $contentType, $path): false|int
{
header("Content-type: $contentType");
/var/www/html/index.php
// If HTTP error code has been passed, handle it.
if (!is_null($http_err_code)) {
switch ($http_err_code) {
case '404':
$e = new FOSSBilling\Exception('Page :url not found', [':url' => $url], 404);
echo $app->show404($e);
break;
default:
$http_err_code = intval($http_err_code);
http_response_code($http_err_code);
$e = new FOSSBilling\Exception('HTTP Error :err_code occurred while attempting to load :url', [':err_code' => $http_err_code, ':url' => $url], $http_err_code);
echo $app->render('error', ['exception' => $e]);
}
exit;
}
// If no HTTP error passed, run the app.
echo $app->run();
exit;