SortBaseForm.php in Entity Share 8.3
File
modules/entity_share_server/src/Form/SortBaseForm.php
View source
<?php
declare (strict_types=1);
namespace Drupal\entity_share_server\Form;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface;
class SortBaseForm extends EntityForm {
protected function actions(array $form, FormStateInterface $form_state) {
$actions = parent::actions($form, $form_state);
unset($actions['delete']);
return $actions;
}
protected function getDirectionOptions() {
return [
'ASC' => $this
->t('Ascending'),
'DESC' => $this
->t('Descending'),
];
}
public function sortExists($name) {
$channel = $this->entity;
$channel_sorts = $channel
->get('channel_sorts');
if (is_null($channel_sorts)) {
return FALSE;
}
if (isset($channel_sorts[$name])) {
return TRUE;
}
else {
return FALSE;
}
}
protected function getsortId() {
if (!isset($this->sortId)) {
$this->sortId = $this
->getRequest()->attributes
->get('sort');
}
return $this->sortId;
}
protected function sortIdExists() {
$channel = $this->entity;
$channel_sorts = $channel
->get('channel_sorts');
$sort_id = $this
->getsortId();
$sort_exists = FALSE;
if (isset($channel_sorts[$sort_id])) {
$sort_exists = TRUE;
}
return $sort_exists;
}
}