Skip to content

Commit

Permalink
xml config removed
Browse files Browse the repository at this point in the history
  • Loading branch information
hafijul233 committed Aug 6, 2022
1 parent c9234f8 commit c0389a6
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 131 deletions.
54 changes: 38 additions & 16 deletions config/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,36 @@
return [

/*
|--------------------------------------------------------------------------
| User Model Definition
|--------------------------------------------------------------------------
|
| Please specify a user model that should be used to setup `creator`
| and `updater` relationship.
|
*/
|--------------------------------------------------------------------------
| User Model Definition
|--------------------------------------------------------------------------
|
| Please specify a user model that should be used to setup `creator`
| and `updater` relationship.
|
*/

'paginate_location' => 'layouts.paginate.',

/*
|--------------------------------------------------------------------------
| User Model Definition
|--------------------------------------------------------------------------
|
| Please specify a user model that should be used to setup `creator`
| and `updater` relationship.
|
*/
|--------------------------------------------------------------------------
| User Model Definition
|--------------------------------------------------------------------------
|
| Please specify a user model that should be used to setup `creator`
| and `updater` relationship.
|
*/

'popup_actions' => [
'delete' => 'core::popup.delete',
'restore' => 'core::popup.restore',
'export' => 'core::popup.export',
'import' => 'core::popup.import',
],

//Blameable Trait and Uses

'blame' => [

/*
Expand Down Expand Up @@ -81,4 +84,23 @@

'deletedBy' => 'deleted_by',
],

//XML Response handler
'xml' => [
/*
|--------------------------------------------------------------------------
| Default template
|--------------------------------------------------------------------------
|
| Template to XML
|
| <root xmlns:v1="http://www.site.com/schema"></root>
|
*/
'template' => '<root></root>',
'caseSensitive' => false,
'showEmptyField' => true, //Show empty field
'charset' => 'utf-8',
'rowName' => null,
]
];
27 changes: 0 additions & 27 deletions config/xml.php

This file was deleted.

5 changes: 0 additions & 5 deletions src/CoreServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public function boot()
//config
$this->publishes([
__DIR__.'/../config/core.php' => config_path('core.php'),
__DIR__.'/../config/xml.php' => config_path('xml.php'),
__DIR__.'/../config/audit.php' => config_path('audit.php'),
__DIR__.'/../config/media-library.php' => config_path('media-library.php'),
__DIR__.'/../config/columnsortable.php' => config_path('columnsortable.php'),
Expand Down Expand Up @@ -62,10 +61,6 @@ public function register()
$this->mergeConfigFrom(
__DIR__.'/../config/core.php', 'core'
);

$this->mergeConfigFrom(
__DIR__.'/../config/xml.php', 'xml'
);
}

private function loadMacro()
Expand Down
44 changes: 20 additions & 24 deletions src/Http/Response/XmlResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ class XmlResponse
/**
* @var bool
*/
private $caseSensitive;
private $caseSensitive = false;

/**
* @var string
*/
private $template;
private $template = '<root></root>';

/**
* @var bool
*/
private $showEmptyField;
private $showEmptyField = true;

/**
* @var string
*/
private $charset;
private $charset = 'utf-8';

/**
* @var mixed
*/
private $rowName;
private $rowName = null;

/**
* @var bool
Expand All @@ -47,11 +47,7 @@ class XmlResponse
*/
public function __construct()
{
$this->caseSensitive = Config::get('xml.caseSensitive');
$this->template = Config::get('xml.template');
$this->showEmptyField = Config::get('xml.showEmptyField');
$this->charset = Config::get('xml.charset');
$this->rowName = Config::get('xml.rowName');
$this->config(Config::get('core.xml'));
}

/**
Expand All @@ -65,14 +61,14 @@ private function header()
}

/**
* @param array $header
* @param array $header
* @return string
*/
private function charset($header = []): string
{
$charset = 'application/xml; ';

if (! empty($this->charset)) {
if (!empty($this->charset)) {
$charset .= "charset={$this->charset}";
}

Expand All @@ -84,13 +80,13 @@ private function charset($header = []): string
*/
private function encodingXml()
{
if (! empty($this->charset) && strpos($this->template, 'encoding') === false) {
if (!empty($this->charset) && strpos($this->template, 'encoding') === false) {
$this->template = "<?xml version=\"1.0\" encoding=\"{$this->charset}\"?>{$this->template}";
}
}

/**
* @param string $value
* @param string $value
* @return bool
*/
private function isType(string $value): bool
Expand Down Expand Up @@ -119,11 +115,11 @@ private function caseSensitive($value)

private function rowName($row)
{
if (! empty($this->rowName)) {
if (!empty($this->rowName)) {
return $this->rowName;
}

return 'row_'.$row;
return 'row_' . $row;
}

/**
Expand All @@ -144,7 +140,7 @@ private function isConfig($value): bool
/**
* replaces the current setting
*
* @param array $config
* @param array $config
* @return void
*/
private function config($config = [])
Expand All @@ -158,9 +154,9 @@ private function config($config = [])

/**
* @param $array
* @param bool $xml
* @param array $config
* @param int $status
* @param bool $xml
* @param array $config
* @param int $status
* @return mixed
*
* @throws XmlResponseException
Expand All @@ -172,7 +168,7 @@ public function array2xml($array, $xml = false, $config = [], $status = 200)
$array = $array->toArray();
}

if (! $this->isType(gettype($array))) {
if (!$this->isType(gettype($array))) {
throw new XmlResponseException('It is not possible to convert data to XML Response');
}

Expand All @@ -193,7 +189,7 @@ public function array2xml($array, $xml = false, $config = [], $status = 200)
} elseif (is_object($value)) {
$this->array2xml($value, $xml->addChild($this->caseSensitive((new \ReflectionClass(get_class($value)))->getShortName())));
} else {
if (! is_null($value) || $this->showEmptyField) {
if (!is_null($value) || $this->showEmptyField) {
if (is_numeric($key)) {
$xml->addChild($this->caseSensitive($this->rowName($key)), htmlspecialchars($value));
} else {
Expand All @@ -211,8 +207,8 @@ public function array2xml($array, $xml = false, $config = [], $status = 200)
}

/**
* @param array $array
* @param array $config
* @param array $array
* @param array $config
* @return string
*
* @throws XmlResponseException
Expand Down
64 changes: 5 additions & 59 deletions src/Supports/Constant.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,11 @@ class Constant
*/
public const ENABLED_OPTIONS = ['yes' => 'Yes', 'no' => 'No'];

/**
* System Model Status
*/
public const GUEST_ROLE_ID = 4;

/**
* System User Permission Guards
*/
public const PERMISSION_GUARDS = ['web' => 'WEB'];

/**
* System User Permission Guard
*/
public const PERMISSION_GUARD = 'web';

/**
* System Permission Title Constraint
*/
public const PERMISSION_NAME_ALLOW_CHAR = '([a-zA-Z0-9.-_]+)';

/**
* Keyword to purge Soft Deleted Models
*/
public const PURGE_MODEL_QSA = 'purge';

/**
* Timing Constants
*/
Expand All @@ -59,13 +39,13 @@ class Constant
/**
* Toastr Message Levels
*/
public const MSG_TOASTR_ERROR = 'error';
public const MESSAGE_ERROR = 'error';

public const MSG_TOASTR_WARNING = 'warning';
public const MESSAGE_WARNING = 'warning';

public const MSG_TOASTR_SUCCESS = 'success';
public const MESSAGE_SUCCESS = 'success';

public const MSG_TOASTR_INFO = 'info';
public const MESSAGE_INFO = 'info';

/**
* Authentication Login Medium
Expand All @@ -88,7 +68,7 @@ class Constant
public const EXPORT_OPTIONS = [
'xlsx' => 'Microsoft Excel (.xlsx)',
'ods' => 'Open Document Spreadsheet (.ods)',
'csv' => 'Comma Seperated Values (.csv)',
'csv' => 'Comma Separated Values (.csv)',
];

/**
Expand Down Expand Up @@ -132,38 +112,4 @@ class Constant
* Default Exp[ort type
*/
public const EXPORT_DEFAULT = 'xlsx';

/**
* CATALOG TYPES
*/
public const CATALOG_TYPE = [
'GENDER' => 'GEN',
'MARITAL_STATUS' => 'MAS',
'RELIGION' => 'REL',
'UNIVERSITY' => 'UNI',
'BOARD' => 'BOR',
'QUOTA' => 'QOT',
];

/**
* CATALOG TYPES
*/
public const CATALOG_LABEL = [
'GEN' => 'Gender',
'MAS' => 'Marital Status',
'REL' => 'Religion',
'UNI' => 'University',
'BOR' => 'Board',
'QOT' => 'Quote',
];

public const GPA_TYPE = [
1 => '1st Division',
2 => '2nd Division',
3 => '3rd Division',
4 => 'GPA(Out of 4)',
5 => 'GPA(Out of 5)',
6 => 'Others',

];
}

0 comments on commit c0389a6

Please sign in to comment.