Working on speech rec

This commit is contained in:
Hillel Coren 2017-04-05 22:39:13 +03:00
parent 2581e529e4
commit d2b90ac4b6
3 changed files with 10 additions and 3 deletions

View File

@ -80,6 +80,13 @@ class BaseIntent
return new $className($state, $data);
}
protected function hasField($field, $value = false)
{
$fieldValue = $this->getField($field);
return $value ? $value == $fieldValue : !!$fieldValue;
}
protected function getField($field)
{
foreach ($this->data->entities as $entity) {
@ -106,7 +113,7 @@ class BaseIntent
protected function loadStates($entityType)
{
$states = array_filter($this->getFields('State'), function($state) {
$states = array_filter($this->getFields('Filter'), function($state) {
return in_array($state, [STATUS_ACTIVE, STATUS_ARCHIVED, STATUS_DELETED]);
});

View File

@ -109,7 +109,7 @@ class InvoiceIntent extends BaseIntent
protected function loadStatuses($entityType)
{
$statusIds = [];
$statuses = $this->getFields('State');
$statuses = $this->getFields('Filter');
foreach ($statuses as $status) {
if ($statusId = InvoiceStatus::getIdFromAlias($status)) {

View File

@ -11,7 +11,7 @@ class ListInvoiceIntent extends InvoiceIntent
$this->loadStates(ENTITY_INVOICE);
$this->loadStatuses(ENTITY_INVOICE);
if ($client = $this->requestClient()) {
if (! $this->hasField('Filter', 'all') && $client = $this->requestClient()) {
$url = $client->present()->url . '#invoices';
} else {
$url = '/invoices';