DeactivateConnection.php in RedHen CRM 8
File
modules/redhen_connection/src/Plugin/Action/DeactivateConnection.php
View source
<?php
namespace Drupal\redhen_connection\Plugin\Action;
use Drupal\Core\Action\ActionBase;
use Drupal\Core\Session\AccountInterface;
class DeactivateConnection extends ActionBase {
public function execute($connection = NULL) {
if ($connection !== FALSE && $connection
->isActive()) {
$connection->original = clone $connection;
$connection
->setActive(FALSE);
$connection
->save();
}
}
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
$access = $object->status
->access('edit', $account, TRUE);
return $return_as_object ? $access : $access
->isAllowed();
}
}