GroupBaseForm.php in Entity Share 8
File
modules/entity_share_server/src/Form/GroupBaseForm.php
View source
<?php
namespace Drupal\entity_share_server\Form;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface;
class GroupBaseForm extends EntityForm {
protected function actions(array $form, FormStateInterface $form_state) {
$actions = parent::actions($form, $form_state);
unset($actions['delete']);
return $actions;
}
protected function getConjunctionOptions() {
return [
'AND' => $this
->t('And'),
'OR' => $this
->t('Or'),
];
}
protected function getGroupOptions($group_id = '') {
$channel = $this->entity;
$channel_groups = $channel
->get('channel_groups');
if (is_null($channel_groups)) {
$channel_groups = [];
}
$member_options = array_keys($channel_groups);
$options = array_combine($member_options, $member_options);
if (isset($options[$group_id])) {
unset($options[$group_id]);
}
return $options;
}
public function groupExists($name) {
$channel = $this->entity;
$channel_groups = $channel
->get('channel_groups');
if (is_null($channel_groups)) {
return FALSE;
}
if (isset($channel_groups[$name])) {
return TRUE;
}
else {
return FALSE;
}
}
protected function getgroupId() {
if (!isset($this->groupId)) {
$this->groupId = $this
->getRequest()->attributes
->get('group');
}
return $this->groupId;
}
protected function groupIdExists() {
$channel = $this->entity;
$channel_groups = $channel
->get('channel_groups');
$group_id = $this
->getgroupId();
$group_exists = FALSE;
if (isset($channel_groups[$group_id])) {
$group_exists = TRUE;
}
return $group_exists;
}
}