Merge branch 'dev' into widget_menu

This commit is contained in:
Michal Kváček
2016-04-01 21:57:44 +02:00
147 changed files with 5792 additions and 158 deletions
@@ -5,14 +5,20 @@ use App\Enumerations\Exceptions\EnumerationExistsException;
use App\Handlers\Contracts\SearchHandler;
use App\Handlers\Contracts\SearchPresenterHandler;
use App\Handlers\Registrators\Items\SearchEngine;
use Symfony\Component\Process\Exception\InvalidArgumentException;
class SearchEngineRegistrator
{
const ADMIN = 'admin';
const VISITOR = 'visitor';
protected $searchEngines;
function __construct($app)
{
$this->searchEngines = [];
$this->searchEngines = [
self::ADMIN => [],
self::VISITOR => []
];
}
/**
@@ -21,37 +27,46 @@ class SearchEngineRegistrator
* @param SearchHandler $search
* @param SearchPresenterHandler $presenter
*
* @param $type
*
* @throws EnumerationExistsException
*/
public function register(SearchHandler $search, SearchPresenterHandler $presenter)
public function register(SearchHandler $search, SearchPresenterHandler $presenter, $type)
{
$this->checkIfRegistered($search->getId());
$this->checkIfRegistered($type, $search->getId());
// register new extension
$this->searchEngines[$search->getId()] = [$search, $presenter];
$this->searchEngines[$type][$search->getId()] = [$search, $presenter];
}
/**
* Getter for all registered extensions
*
* @param $type
*
* @return array
*/
public function get()
public function get($type)
{
return $this->searchEngines;
if (!isset($this->searchEngines[$type])) {
throw new InvalidArgumentException('Invalid type ' . $type);
}
return $this->searchEngines[$type];
}
/**
* Checks if this section is not already defined
*
* @param $type
* @param $id
*
* @throws EnumerationExistsException
*/
private function checkIfRegistered($id)
private function checkIfRegistered($type, $id)
{
if (isset($this->searchEngines[$id])) {
throw new EnumerationExistsException('Already existing search engine ' . $id);
if (isset($this->searchEngines[$type][$id])) {
throw new EnumerationExistsException('Already existing search engine ' . $id . ' in ' . $type);
}
}
}
@@ -21,7 +21,6 @@ class TemplateRegistrator
protected $namespace;
/**
* @var string absolute path to currently registered directory
*
* This variable is set in register() method as $baseDirectory/$path
*/
protected $registeredPath;
@@ -78,7 +77,6 @@ class TemplateRegistrator
/**
* Registers new template path.
*
* This method registeres given path itself with all subdirectories
*
* @param string $path path relatively to root of the project
@@ -140,7 +138,13 @@ class TemplateRegistrator
{
// skip custom directories (contains updated templates only)
$dirName = basename($path);
if ($dirName == Template::EDITED_TEMPLATES_DIRECTORY) {
$ignoredDirectories = [
Template::EDITED_TEMPLATES_DIRECTORY,
Template::ASSETS_DIRECTORY,
Template::MODULES_DIRECTORY
];
if (in_array($dirName, $ignoredDirectories)) {
return;
}
@@ -156,7 +160,6 @@ class TemplateRegistrator
/**
* Registers all templates
*
* This method takes all templates in given directory and registers them into database. Templates registered in
* this way may be used for further manipulation.
*
@@ -259,7 +262,6 @@ class TemplateRegistrator
/**
* Get template name
*
* Converts path to template to corresponding name
*
* @param $template
@@ -38,9 +38,9 @@ class WidgetRegistrator
'name' => $widgetName,
'description' => $widgetDescription
]);
}
// install widget (if neccessary)
call_user_func($classname . '::install');
// install widget (if neccessary)
call_user_func($classname . '::install');
}
}
}