Defines the Abilities for the application.

@return void
184280
public function defineAbilities()
    {
        $this->gate->before(function ($user, $ability) {
            if ($user->isSuperuser()) return true;
        });

        foreach ($this->getPermissions() as $permission) {
            $this->gate->define($permission->name, function ($user) use ($permission) {
                return $user->hasPermission($permission->name);
            });
        }
    }
968803
protected function _defineFeatures()
    {
        $this->setFeature('iframes',    false, 'product_capability');
        $this->setFeature('frames',     false, 'product_capability');
        $this->setFeature('javascript', false, 'product_capability');
        return parent::_defineFeatures();
    }
618553
protected function definition() {
        $form = $this->_form;
        $stores = $this->_customdata;

        $options = array(
            cache_store::MODE_APPLICATION => array(),
            cache_store::MODE_SESSION => array(),
            cache_store::MODE_REQUEST => array()
        );
        foreach ($stores as $storename => $store) {
            foreach ($store['modes'] as $mode => $enabled) {
                if ($enabled && ($mode !== cache_store::MODE_SESSION || $store['supports']['searchable'])) {
                    if (empty($store['default'])) {
                        $options[$mode][$storename] = $store['name'];
                    } else {
                        $options[$mode][$storename] = get_string('store_'.$store['name'], 'cache');
                    }
                }
            }
        }

        $form->addElement('hidden', 'action', 'editmodemappings');
        $form->setType('action', PARAM_ALPHA);
        foreach ($options as $mode => $optionset) {
            $form->addElement('select', 'mode_'.$mode, get_string('mode_'.$mode, 'cache'), $optionset);
        }

        $this->add_action_buttons();
    }
70743
protected function configure(): void
    {
        // eg. IndexConfigure() for indexCommand()
        $method = $this->action . 'Configure';

        if (\method_exists($this, $method)) {
            $this->$method();
        }
    }
266328
public function abilities()
    {
        $relation = $this->morphToMany(
            Models::classname(Ability::class),
            'entity',
            Models::table('permissions')
        )->withPivot('forbidden', 'scope');

        return Models::scope()->applyToRelation($relation);
    }
382501
public function perform_turn()
    {
        if ($this->position) {
            foreach ($this->abilities as $ability) {
                $ability->pass_turn();
            }
            if ($this->current_turn->action && !$this->is_bound()) {
                list ($name, $args) = $this->current_turn->action;
                call_user_func_array([$this->abilities[$name], 'perform'], $args);
                //$this->abilities[$name]->perform($args);
            }
        }
    }
611632
public function run()
    {
        Bouncer::allow('superadmin')->everything();

        $abilities = [
            ['name' => 'list', 'title' => 'List abilities', 'entity_type' => 'ability'],
            ['name' => 'import', 'title' => 'Import abilities', 'entity_type' => 'ability'],
            ['name' => 'create', 'title' => 'Create abilities', 'entity_type' => 'ability'],
            ['name' => 'update', 'title' => 'Update abilities', 'entity_type' => 'ability'],
            ['name' => 'delete', 'title' => 'Delete abilities', 'entity_type' => 'ability'],
            ['name' => 'audit', 'title' => 'Audit abilities', 'entity_type' => 'ability'],
            ['name' => 'grant', 'title' => 'Grant abilities', 'entity_type' => 'ability'],

            ['name' => 'list', 'title' => 'List roles', 'entity_type' => 'role'],
            ['name' => 'import', 'title' => 'Import roles', 'entity_type' => 'role'],
            ['name' => 'create', 'title' => 'Create roles', 'entity_type' => 'role'],
            ['name' => 'update', 'title' => 'Update roles', 'entity_type' => 'role'],
            ['name' => 'delete', 'title' => 'Delete roles', 'entity_type' => 'role'],
            ['name' => 'audit', 'title' => 'Audit roles', 'entity_type' => 'role'],
            ['name' => 'assign', 'title' => 'Assign roles', 'entity_type' => 'role'],

            ['name' => 'list', 'title' => 'List admins', 'entity_type' => 'admin'],
            ['name' => 'import', 'title' => 'Import admins', 'entity_type' => 'admin'],
            ['name' => 'create', 'title' => 'Create admins', 'entity_type' => 'admin'],
            ['name' => 'update', 'title' => 'Update admins', 'entity_type' => 'admin'],
            ['name' => 'delete', 'title' => 'Delete admins', 'entity_type' => 'admin'],
            ['name' => 'audit', 'title' => 'Audit admins', 'entity_type' => 'admin'],

            ['name' => 'list', 'title' => 'List members', 'entity_type' => 'member'],
            ['name' => 'import', 'title' => 'Import members', 'entity_type' => 'member'],
            ['name' => 'create', 'title' => 'Create members', 'entity_type' => 'member'],
            ['name' => 'update', 'title' => 'Update members', 'entity_type' => 'member'],
            ['name' => 'delete', 'title' => 'Delete members', 'entity_type' => 'member'],
            ['name' => 'audit', 'title' => 'Audit members', 'entity_type' => 'member'],

            ['name' => 'list', 'title' => 'List managers', 'entity_type' => 'manager'],
            ['name' => 'import', 'title' => 'Import managers', 'entity_type' => 'manager'],
            ['name' => 'create', 'title' => 'Create managers', 'entity_type' => 'manager'],
            ['name' => 'update', 'title' => 'Update managers', 'entity_type' => 'manager'],
            ['name' => 'delete', 'title' => 'Delete managers', 'entity_type' => 'manager'],
            ['name' => 'audit', 'title' => 'Audit managers', 'entity_type' => 'manager'],

            ['name' => 'list', 'title' => 'List guardians', 'entity_type' => 'guardian'],
            ['name' => 'import', 'title' => 'Import guardians', 'entity_type' => 'guardian'],
            ['name' => 'create', 'title' => 'Create guardians', 'entity_type' => 'guardian'],
            ['name' => 'update', 'title' => 'Update guardians', 'entity_type' => 'guardian'],
            ['name' => 'delete', 'title' => 'Delete guardians', 'entity_type' => 'guardian'],
            ['name' => 'audit', 'title' => 'Audit guardians', 'entity_type' => 'guardian'],
        ];

        collect($abilities)->each(function (array $ability) {
            app('cortex.auth.ability')->create($ability);
        });
    }
1104178
private function checkDefinitions(): void {
    // Add many to many stuff if necessary
    foreach($this->unchecked as $def) {
      foreach($def->many_to_many as $relation) {
        //echo "Processing many to many for {$def->name}\n";

        // Set up left keys
        $related = $this->defs[$relation->entity_left];

        if(empty($relation->id_left)) {
          //echo "Setting {$relation->alias_join} id_left to {$related->id->alias}\n";
          $relation->idLeft($related->id->alias);
        }

        if(empty($relation->key_left)) {
          //echo "Setting {$relation->alias_join} key_left to " . keyify($related->name) . "\n";
          $relation->keyLeft(keyify($related->name));
        }
        //

        // Set up right keys
        $related = $this->defs[$relation->entity_right];

        if(empty($relation->id_right)) {
          //echo "Setting {$relation->alias_join} id_right to {$related->id->alias}\n";
          $relation->idRight($related->id->alias);
        }

        if(empty($relation->key_right)) {
          //echo "Setting {$relation->alias_join} key_right to " . keyify($related->name) . "\n";
          $relation->keyRight(keyify($related->name));
        }
        //

        // Left side relations
        $related = $this->defs[$relation->entity_left];

        //echo "Adding {$related->name} hasManyThrough {$relation->alias_join} to {$relation->alias_right}\n";
        $related->hasManyThrough(pluralize($relation->alias_right), $relation->entity_join, $relation->entity_right)
          ->idLocal($relation->id_left)
          ->idForeign($relation->id_right)
          ->keyLocal($relation->key_left)
          ->keyForeign($relation->key_right)
        ;

        if(!array_key_exists($relation->alias_join, $def->has_many)) {
          //echo "Adding {$related->name} hasMany {$def->name}\n";
          $related->hasMany($relation->alias_join, $def->full_name)
            ->localKey  ($relation->id_left)
            ->foreignKey($relation->key_left)
          ;
        }

        if(!array_key_exists($relation->alias_left, $def->belongs_to)) {
          //echo "Adding {$def->name} belongsTo {$related->name}\n";
          $def->belongsTo($relation->alias_left, $related->full_name);
        }
        //

        // Right side relations
        $related = $this->defs[$relation->entity_right];

        //echo "Adding {$related->name} hasManyThrough {$relation->alias_join} to {$relation->alias_left}\n";
        $related->hasManyThrough(pluralize($relation->alias_left), $relation->entity_join, $relation->entity_left)
          ->idLocal($relation->id_right)
          ->idForeign($relation->id_left)
          ->keyLocal($relation->key_right)
          ->keyForeign($relation->key_left)
        ;

        if(!array_key_exists($relation->alias_join, $def->has_many)) {
          //echo "Adding {$related->name} hasMany {$def->name}\n";
          $related->hasMany($relation->alias_join, $def->full_name)
            ->localKey  ($relation->id_right)
            ->foreignKey($relation->key_right)
          ;
        }

        if(!array_key_exists($relation->alias_right, $def->belongs_to)) {
          //echo "Adding {$def->name} belongsTo {$related->name}\n";
          $def->belongsTo($relation->alias_right, $related->full_name);
        }
        //
      }
    }

    // Add has many stuff if necessary
    foreach($this->unchecked as $def) {
      foreach($def->has_many as $relation) {
        //echo "Processing has many for {$def->name}\n";

        $related = $this->defs[$relation->foreign_entity];

        if(empty($relation->local_key)) {
          //echo "Setting {$relation->alias} local_key to {$def->id->alias}\n";
          $relation->localKey($def->id->alias);
        }

        if(empty($relation->foreign_key)) {
          //echo "Setting {$relation->alias} foreign_key to " . keyify($related->name) . "\n";
          $relation->foreignKey(keyify($related->name));
        }
      }
    }

    // Add belongs to stuff if necessary
    foreach($this->unchecked as $def) {
      foreach($def->belongs_to as $relation) {
        //echo "Processing belongs to for {$def->name}\n";

        $related = $this->defs[$relation->foreign_entity];

        if(empty($relation->local_key)) {
          //echo "Setting {$relation->alias} local_key to " . keyify($related->name) . "\n";
          $relation->localKey(keyify($related->name));
        }

        if(empty($relation->foreign_key)) {
          //echo "Setting {$relation->alias} foreign_key to {$def->id->alias}\n";
          $relation->foreignKey($related->id->alias);
        }

        if(!array_key_exists($relation->local_key, $related->required)) {
          //echo "Adding {$def->name} column {$relation->local_key} of type {$related->id->type}\n";
          $def->required($relation->local_key, $related->id->type);
        }
      }
    }

    // We've checked everything in the queue.  Clear it out.
    $this->unchecked = [];
  }
316342
protected function configure()
    {
        $this
            ->setName('detect')
            ->setDefinition(
                [
                    new InputArgument('path', InputArgument::OPTIONAL, 'path of the project', null),
                    new InputOption(
                        'config-file',
                        'c',
                        InputOption::VALUE_REQUIRED,
                        'File path of the configuration file'
                    ),
                    new InputOption(
                        'format',
                        'f',
                        InputOption::VALUE_REQUIRED,
                        sprintf('Output format (%s)', implode(', ', $this->formats)),
                        $this->formats[0]
                    ),
                ]
            )
            ->setDescription('Detect coupling rules')
            ->setHelp($this->loadHelpContent());
    }
874023
public function setup(){
		if($this->hasOption('autoinit') && $this->options()->autoinit){
			if($this->hasOption('default')){
				$this->setValue($this->options()->default);
			}else{
				$this->setValue('now');
			}
		}
	}
1018593
public function definition () {
        global $CFG, $COURSE, $USER;

        $mform = $this->_form;
        $userid = $USER->id;

        if (is_array($this->_customdata)) {
            if (array_key_exists('userid', $this->_customdata)) {
                $userid = $this->_customdata['userid'];
            }
        }

        // Add some extra hidden fields.
        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);
        $mform->addElement('hidden', 'course', $COURSE->id);
        $mform->setType('course', PARAM_INT);

        $purpose = user_edit_map_field_purpose($userid, 'lang');
        $translations = get_string_manager()->get_list_of_translations();
        $mform->addElement('select', 'lang', get_string('preferredlanguage'), $translations, $purpose);
        $mform->setDefault('lang', core_user::get_property_default('lang'));

        $this->add_action_buttons(true, get_string('savechanges'));
    }
920094
protected function prepareForValidation(): void
    {
        $data = $this->all();

        // Set abilities
        if (! empty($data['abilities'])) {
            if ($this->user($this->route('guard'))->can('grant', \Cortex\Auth\Models\Ability::class)) {
                $abilities = array_map('intval', $this->get('abilities', []));
                $data['abilities'] = $this->user($this->route('guard'))->isA('superadmin') ? $abilities
                    : $this->user($this->route('guard'))->getAbilities()->pluck('id')->intersect($abilities)->toArray();
            } else {
                unset($data['abilities']);
            }
        }

        $this->replace($data);
    }
321791
public function allows($ability, $arguments = array())
    {
        if (! is_array($arguments)) {
            $arguments = array_slice(func_get_args(), 1);
        }

        return $this->check($ability, $arguments);
    }
500188
protected function configure(): void
    {
        $this
            ->setName('make:model')
            ->setDescription('Creates a new App model')
            ->addArgument(
                'modelName',
                InputArgument::OPTIONAL,
                'Define the name of the model to create'
            )
            ->addOption(
                'skip-db',
                null,
                InputOption::VALUE_NONE,
                'Skip database table creation'
            )
            ->addOption(
                'skip-seeder',
                null,
                InputOption::VALUE_NONE,
                'Skip seeder creation'
            )
            ->addOption(
                'auto-detect',
                null,
                InputOption::VALUE_NONE,
                'Automatically build models from the database'
            )
            ->addOption(
                'localised',
                null,
                InputOption::VALUE_NONE,
                'Create a localised model (or convert an existing model)'
            );

        if (Components::exists('nails/module-admin')) {
            $this->addOption(
                'admin',
                null,
                InputOption::VALUE_NONE,
                'Create an admin controller'
            );
        }
    }
1306911
public function define()
    {
        $this->eventEmitter->emit('suite.define', [$this]);
        call_user_func_array($this->getDefinition(), $this->getDefinitionArguments());
    }
753949
public function enable()
    {
        $this->manager->enable($this);

        if ($this->referenced) {
            $this->manager->reference($this);
        }
    }
823504
public function init()
    {
        $this->options['disable_capable'] = array(
            'description' => /*@translate*/ 'Request additional facts from the Applicant. Selected Fields will be added to the application Form.',
        );
        $this->setLabel('Facts');
        $this->setIsDescriptionsEnabled(true);
        $this->setDescription(/*@translate*/ 'Please provide some additional facts for this job opening.');
        $this->setIsDisableCapable(true);
        $this->setIsDisableElementsCapable(true);

        parent::init();
    }