Skip to content

Commit

Permalink
Refinery: implement in new component framework
Browse files Browse the repository at this point in the history
  • Loading branch information
klees committed Jan 19, 2024
1 parent 97f8e00 commit 0da1d1a
Show file tree
Hide file tree
Showing 60 changed files with 172 additions and 132 deletions.
6 changes: 5 additions & 1 deletion components/ILIAS/Refinery/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public function init(
array | \ArrayAccess &$pull,
array | \ArrayAccess &$internal,
): void {
// ...
$provide[\ILIAS\Refinery\Factory::class] = fn() =>
new \ILIAS\Refinery\Factory(
$pull[\ILIAS\Data\Factory::class],
$use[\ILIAS\Language\Language::class]
);
}
}
8 changes: 4 additions & 4 deletions components/ILIAS/Refinery/src/Custom/Constraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use ILIAS\Data;
use ILIAS\Data\Result;
use ILIAS\Refinery\ProblemBuilder;
use ilLanguage;
use ILIAS\Language\Language;

class Constraint implements ConstraintInterface
{
Expand All @@ -35,7 +35,7 @@ class Constraint implements ConstraintInterface
use ProblemBuilder;

protected Data\Factory $data_factory;
protected ilLanguage $lng;
protected \ILIAS\Language\Language $lng;
/** @var callable */
protected $is_ok;
/** @var callable|string */
Expand All @@ -51,9 +51,9 @@ class Constraint implements ConstraintInterface
* @param callable $is_ok
* @param string|callable $error
* @param Data\Factory $data_factory
* @param ilLanguage $lng
* @param \ILIAS\Language\Language $lng
*/
public function __construct(callable $is_ok, $error, Data\Factory $data_factory, ilLanguage $lng)
public function __construct(callable $is_ok, $error, Data\Factory $data_factory, \ILIAS\Language\Language $lng)
{
$this->is_ok = $is_ok;
$this->error = $error;
Expand Down
6 changes: 3 additions & 3 deletions components/ILIAS/Refinery/src/Custom/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
namespace ILIAS\Refinery\Custom;

use ILIAS\Data\Factory;
use ilLanguage;
use ILIAS\Language\Language;
use ILIAS\Refinery\Constraint as ConstraintInterface;
use ILIAS\Refinery\Transformation as TransformationInterface;

class Group
{
private Factory $dataFactory;
private ilLanguage $language;
private \ILIAS\Language\Language $language;

public function __construct(Factory $dataFactory, ilLanguage $language)
public function __construct(Factory $dataFactory, \ILIAS\Language\Language $language)
{
$this->dataFactory = $dataFactory;
$this->language = $language;
Expand Down
6 changes: 3 additions & 3 deletions components/ILIAS/Refinery/src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
use ILIAS\Refinery\In;
use ILIAS\Refinery\To;
use ILIAS\Refinery\Random\Group as RandomGroup;
use ilLanguage;
use ILIAS\Language\Language;

class Factory
{
private \ILIAS\Data\Factory $dataFactory;
private ilLanguage $language;
private \ILIAS\Language\Language $language;

public function __construct(\ILIAS\Data\Factory $dataFactory, ilLanguage $language)
public function __construct(\ILIAS\Data\Factory $dataFactory, \ILIAS\Language\Language $language)
{
$this->dataFactory = $dataFactory;
$this->language = $language;
Expand Down
36 changes: 36 additions & 0 deletions components/ILIAS/Refinery/src/FactoryFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

declare(strict_types=1);

namespace ILIAS\Refinery;

use ILIAS\Language\Language;

/**
* This Javaism is required to solve the problem that we do not have proper
* \ILIAS\Language\Language during the setup. There might be setups where this would be
* superfluous.
*/
class FactoryFactory
{
public function build(\ILIAS\Data\Factory $dataFactory, \ILIAS\Language\Language $language): \ILIAS\Refinery\Factory
{
return new \ILIAS\Refinery\Factory($dataFactory, $language);
}
}
4 changes: 2 additions & 2 deletions components/ILIAS/Refinery/src/Integer/GreaterThan.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

use ILIAS\Data;
use ILIAS\Refinery\Custom\Constraint;
use ilLanguage;
use ILIAS\Language\Language;

class GreaterThan extends Constraint
{
public function __construct(int $min, Data\Factory $data_factory, ilLanguage $lng)
public function __construct(int $min, Data\Factory $data_factory, \ILIAS\Language\Language $lng)
{
parent::__construct(
static function ($value) use ($min): bool {
Expand Down
4 changes: 2 additions & 2 deletions components/ILIAS/Refinery/src/Integer/GreaterThanOrEqual.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

use ILIAS\Data;
use ILIAS\Refinery\Custom\Constraint;
use ilLanguage;
use ILIAS\Language\Language;

class GreaterThanOrEqual extends Constraint
{
public function __construct(int $min, Data\Factory $data_factory, ilLanguage $lng)
public function __construct(int $min, Data\Factory $data_factory, \ILIAS\Language\Language $lng)
{
parent::__construct(
static function ($value) use ($min): bool {
Expand Down
6 changes: 3 additions & 3 deletions components/ILIAS/Refinery/src/Integer/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@

use ILIAS\Data\Factory;
use ILIAS\Refinery\Constraint;
use ilLanguage;
use ILIAS\Language\Language;

class Group
{
private Factory $dataFactory;
private ilLanguage $language;
private \ILIAS\Language\Language $language;

public function __construct(Factory $dataFactory, ilLanguage $language)
public function __construct(Factory $dataFactory, \ILIAS\Language\Language $language)
{
$this->dataFactory = $dataFactory;
$this->language = $language;
Expand Down
4 changes: 2 additions & 2 deletions components/ILIAS/Refinery/src/Integer/LessThan.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

use ILIAS\Data;
use ILIAS\Refinery\Custom\Constraint;
use ilLanguage;
use ILIAS\Language\Language;

class LessThan extends Constraint
{
public function __construct(int $max, Data\Factory $data_factory, ilLanguage $lng)
public function __construct(int $max, Data\Factory $data_factory, \ILIAS\Language\Language $lng)
{
parent::__construct(
static function ($value) use ($max): bool {
Expand Down
4 changes: 2 additions & 2 deletions components/ILIAS/Refinery/src/Integer/LessThanOrEqual.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

use ILIAS\Data;
use ILIAS\Refinery\Custom\Constraint;
use ilLanguage;
use ILIAS\Language\Language;

class LessThanOrEqual extends Constraint
{
public function __construct(int $max, Data\Factory $data_factory, ilLanguage $lng)
public function __construct(int $max, Data\Factory $data_factory, \ILIAS\Language\Language $lng)
{
parent::__construct(
static function ($value) use ($max): bool {
Expand Down
4 changes: 2 additions & 2 deletions components/ILIAS/Refinery/src/IsNull.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

use ILIAS\Refinery\Custom\Constraint;
use ILIAS\Data;
use ilLanguage;
use ILIAS\Language\Language;

class IsNull extends Constraint
{
public function __construct(Data\Factory $data_factory, ilLanguage $lng)
public function __construct(Data\Factory $data_factory, \ILIAS\Language\Language $lng)
{
parent::__construct(
static function ($value): bool {
Expand Down
6 changes: 3 additions & 3 deletions components/ILIAS/Refinery/src/Logical/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
use ILIAS\Data\Factory;
use ILIAS\Refinery\Custom\Constraint;
use ILIAS\Refinery\Constraint as ConstraintInterface;
use ilLanguage;
use ILIAS\Language\Language;

class Group
{
private Factory $dataFactory;
private ilLanguage $language;
private \ILIAS\Language\Language $language;

public function __construct(Factory $dataFactory, ilLanguage $language)
public function __construct(Factory $dataFactory, \ILIAS\Language\Language $language)
{
$this->dataFactory = $dataFactory;
$this->language = $language;
Expand Down
6 changes: 3 additions & 3 deletions components/ILIAS/Refinery/src/Logical/LogicalOr.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@

use ILIAS\Refinery\Custom\Constraint;
use ILIAS\Data;
use ilLanguage;
use ILIAS\Language\Language;

class LogicalOr extends Constraint
{
/**
* LogicalOr constructor.
* @param Constraint[] $other
* @param Data\Factory $data_factory
* @param ilLanguage $lng
* @param \ILIAS\Language\Language $lng
*/
public function __construct(array $other, Data\Factory $data_factory, ilLanguage $lng)
public function __construct(array $other, Data\Factory $data_factory, \ILIAS\Language\Language $lng)
{
parent::__construct(
static function ($value) use ($other): bool {
Expand Down
4 changes: 2 additions & 2 deletions components/ILIAS/Refinery/src/Logical/Not.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

use ILIAS\Refinery\Custom\Constraint;
use ILIAS\Data;
use ilLanguage;
use ILIAS\Language\Language;

class Not extends Constraint
{
public function __construct(Constraint $constraint, Data\Factory $data_factory, ilLanguage $lng)
public function __construct(Constraint $constraint, Data\Factory $data_factory, \ILIAS\Language\Language $lng)
{
parent::__construct(
static function ($value) use ($constraint) {
Expand Down
6 changes: 3 additions & 3 deletions components/ILIAS/Refinery/src/Logical/Parallel.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use ILIAS\Refinery\Custom\Constraint;
use ILIAS\Data;
use ilLanguage;
use ILIAS\Language\Language;

class Parallel extends Constraint
{
Expand All @@ -37,9 +37,9 @@ class Parallel extends Constraint
/**
* @param Constraint[] $constraints
* @param Data\Factory $data_factory
* @param ilLanguage $lng
* @param \ILIAS\Language\Language $lng
*/
public function __construct(array $constraints, Data\Factory $data_factory, ilLanguage $lng)
public function __construct(array $constraints, Data\Factory $data_factory, \ILIAS\Language\Language $lng)
{
parent::__construct(
function ($value) use ($constraints): bool {
Expand Down
6 changes: 3 additions & 3 deletions components/ILIAS/Refinery/src/Logical/Sequential.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use ILIAS\Refinery\Custom\Constraint as CustomConstraint;
use ILIAS\Refinery\Constraint;
use ILIAS\Data;
use ilLanguage;
use ILIAS\Language\Language;

class Sequential extends CustomConstraint
{
Expand All @@ -38,9 +38,9 @@ class Sequential extends CustomConstraint
/**
* @param Constraint[] $constraints
* @param Data\Factory $data_factory
* @param ilLanguage $lng
* @param \ILIAS\Language\Language $lng
*/
public function __construct(array $constraints, Data\Factory $data_factory, ilLanguage $lng)
public function __construct(array $constraints, Data\Factory $data_factory, \ILIAS\Language\Language $lng)
{
parent::__construct(
function ($value) use ($constraints): bool {
Expand Down
6 changes: 3 additions & 3 deletions components/ILIAS/Refinery/src/Numeric/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@

use ILIAS\Data\Factory;
use ILIAS\Refinery\Constraint;
use ilLanguage;
use ILIAS\Language\Language;

class Group
{
private Factory $dataFactory;
private ilLanguage $language;
private \ILIAS\Language\Language $language;

public function __construct(Factory $dataFactory, ilLanguage $language)
public function __construct(Factory $dataFactory, \ILIAS\Language\Language $language)
{
$this->dataFactory = $dataFactory;
$this->language = $language;
Expand Down
4 changes: 2 additions & 2 deletions components/ILIAS/Refinery/src/Numeric/IsNumeric.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

use ILIAS\Refinery\Custom\Constraint;
use ILIAS\Data;
use ilLanguage;
use ILIAS\Language\Language;

class IsNumeric extends Constraint
{
public function __construct(Data\Factory $data_factory, ilLanguage $lng)
public function __construct(Data\Factory $data_factory, \ILIAS\Language\Language $lng)
{
parent::__construct(
static function ($value): bool {
Expand Down
6 changes: 3 additions & 3 deletions components/ILIAS/Refinery/src/Password/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@

use ILIAS\Data\Factory;
use ILIAS\Refinery\Constraint;
use ilLanguage;
use ILIAS\Language\Language;

class Group
{
protected Factory $data_factory;
protected ilLanguage $lng;
protected \ILIAS\Language\Language $lng;

public function __construct(Factory $data_factory, ilLanguage $lng)
public function __construct(Factory $data_factory, \ILIAS\Language\Language $lng)
{
$this->data_factory = $data_factory;
$this->lng = $lng;
Expand Down
4 changes: 2 additions & 2 deletions components/ILIAS/Refinery/src/Password/HasLowerChars.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

use ILIAS\Refinery\Custom\Constraint;
use ILIAS\Data;
use ilLanguage;
use ILIAS\Language\Language;

class HasLowerChars extends Constraint
{
public function __construct(Data\Factory $data_factory, ilLanguage $lng)
public function __construct(Data\Factory $data_factory, \ILIAS\Language\Language $lng)
{
parent::__construct(
static function (Data\Password $value): bool {
Expand Down
4 changes: 2 additions & 2 deletions components/ILIAS/Refinery/src/Password/HasMinLength.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

use ILIAS\Refinery\Custom\Constraint;
use ILIAS\Data;
use ilLanguage;
use ILIAS\Language\Language;

class HasMinLength extends Constraint
{
public function __construct(int $min_length, Data\Factory $data_factory, ilLanguage $lng)
public function __construct(int $min_length, Data\Factory $data_factory, \ILIAS\Language\Language $lng)
{
parent::__construct(
static function (Data\Password $value) use ($min_length): bool {
Expand Down
4 changes: 2 additions & 2 deletions components/ILIAS/Refinery/src/Password/HasNumbers.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

use ILIAS\Refinery\Custom\Constraint;
use ILIAS\Data;
use ilLanguage;
use ILIAS\Language\Language;

class HasNumbers extends Constraint
{
public function __construct(Data\Factory $data_factory, ilLanguage $lng)
public function __construct(Data\Factory $data_factory, \ILIAS\Language\Language $lng)
{
parent::__construct(
static function (Data\Password $value): bool {
Expand Down
Loading

0 comments on commit 0da1d1a

Please sign in to comment.