Returns only writable columns

@param array                  $rules   all Columns
@param \FlexiPeeHP\FlexiBeeRW $engine  saver class
344396
public static function removeRoColumns(array $rules, $engine)
    {
        foreach ($rules as $index => $subrules) {
            if (is_array($subrules)) {
                $eback         = $engine->getEvidence();
                $engine->setEvidence($engine->getEvidence().'-polozka');
                $rules[$index] = self::removeRoColumns($subrules, $engine);
                $engine->setEvidence($eback);
            } else {
                $columnInfo = $engine->getColumnInfo($subrules);
                if ($columnInfo['isWritable'] == 'false') {
                    unset($rules[$index]);
                }
            }
        }
        return $rules;
    }
674458
public function buildRules(RulesChecker $rules)
    {
        // check max instances limit
        $rules->addCreate(function ($instance, $options) {
            $info = (array)$instance->info();
            if (isset($info['maxInstances']) && $info['maxInstances'] > 0) {
                if (!$instance->get('eav_attribute')) {
                    return false;
                }

                $count = $this
                    ->find()
                    ->select(['FieldInstances.id', 'FieldInstances.handler', 'EavAttribute.id', 'EavAttribute.table_alias'])
                    ->contain(['EavAttribute'])
                    ->where([
                        'EavAttribute.table_alias' => $instance->get('eav_attribute')->get('table_alias'),
                        'FieldInstances.handler' => $instance->get('handler'),
                    ])
                    ->count();

                return ($count <= (intval($info['maxInstances']) - 1));
            }

            return true;
        }, 'maxInstances', [
            'errorField' => 'label',
            'message' => __d('field', 'No more instances of this field can be attached, limit reached.'),
        ]);

        return $rules;
    }
41437
private function processRules(string $key, array $rules, array $insert): array
    {
        $status = true;

        if (!isset($insert[$key])) {
            $status  = false;
            $message = 'Schema key [%s] not present on insert.';
        }

        do {
            $r = array_shift($rules);
            $method = 'checkRule'. ucfirst($r);

            if (!in_array($r, $this->rules)) {
                // There's no rule defined and allowed.
                continue;
            }

            if (!$this->{$method}($insert[$key])) {
                // When given key is not valid we need to stop process
                // and set message related to validation error.
                $status  = false;
                $message = $this->messages()[$r];
                break;
            }

        } while (count($rules));

        return compact('status', 'message');
    }
417506
protected function rulesArrayContainsAnyNestedRules(array $rules)
    {
        foreach ($rules as $rule) {

            if ( ! empty($rule->key())) {
                return true;
            }
        }

        return false;
    }
936826
public static function make(array $data, array $rules)
    {
        self::$validator = new V([]);
        self::$validator->labels($data);

        foreach ($rules as $rule => $columns) {
            if (is_string($columns)) {
                $columns = self::separte($columns);
            } else {
                $columns = $columns;
            }

            $value = self::getValue($rule);

            self::$validator->rule($value['rule'], $columns, $value['value']);
        }

        return new ValidationResult(self::$validator);
    }
779822
public function getRules()
    {
        if (!$this->rules) {
            return '[]';
        }
        $results = '[' . PHP_EOL;

        foreach ($this->getSchemaParser()->toArray() as $column => $value) {
            $results .= "\t\t'{$column}'\t=>'\t{$value}'," . PHP_EOL;
        }

        return $results . "\t" . ']';
    }
1356495
private function getRuleSelectQuery(): QueryBuilder
    {
        $query = $this->connection->createQueryBuilder();
        $query->select('DISTINCT r.*', 'rd.*')
            ->from('ngbm_rule', 'r')
            ->innerJoin(
                'r',
                'ngbm_rule_data',
                'rd',
                $query->expr()->eq('rd.rule_id', 'r.id')
            );

        return $query;
    }
476704
public static function getRules()
    {
        $instance = static::getInstance();

        $fillables = $instance->getFillables();

        $structure = $instance->getStructure();

        $rules = $instance->rules;

        if(!$rules){
            $rules = [];

            foreach($structure as $key => $column){
                $rules[$key] = '';
            }
        }

        return $rules;
    }
708202
public static function getRulesEndIndexes(array $arrayRulesIndexes): array
    {
        assert(array_key_exists(static::RULES_ARRAY_END_INDEXES, $arrayRulesIndexes));
        $result = $arrayRulesIndexes[static::RULES_ARRAY_END_INDEXES];

        return $result;
    }
324080
public function handleImageRules($model, $rules)
    {

        // If the model is an image, the rules were passed in by NestedModels
        // and are good to go
        if (is_a($model, Image::class)) {
            return $rules;
        }

        // Otherwise, remove any image rules because this is a non-Image and
        // these rules will get applied by NestedModels
        return array_where($rules, function ($val, $key) {
            return !starts_with($key, 'images.');
        });
    }
1370791
public function createQueryParser(string $rulesClass): JsonApiQueryParserInterface
    {
        $serializedData = FluteSettings::getJsonQuerySerializedRules($this->getFluteSettings());

        /** @var FormatterFactoryInterface $formatterFactory */
        $formatterFactory = $this->getContainer()->get(FormatterFactoryInterface::class);
        $parser           = new QueryParser(
            $rulesClass,
            JsonApiQueryRulesSerializer::class,
            $serializedData,
            new ContextStorage(JsonApiQueryRulesSerializer::readBlocks($serializedData), $this->getContainer()),
            new CaptureAggregator(),
            new ErrorAggregator(),
            new JsonApiErrorCollection($formatterFactory->createFormatter(Messages::NAMESPACE_NAME)),
            $this->getContainer()->get(FormatterFactoryInterface::class)
        );

        return $parser;
    }
1129380
private function createRuleTable($installer)
    {
        $tableName = $installer->getTable(Schema::EMAIL_RULES_TABLE);
        $this->dropTableIfExists($installer, $tableName);

        $ruleTable = $installer->getConnection()->newTable($tableName);
        $ruleTable = $this->addColumnsToRulesTable($ruleTable);
        $ruleTable->setComment('Connector Rules');
        $installer->getConnection()->createTable($ruleTable);
    }
132566
protected function parseRulesArray(array $rules)
    {
        $parsedRules = [];

        $rawRules = (new ValidationRuleParser($this->data))->explode($rules);

        foreach ($rawRules->rules as $attribute => $attributeRules) {
            foreach ($attributeRules as $attributeRule) {
                $parsedRule = $this->parseRuleString($attributeRule);
                if ($parsedRule) {
                    $parsedRules[$attribute][] = $parsedRule;
                }
            }
        }

        return $parsedRules;
    }
300617
protected function resultsToModels($connection, ResultSet $results, array $columns = [])
    {
        $models = [];

        if ($results->valid())
        {
            $resultColumns = $results->getColumns();

            foreach ($results as $result)
            {
                $attributes = $this->getProperties($resultColumns, $result, $columns);

                // Now that we have the attributes, we first check for mutations
                // and if exists, we will need to mutate the attributes accordingly.
                if ($this->shouldMutate($attributes))
                {
                    $models[] = $this->mutateToOrigin($result, $attributes);
                }
                // This is a regular record that we should deal with the normal way, creating an instance
                // of the model out of the fetched attributes.
                else
                {
                    $model = $this->model->newFromBuilder($attributes);
                    $model->setConnection($connection);
                    $models[] = $model;
                }
            }
        }

        return $models;
    }
1247428
public static function loadRules() {
		
		// default var
		$configDir = Config::getOption("configDir");
		
		// make sure the pattern engine data exists
		if (file_exists($configDir."/patternengines.json")) {
			
			// get pattern engine list data
			$patternEngineList = json_decode(file_get_contents($configDir."/patternengines.json"), true);
			
			// get the pattern engine info
			foreach ($patternEngineList["patternengines"] as $patternEngineName) {
				
				self::$rules[] = new $patternEngineName();
				
			}
			
		} else {
			Console::writeError("The pattern engines list isn't available in <path>".$configDir."</path>...");
		}
		
	}
15980
public function add_rules( array $rules ) {
		foreach ( $rules as $name => $rule ) {
			$this->add_rule( $name, $rule );
		}

		return $this;
	}
916341
public function rewrite_rules_array( array $rules ){
        if( !empty($this->rewrites) ){
            $rules = array_merge($this->rewrites, $rules);
        }
        return $rules;
    }