FEATURE: add input for setting preview size and quality
This commit is contained in:
@@ -15,6 +15,7 @@ class SettingExtension
|
||||
* @var string view used for rendering given settings part
|
||||
*/
|
||||
protected $view;
|
||||
protected $order;
|
||||
|
||||
/**
|
||||
* SettingExtension constructor.
|
||||
@@ -23,11 +24,12 @@ class SettingExtension
|
||||
* @param string $name
|
||||
* @param string $view
|
||||
*/
|
||||
public function __construct($id, $name, $view)
|
||||
public function __construct($id, $name, $view, $order)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->view = $view;
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,4 +55,14 @@ class SettingExtension
|
||||
{
|
||||
return $this->view;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\CMS\Handlers\Registrators;
|
||||
|
||||
use App\CMS\Enumerations\Exceptions\EnumerationExistsException;
|
||||
use App\CMS\Exceptions\Enumerations\EnumerationExistsException;
|
||||
use App\CMS\Handlers\Registrators\Items\SettingExtension;
|
||||
|
||||
class SettingsExtensionRegistrator
|
||||
@@ -22,12 +23,16 @@ class SettingsExtensionRegistrator
|
||||
*
|
||||
* @throws EnumerationExistsException
|
||||
*/
|
||||
public function register($sectionId, $sectionName, $sectionView)
|
||||
public function register($sectionId, $sectionName, $sectionView, $order = null)
|
||||
{
|
||||
$this->checkIfRegistered($sectionId);
|
||||
|
||||
if (is_null($order)) {
|
||||
$order = count($this->settingsExtensions);
|
||||
}
|
||||
|
||||
// register new extension
|
||||
$this->settingsExtensions[$sectionId] = new SettingExtension($sectionId, $sectionName, $sectionView);
|
||||
$this->settingsExtensions[$sectionId] = new SettingExtension($sectionId, $sectionName, $sectionView, $order);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,14 +49,15 @@ class SettingsExtensionRegistrator
|
||||
|
||||
/**
|
||||
* Getter for all registered extensions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
// sort registered extensions by key
|
||||
ksort($this->settingsExtensions);
|
||||
|
||||
// sort registered extensions
|
||||
uasort($this->settingsExtensions, function (SettingExtension $a, SettingExtension $b) {
|
||||
return $a->getOrder() - $b->getOrder();
|
||||
});
|
||||
|
||||
return $this->settingsExtensions;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user