Create an Author role.

@param  bool $force Create author role even if it exist
@return bool
195068
public static function createAuthorRole($force = false)
    {
        if(!$force) {
            if(Permission::exists('global', 'author')) {
                return false;
            }
        }

        return self::createRole(
            'Author', true, [[
            'app' => 'global',
            'key' => 'author'
            ]]
        );
    }
222652
public function getSiteRoles(bool $force = false) : CNabuSiteRoleList
    {
        if ($this->nb_site_role_list->isEmpty() || $force) {
            $this->nb_site_role_list->clear();
            $this->nb_site_role_list->merge(CNabuSiteRole::getSiteRolesForSite($this));
        }

        return $this->nb_site_role_list;
    }
719116
public function create($roleName)
    {
        if (! is_null($this->findByName($roleName))) {
            // TODO: add translation support
            throw new RoleExistsException('A role with the given name already exists');
        }

        return $role = $this->model->create(['name' => $roleName]);
    }
421719
public function makeDir(string $path, bool $force = false) : bool
    {
        if (is_dir($path) == true) {
            return true;
        }

        $result = false;

        try {
            $result = mkdir($path, 0755, $force);
        } catch(\ErrorException $e) {
            $this->addErrorMessage( $e->getMessage() );
        }

        return $result;
    }
976070
public function postCreate(CreateEvent $event)
    {
        /** @var Role $role */
        $role = $event->getObject();

        if ($role->getWorkspace()) {
            $sql = "
              INSERT INTO claro_resource_rights (role_id, mask, resourceNode_id)
              SELECT {$role->getId()}, 1, resource.id FROM claro_resource_node resource
              WHERE resource.workspace_id = {$role->getWorkspace()->getId()}
            ";

            $stmt = $this->conn->prepare($sql);
            $stmt->execute();
        }
    }
364777
public function createUserWithRoles(array $roles = ['authenticated'], $password = FALSE) {
    $faker = Faker::create();
    /** @var \Drupal\user\Entity\User $user */
    $user = User::create([
      'name' => $faker->userName,
      'mail' => $faker->email,
      'roles' => $roles,
      'pass' => $password ? $password : $faker->password(12, 14),
      'status' => 1,
    ]);

    $user->save();

    $this->users[] = $user->id();

    return $user;
  }
351309
public function getCTAs($force = false)
    {
        if ($this->nb_site_target_cta_list->isEmpty() || $force) {
            $this->nb_site_target_cta_list->clear();
            $this->nb_site_target_cta_list->merge(CNabuSiteTargetCTA::getSiteTargetCTAs($this));
            $translations = CNabuSiteTargetCTALanguage::getCTATranslationsForSiteTarget($this);
            if (is_array($translations) && count($translations) > 0) {
                foreach ($translations as $translation) {
                    $nb_site_target_cta = $this->nb_site_target_cta_list->getItem($translation->getSiteTargetCTAId());
                    if ($nb_site_target_cta instanceof CNabuSiteTargetCTA) {
                        $nb_site_target_cta->setTranslation($translation);
                    }
                }
            }
            $roles = CNabuSiteTargetCTARole::getCTARolesForSiteTarget($this);
            if (is_array($roles) && count($roles) > 0) {
                foreach ($roles as $role) {
                    $nb_site_target_cta = $this->nb_site_target_cta_list->getItem($role->getSiteTargetCTAId());
                    if ($nb_site_target_cta instanceof CNabuSiteTargetCTA) {
                        $nb_site_target_cta->addRole($role);
                    }
                }
            }
        }

        return $this->nb_site_target_cta_list;
    }
1291810
public static function createRole($name, $isDefault, $permissions = [])
    {

        // Create admin role
        $role = (new static());
        $role->name = $name;
        $role->isDefault = $isDefault;
        $role->slug = str_slug($name);

        if($createdRole = $role->save()) {
            // Assert Permissions
            if($permissions) {
                $permissionObj = new Permission();
                foreach ($permissions as $permission) {
                    $permissionObj->assertPermission($role->groupID, $permission);
                }
            }

            return true;
        }

        return false;
    }
712811
protected function createAuthor(ObjectAccess $author)
    {
        return new Author(
            $author->get('name'),
            $author->getDefault('email'),
            $author->getDefault('homepage'),
            $author->getDefault('role'),
            $author->data()
        );
    }
745266
public function createRole($id, array $content, array $options = [])
    {
        $action = 'createRole';
        $data = [
            '_id' => $id,
            'body' => $content
        ];

        if (array_key_exists('replaceIfExist', $options)) {
            $action = 'createOrReplaceRole';
        }

        $response = $this->kuzzle->query(
            $this->buildQueryArgs($action),
            $data,
            $options
        );

        return new Role($this, $response['result']['_id'], $response['result']['_source'], $response['result']['_meta']);
    }
426723
public function create($data)
    {
        $descriptor = new AuthorDescriptor($data->getName());
        $descriptor->setDescription($data->getDescription());

        return $descriptor;
    }
1323156
public function make($name, $force = false) {
        if (isset($this->delays[$name])) {
            $this->register(new $this->delays[$name]($this), $name);
            unset($this->delays[$name]);
        }
        return parent::make($name, $force);
    }
180984
public function canDo($permission, $force = false)
    {
        if (! is_null($this->getUser())) {
            return $this->getUser()->canDo($permission, $force);
        }

        return false;
    }
1215810
private function setup($force = false)
    {
        // Set a default error code to indicate if anything changes
        $this->errorCode = NULL;

        // Indicate if this is a forced procedure
        $this->force = $force;

        // Load the current user
        $this->getUser();

        // Get the current bcrypt cost
		$this->_cost = Cii::getBcryptCost();

        // Preload the number of password attempts. As of 1.10.0
        $this->getPasswordAttempts();

        return;
    }
475889
protected function getHttpClient(bool $force = false): HttpClient
    {
        if ($this->_httpClient === null || $force) {
            $config = ArrayHelper::merge(['class' => HttpClient::class], $this->httpClientConfig);
            $config['baseUrl'] = $this->getBaseUrl();

            return $this->_httpClient = Yii::createObject($config);
        } else {
            return $this->_httpClient;
        }
    }
851298
public function create(array $data, MembershipInterface $author): PodiumResponse
    {
        /* @var $categoryForm AuthoredFormInterface */
        $categoryForm = $this->getForm();

        $categoryForm->setAuthor($author);

        if (!$categoryForm->loadData($data)) {
            return PodiumResponse::error();
        }

        return $categoryForm->create();
    }
445506
public function createUser($user, $roles = [])
    {
        // Create the new user
        $password = [
            'password' => bcrypt(Str::random(10)),
        ];

        $user = array_merge($password, $user);
        $user = $this->user->create($user);

        if (! $user) {
            return $user;
        }

        // Fire the creating event.
        event(new UserCreating($user));

        // Add the extra details needed to finish them.
        // Add the user details.
        $this->userDetails->create($this->getUserDetailsFromRequest($user));

        // Assign the user to the default group
        if (is_array($roles) || $roles instanceof Collection) {
            $user->syncRoles($roles);
        }

        // the user should always have the default role.
        if (empty($roles) || $roles === '') {
            $user->assignRole(config('jumpgate.users.default_role'));
        }

        // If we do not require activation, set the user as active.
        if (! config('jumpgate.users.require_email_activation')) {
            $user->updateActivationDetails();
        }

        // New user needs to set their password.
        $user->generateNewUserPasswordResetToken();

        // Fire the created event.
        event(new UserCreated($user));

        return $user;
    }