UnpublishProfile.php in Profile 2 8
File
src/Plugin/Action/UnpublishProfile.php
View source
<?php
namespace Drupal\profile\Plugin\Action;
use Drupal\Core\Action\ActionBase;
use Drupal\Core\Session\AccountInterface;
class UnpublishProfile extends ActionBase {
public function execute($entity = NULL) {
$entity->status = PROFILE_NOT_ACTIVE;
$entity
->save();
}
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
$access = $object
->access('update', $account, TRUE)
->andIf($object->status
->access('edit', $account, TRUE));
return $return_as_object ? $access : $access
->isAllowed();
}
}