protected function InstagramAccountForm::actions in Instagram Feeds 8
Returns an array of supported actions for the current entity form.
This function generates a list of Form API elements which represent actions supported by the current entity form.
@todo Consider introducing a 'preview' action here, since it is used by many entity types.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array An array of supported Form API action elements keyed by name.
Overrides EntityForm::actions
File
- src/
Form/ InstagramAccountForm.php, line 40
Class
- InstagramAccountForm
- Provides the InstagramAccount add/edit form.
Namespace
Drupal\instagram_feeds\FormCode
protected function actions(array $form, FormStateInterface $form_state) {
if (empty($this
->getConfig('client_id')) || empty($this
->getConfig('client_secret'))) {
return [
'configure' => [
'#type' => 'link',
'#title' => $this
->t('Configure Instagram Feeds'),
'#access' => $this
->currentUser()
->hasPermission('administer instagram_feeds'),
'#attributes' => [
'class' => [
'button',
'button--primary',
],
],
'#url' => Url::fromRoute('instagram_feeds.settings')
->setOption('query', \Drupal::destination()
->getAsArray()),
],
];
}
/** @var \Drupal\instagram_feeds\Entity\InstagramAccountInterface $i_account */
$i_account = $this
->getEntity();
// if ($i_account->isNew() && $i_account->get('token')->isEmpty()) {
// return $this->getAuthWindowButton();
// }
// elseif (!$i_account->tokenIsValid()) {
if (!$i_account
->tokenIsValid()) {
return $this
->getAuthWindowButton() + parent::actions($form, $form_state);
}
return parent::actions($form, $form_state);
}