Seed block types

@return void
491822
private function seedBlockTypes()
    {
        BlockType::firstOrCreate(['name' => 'basic', 'handler' => Gzero\Cms\Handlers\Block\Basic::class]);
        BlockType::firstOrCreate(['name' => 'menu', 'handler' => Gzero\Cms\Handlers\Block\Menu::class]);
        BlockType::firstOrCreate(['name' => 'slider', 'handler' => Gzero\Cms\Handlers\Block\Slider::class]);
    }
333242
protected function blockChildren(OutputBlock $block)
    {
        foreach ($block->children as $child) {
            $this->block($child);
        }
    }
829469
public function delete()
    {
        $app = Application::getFacadeApplication();
        $db = $app->make(Connection::class);
        $db->delete('BlockTypeSetBlockTypes', ['btsID' => $this->getBlockTypeSetID()]);
        $db->delete('BlockTypeSets', ['btsID' => $this->getBlockTypeSetID()]);
    }
1279849
private function seedUserTables()
    {
        if (Status::count() === 0) {
            $this->comment('Seeding user_statuses...');
            $this->call('db:seed', ['--class' => 'UserStatus']);
        } else {
            $this->comment('Table user_statuses is not empty.  Skipping seed...');
        }

        if (Role::count() === 0) {
            $this->comment('Seeding rbac_roles...');
            $this->call('db:seed', ['--class' => 'UserRoles']);
        } else {
            $this->comment('Table rbac_roles is not empty.  Skipping seed...');
        }
    }
657216
final private function set_control_types() {

		// Early exit if this has already run.
		if ( ! empty( self::$control_types ) ) {
			return;
		}

		self::$control_types = apply_filters( 'kirki_control_types', [] );

		// Make sure the defined classes actually exist.
		foreach ( self::$control_types as $key => $classname ) {
			if ( ! class_exists( $classname ) ) {
				unset( self::$control_types[ $key ] );
			}
		}
	}
1367890
public function run(): void
    {
        // Set default privacy settings for new trees
        foreach (self::DEFAULT_RESTRICTIONS as $tag_type => $resn) {
            DB::table('default_resn')->updateOrInsert([
                'gedcom_id' => -1,
                'tag_type'  => $tag_type,
            ], [
                'resn'      => $resn,
            ]);
        }
    }
697925
public function run()
    {
        Model::unguard();
        try {
            foreach ($this->seederClasses as $seederClass) {
                $this->parentSeeder->call($seederClass);
            }
        } finally {
            Model::reguard();
        }
    }
562102
public function run()
    {
        // php artisan db:seed --class="PermissionsTableSeeder"
        $permissions = [
            [
                'name' => 'manage_users',
            ],
            [
                'name' => 'manage_pages',
            ],
            [
                'name' => 'access_admin',
            ],
        ];

        // Only add new
        $allPermissions = Permission::all()->pluck('name')->toArray();

        foreach ($permissions as $permission) {
            if (! in_array($permission['name'], $allPermissions)) {
                Permission::create($permission);
            }
        }
    }
1106519
private function generateBlockTypeGroupConfig(array $blockTypeGroups, array $blockTypes): array
    {
        $missingBlockTypes = [];

        // We will add all blocks which are not located in any group to a custom group
        // if it exists
        if (isset($blockTypeGroups['custom'])) {
            foreach (array_keys($blockTypes) as $blockType) {
                foreach ($blockTypeGroups as $blockTypeGroup) {
                    if (in_array($blockType, $blockTypeGroup['block_types'], true)) {
                        continue 2;
                    }
                }

                $missingBlockTypes[] = $blockType;
            }

            $blockTypeGroups['custom']['block_types'] = array_merge(
                $blockTypeGroups['custom']['block_types'],
                $missingBlockTypes
            );
        }

        return $blockTypeGroups;
    }
1374281
private function seedContentTypes()
    {
        ContentType::firstOrCreate(['name' => 'content', 'handler' => Gzero\Cms\Handlers\Content\ContentHandler::class]);
        ContentType::firstOrCreate(['name' => 'category', 'handler' => Gzero\Cms\Handlers\Content\CategoryHandler::class]);
    }
445014
public static function matrixFieldsOfType(MatrixBlock $matrixBlock, string $fieldType): array
    {
        $foundFields = [];

        try {
            $matrixBlockTypeModel = $matrixBlock->getType();
        } catch (InvalidConfigException $e) {
            $matrixBlockTypeModel = null;
        }
        if ($matrixBlockTypeModel) {
            $fields = $matrixBlockTypeModel->getFields();
            /** @var  $field BaseField */
            foreach ($fields as $field) {
                if ($field instanceof $fieldType) {
                    $foundFields[] = $field->handle;
                }
            }
        }

        return $foundFields;
    }
1078073
public function setBlock($block)
    {
        if (!empty($block) && $block <= 4 && $block !== 0 && !($block < 0)) {
            $this->block = $block;
        }
    }
1327660
public function getBlockTypes()
    {
        $types = array();
        foreach ($this->alBlocks as $block) {
            $type = $block->getType();
            if ( !in_array($type, $types)) {
                $types[] = $type;
            }
        }

        return $types;
    }
1293216
public function getBlockTypeComposerTemplates()
    {
        $btHandle = $this->getBlockTypeHandle();
        $files = array();
        $fh = Loader::helper('file');
        $dir = DIR_FILES_BLOCK_TYPES . "/{$btHandle}/" . DIRNAME_BLOCK_TEMPLATES_COMPOSER;
        if (is_dir($dir)) {
            $files = array_merge($files, $fh->getDirectoryContents($dir));
        }
        foreach (PackageList::get()->getPackages() as $pkg) {
            $dir =
                (is_dir(DIR_PACKAGES . '/' . $pkg->getPackageHandle()) ? DIR_PACKAGES : DIR_PACKAGES_CORE)
                . '/' . $pkg->getPackageHandle() . '/' . DIRNAME_BLOCKS . '/' . $btHandle . '/' . DIRNAME_BLOCK_TEMPLATES_COMPOSER;
            if (is_dir($dir)) {
                $files = array_merge($files, $fh->getDirectoryContents($dir));
            }
        }
        $dir = DIR_FILES_BLOCK_TYPES_CORE . "/{$btHandle}/" . DIRNAME_BLOCK_TEMPLATES_COMPOSER;
        if (file_exists($dir)) {
            $files = array_merge($files, $fh->getDirectoryContents($dir));
        }
        $templates = array();
        foreach (array_unique($files) as $file) {
            $templates[] = new TemplateFile($this, $file);
        }

        return TemplateFile::sortTemplateFileList($templates);
    }
814386
public function seedDatabase(): void
    {
        (new SeedSiteSettingTable())->run();
        (new SeedUserTable())->run();
        (new SeedGedcomTable())->run();
        (new SeedGedcomSettingTable())->run();
        (new SeedDefaultResnTable())->run();
    }
1318885
protected function ensureInitialized($blockType)
    {
        if ($blockType instanceof BlockTypeInterface) {
            $name = $blockType->getName();
            $type = $blockType;
        } else {
            $name = $blockType;
            $type = null;
        }

        if (!isset($this->types[$name])) {
            if (!$type) {
                $type = $this->registry->getType($name);
            }

            $types      = [$type];
            $typeName   = $type->getName();
            $names      = [$typeName];
            $nameMap    = [$typeName => true];
            $parentName = $type->getParent();
            while ($parentName) {
                if (isset($this->types[$parentName])) {
                    // use data from already loaded parent type
                    $types   = array_merge($this->types[$parentName], array_reverse($types));
                    $names   = array_merge($this->names[$parentName], array_reverse($names));
                    $nameMap = array_merge($nameMap, $this->nameMap[$parentName]);
                    break;
                } else {
                    $type     = $this->registry->getType($parentName);
                    $typeName = $type->getName();

                    $types[]            = $type;
                    $names[]            = $typeName;
                    $nameMap[$typeName] = true;

                    $parentName = $type->getParent();
                }
            }

            if (null === $parentName) {
                $types = array_reverse($types);
                $names = array_reverse($names);
            }

            $this->types[$name]   = $types;
            $this->names[$name]   = $names;
            $this->nameMap[$name] = $nameMap;

            // initialise all parent types if them are not initialized yet
            $typeNames = array_keys($nameMap);
            $offset    = 0;
            while (false !== ($typeName = next($typeNames))) {
                if (isset($this->nameMap[$typeName])) {
                    break;
                }

                $offset++;
                $this->types[$typeName]   = array_slice($types, 0, -$offset);
                $this->names[$typeName]   = array_slice($names, 0, -$offset);
                $this->nameMap[$typeName] = array_slice($nameMap, $offset);
            }
        }

        return $name;
    }
1119134
private function generateSeeder()
    {
        // Get the stub file and format our permissions.
        $stub        = $this->files->get(__DIR__ . '/stubs/Seeder.stub');
        $permissions = $this->permissions->map(function ($permission) {
            return (array)$permission;
        });
        $permissions = $this->export($permissions->toArray(), "\t");

        // Replace the parts of the stub with actual data.
        $patterns = [
            '__NAME__',
            '__TABLE__',
            '__INSERTS__',
        ];

        $replace = [
            'RbacPermissions',
            'rbac_permissions',
            $permissions,
        ];

        $stub = str_replace($patterns, $replace, $stub);

        // Save the file.
        $this->files->put(base_path('database/seeds/RbacPermissions.php'), $stub);
    }