This repository has been archived by the owner on Jul 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create branch * Model (draft) * Migrations * draft * wip * First form (draft) * New organization form. * Organization: from multiple to single. * Badge creation * Badge edition * Add/remove assertion. * my badges tool * OpenBadges custom routes * wip * Goes through the mozailla validator fine now. * Tags & durations * workspace tool * badge in workspace upgrade * Workspace badge creation * Much cleaner * Assertion page. * Merging all tools into one (that was easy after all) * Adding some conditions * Wip (badge card) * Reorganize some code * Badge field for form (no picker yet but display is ok) * user field type (no picker yet) * Evidences (draft) * single group field + issuing mode (no backend save change yet) * Migrations reset & test. * Fixing user creation * IssuingModes saved * add user modal for badges refactored * Evidence resources * wip * Fixing forms & display * Proper invalidation * security * enable/disable * readytotest * merge * Refactoring user actions. * Modely * wip * wtf * crypto (basic) * badge input is now valid with crypto (probably should disable it right now) * merge fix * quick broken fix * absolute urls * grant access ? * next try * oops * restore * Mozilla backpack * wip * wip * done badge migrations * [CoreBundle] wip * Something broken with an update. * some fixes. * Badge validation ? * small update * Copying constraints from JVal * assignation * Update composer.json * composer. * nope * tant pis * increase memory limit * test * test * /shrug * just a test * restore yml file. * bump php versionX * Try composer install * restore * . * Create database. * oops * ça devrait alelr pourtant. * Fixing install * Travis 01 * might work * . * Routing * wip
- Loading branch information
1 parent
0679327
commit 36d83a4
Showing
177 changed files
with
8,711 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
language: php | ||
|
||
php: | ||
- "7.1" | ||
- "7.2" | ||
|
||
addons: | ||
apt: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the JVal package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Claroline\AppBundle\JVal\Constraint; | ||
|
||
use JVal\Constraint; | ||
use JVal\Context; | ||
use JVal\Exception\Constraint\InvalidTypeException; | ||
use JVal\Exception\Constraint\LessThanZeroException; | ||
use JVal\Types; | ||
use JVal\Walker; | ||
use stdClass; | ||
|
||
/** | ||
* Base class for constraints based on a specific number of elements. | ||
*/ | ||
abstract class AbstractCountConstraint implements Constraint | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function normalize(stdClass $schema, Context $context, Walker $walker) | ||
{ | ||
$keyword = $this->keywords()[0]; | ||
$context->enterNode($keyword); | ||
|
||
if (!is_int($schema->{$keyword})) { | ||
throw new InvalidTypeException($context, Types::TYPE_INTEGER); | ||
} | ||
|
||
if ($schema->{$keyword} < 0) { | ||
throw new LessThanZeroException($context); | ||
} | ||
|
||
$context->leaveNode(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the JVal package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Claroline\AppBundle\JVal\Constraint; | ||
|
||
use JVal\Constraint; | ||
use JVal\Context; | ||
use JVal\Exception\Constraint\EmptyArrayException; | ||
use JVal\Exception\Constraint\InvalidTypeException; | ||
use JVal\Types; | ||
use JVal\Walker; | ||
use stdClass; | ||
|
||
/** | ||
* Base class for constraints based on a set of sub-schemas. | ||
*/ | ||
abstract class AbstractOfConstraint implements Constraint | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function supports($type) | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function normalize(stdClass $schema, Context $context, Walker $walker) | ||
{ | ||
$keyword = $this->keywords()[0]; | ||
$context->enterNode($keyword); | ||
|
||
if (!is_array($schema->{$keyword})) { | ||
throw new InvalidTypeException($context, Types::TYPE_ARRAY); | ||
} | ||
|
||
if (0 === count($schema->{$keyword})) { | ||
throw new EmptyArrayException($context); | ||
} | ||
|
||
foreach ($schema->{$keyword} as $index => $subSchema) { | ||
$context->enterNode($index); | ||
|
||
if (!is_object($subSchema)) { | ||
throw new InvalidTypeException($context, Types::TYPE_OBJECT); | ||
} | ||
|
||
$walker->parseSchema($subSchema, $context); | ||
$context->leaveNode(); | ||
} | ||
|
||
$context->leaveNode(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the JVal package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Claroline\AppBundle\JVal\Constraint; | ||
|
||
use JVal\Constraint; | ||
use JVal\Context; | ||
use JVal\Exception\Constraint\InvalidTypeException; | ||
use JVal\Exception\Constraint\MissingKeywordException; | ||
use JVal\Types; | ||
use JVal\Walker; | ||
use stdClass; | ||
|
||
/** | ||
* Base class for constraints based on a numeric limit. | ||
*/ | ||
abstract class AbstractRangeConstraint implements Constraint | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function supports($type) | ||
{ | ||
return Types::TYPE_INTEGER === $type | ||
|| Types::TYPE_NUMBER === $type; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function normalize(stdClass $schema, Context $context, Walker $walker) | ||
{ | ||
$property = $this->keywords()[0]; | ||
$secondaryProperty = $this->keywords()[1]; | ||
|
||
if (!property_exists($schema, $property)) { | ||
throw new MissingKeywordException($context, $property); | ||
} | ||
|
||
if (!property_exists($schema, $secondaryProperty)) { | ||
$schema->{$secondaryProperty} = false; | ||
} | ||
|
||
if (!Types::isA($schema->{$property}, Types::TYPE_NUMBER)) { | ||
$context->enterNode($property); | ||
|
||
throw new InvalidTypeException($context, Types::TYPE_NUMBER); | ||
} | ||
|
||
if (!is_bool($schema->{$secondaryProperty})) { | ||
$context->enterNode($secondaryProperty); | ||
|
||
throw new InvalidTypeException($context, Types::TYPE_BOOLEAN); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the JVal package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Claroline\AppBundle\JVal\Constraint; | ||
|
||
use JVal\Context; | ||
use JVal\Walker; | ||
use stdClass; | ||
|
||
/** | ||
* Constraint for the "allOf" keyword. | ||
*/ | ||
class AllOfConstraint extends AbstractOfConstraint | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function keywords() | ||
{ | ||
return ['allOf']; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function apply($instance, stdClass $schema, Context $context, Walker $walker) | ||
{ | ||
$originalCount = $context->countViolations(); | ||
|
||
foreach ($schema->allOf as $subSchema) { | ||
$walker->applyConstraints($instance, $subSchema, $context); | ||
} | ||
|
||
if ($context->countViolations() > $originalCount) { | ||
$context->addViolation('instance must match all the schemas listed in allOf'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the JVal package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Claroline\AppBundle\JVal\Constraint; | ||
|
||
use JVal\Context; | ||
use JVal\Walker; | ||
use stdClass; | ||
|
||
/** | ||
* Constraint for the "anyOf" keyword. | ||
*/ | ||
class AnyOfConstraint extends AbstractOfConstraint | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function keywords() | ||
{ | ||
return ['anyOf']; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function apply($instance, stdClass $schema, Context $context, Walker $walker) | ||
{ | ||
$accumulatingContext = $context->duplicate(); | ||
$hasMatch = false; | ||
|
||
foreach ($schema->anyOf as $subSchema) { | ||
$originalCount = $accumulatingContext->countViolations(); | ||
$walker->applyConstraints($instance, $subSchema, $accumulatingContext); | ||
|
||
if ($accumulatingContext->countViolations() === $originalCount) { | ||
$hasMatch = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!$hasMatch) { | ||
$context->mergeViolations($accumulatingContext); | ||
$context->addViolation('instance must match at least one of the schemas listed in anyOf'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.