3 namespace Drupal\Driver;
5 use Drupal\Driver\Exception\UnsupportedDriverActionException;
8 * Implements DriverInterface.
10 abstract class BaseDriver implements DriverInterface {
15 public function getRandom() {
16 throw new UnsupportedDriverActionException($this->errorString('generate random'), $this);
22 public function bootstrap() {
28 public function isBootstrapped() {
34 public function userCreate(\stdClass $user) {
35 throw new UnsupportedDriverActionException($this->errorString('create users'), $this);
41 public function userDelete(\stdClass $user) {
42 throw new UnsupportedDriverActionException($this->errorString('delete users'), $this);
48 public function processBatch() {
49 throw new UnsupportedDriverActionException($this->errorString('process batch actions'), $this);
55 public function userAddRole(\stdClass $user, $role) {
56 throw new UnsupportedDriverActionException($this->errorString('add roles'), $this);
62 public function fetchWatchdog($count = 10, $type = NULL, $severity = NULL) {
63 throw new UnsupportedDriverActionException($this->errorString('access watchdog entries'), $this);
69 public function clearCache($type = NULL) {
70 throw new UnsupportedDriverActionException($this->errorString('clear Drupal caches'), $this);
76 public function clearStaticCaches() {
77 throw new UnsupportedDriverActionException($this->errorString('clear static caches'), $this);
83 public function createNode($node) {
84 throw new UnsupportedDriverActionException($this->errorString('create nodes'), $this);
90 public function nodeDelete($node) {
91 throw new UnsupportedDriverActionException($this->errorString('delete nodes'), $this);
97 public function runCron() {
98 throw new UnsupportedDriverActionException($this->errorString('run cron'), $this);
104 public function createTerm(\stdClass $term) {
105 throw new UnsupportedDriverActionException($this->errorString('create terms'), $this);
111 public function termDelete(\stdClass $term) {
112 throw new UnsupportedDriverActionException($this->errorString('delete terms'), $this);
118 public function roleCreate(array $permissions) {
119 throw new UnsupportedDriverActionException($this->errorString('create roles'), $this);
125 public function roleDelete($rid) {
126 throw new UnsupportedDriverActionException($this->errorString('delete roles'), $this);
132 public function isField($entity_type, $field_name) {
139 public function configGet($name, $key) {
140 throw new UnsupportedDriverActionException($this->errorString('config get'), $this);
146 public function configSet($name, $key, $value) {
147 throw new UnsupportedDriverActionException($this->errorString('config set'), $this);
151 * Error printing exception.
153 * @param string $error
154 * The term, node, user or permission.
157 * A formatted string reminding people to use an API driver.
159 private function errorString($error) {
160 return sprintf('No ability to %s in %%s. Put `@api` into your feature and add an API driver (ex: `api_driver: drupal`) in behat.yml.', $error);