-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JSON config files. Split concept into services. Update readme
- Loading branch information
Showing
12 changed files
with
723 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"admin": { | ||
"routes": { | ||
"scripts": { | ||
"search/index-content":{ | ||
"ident": "charcoal/search/script/index-content" | ||
} | ||
} | ||
}, | ||
"system_menu": { | ||
"items": { | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"metadata": { | ||
"paths": [ | ||
"vendor/locomotivemtl/charcoal-contrib-search/metadata/" | ||
] | ||
}, | ||
"view": { | ||
"paths": [ | ||
"vendor/locomotivemtl/charcoal-contrib-search/views/" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
|
||
namespace Charcoal\Search\Action; | ||
|
||
use Charcoal\App\Action\AbstractAction; | ||
use Charcoal\Translator\TranslatorAwareTrait; | ||
use Pimple\Container; | ||
use Psr\Http\Message\RequestInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
class SearchAction extends AbstractAction | ||
{ | ||
use TranslatorAwareTrait; | ||
|
||
/** | ||
* @var SearchService | ||
*/ | ||
protected $search; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $output; | ||
|
||
/** | ||
* @param Container $container Pimple\Container. | ||
* @return void | ||
*/ | ||
public function setDependencies(Container $container) | ||
{ | ||
$this->search = $container['search']; | ||
$this->setTranslator($container['translator']); | ||
parent::setDependencies($container); | ||
} | ||
|
||
/** | ||
* @param RequestInterface $request A PSR-7 compatible Request instance. | ||
* @param ResponseInterface $response A PSR-7 compatible Response instance. | ||
* @return ResponseInterface | ||
*/ | ||
public function run(RequestInterface $request, ResponseInterface $response) | ||
{ | ||
$params = $request->getParams(); | ||
$keyword = $params['keyword']; | ||
|
||
$this->search->setKeyword($keyword); | ||
$this->search->setLang($this->translator()->getLocale()); | ||
|
||
if (!$this->search->tableExists()) { | ||
return $response->withStatus(404); | ||
} | ||
|
||
$list = $this->search->search(); | ||
|
||
$out = []; | ||
foreach ($list as $l) { | ||
$out[] = [ | ||
'objType' => $l->objectType(), | ||
'objId' => $l->objectId(), | ||
'slug' => $l->slug() | ||
]; | ||
} | ||
|
||
$this->setOutput($out); | ||
return $response; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function output() | ||
{ | ||
return $this->output; | ||
} | ||
|
||
/** | ||
* @param array $output | ||
* @return SearchAction | ||
*/ | ||
public function setOutput($output) | ||
{ | ||
$this->output = $output; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function results() | ||
{ | ||
return [ | ||
'results' => $this->output() | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.