Error code: Fatal error: Namespace declaration statement has to be the very first statement in the script HTTP Fatal error: Namespace declaration statement has to be the very first statement in the script (GET /settings/plugin)
вот код самого plugin:
<?php
namespace Plugins\Suppliers;
defined('PIMPORT') or die('Error access');
use Infr;
/**
* Class Plugin
* @package Plugins\Suppliers
*/
class Plugin extends Infr\Plugin {
/** @var string */
protected $_name = 'Прайс-листы поставщиков';
/** @var string */
protected $_description = 'XLS прайс-листы поставщиков.';
/** @var bool */
protected $_menu = true;
/** @var string */
protected $_menuName = 'Прайс-листы поставщиков';
/**
* @param \Model\Plugin $plugin
* @param \Base $core
* @return mixed
*/
public function settings(\Model\Plugin $plugin, \Base $core) {
$core->push('js_files', 'plugin_suppliers.js');
$settings = $this->_getSettings($plugin->id);
$supplierStorage = new Model\Storage();
$supplierCollection = $supplierStorage->getSuppliers();
if ($core->get("POST.upload")) {
$supplierId = $core->get("POST.id");
$coefficient = $core->get("POST.coefficient");
/** @var Model\Supplier $supplierItem */
$supplierItem = $supplierCollection->find($supplierId);
$settings['coefficient_' . $supplierItem->id] = $coefficient;
$this->_saveSettings($plugin->id, $settings);
$supplierStorage->setConfig($supplierItem, $settings);
$supplierStorage->generateSupplierPrice($supplierItem, $core->get("FILES.price"));
Infr\Request::instance()->redirect($core->get("BASE") . '/settings/plugin?id=' . $plugin->id . '&supplier='
. rawurlencode($supplierId));
}
if ($core->get("GET.download_price")) {
$supplierId = $core->get("GET.download_price");
/** @var Model\Supplier $supplierItem */
$supplierItem = $supplierCollection->find($supplierId);
if ($supplierItem) {
$supplierStorage->setPrice($supplierItem);
\Web::instance()->send($supplierItem->price->file);
exit();
}
$core->error(404);
}
if ($core->get("GET.remove_price")) {
$supplierId = $core->get("GET.remove_price");
/** @var Model\Supplier $supplierItem */
$supplierItem = $supplierCollection->find($supplierId);
if ($supplierItem) {
$supplierStorage->removePriceFile($supplierItem);
}
Infr\Request::instance()->redirect($core->get("BASE") . '/settings/plugin?id=' . $plugin->id . '&supplier='
. rawurlencode($supplierId));
}
$supplierId = $core->get("GET.supplier");
$supplierStorage->setPriceToCollection($supplierCollection);
$supplierStorage->setConfigToCollection($supplierCollection, $settings);
$core->mset(array(
'CURRENT_SUPPLIER' => $supplierId,
'count_items' => $supplierCollection->count(),
'supplier_items' => $supplierCollection->toArray(),
'PLUGIN_SETTINGS' => $settings,
'PLUGIN' => $plugin->toArray(),
'PHP_INI_MAX_FILE_UPLOAD' => ini_get('max_file_uploads'),
));
return Infr\Template::instance()->render($this->_templateFolder() . DS . 'settings.html');
}
/**
* @param \Model\Plugin $plugin
* @return mixed|void
* @throws \Exception
*/
public function install(\Model\Plugin $plugin) {
}
/**
* @param \Model\Plugin $plugin
* @return mixed|void
*/
public function uninstall(\Model\Plugin $plugin) {
}
}