Skip to content

Commit

Permalink
pint
Browse files Browse the repository at this point in the history
  • Loading branch information
markhuot committed Nov 18, 2023
1 parent 69d27c6 commit bcd0578
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 16 deletions.
4 changes: 1 addition & 3 deletions src/actions/MakeModelFromArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use craft\base\FieldInterface;
use craft\base\Model;
use markhuot\keystone\db\ActiveRecord;
use markhuot\keystone\tests\models\ElementToElementIdTest;
use yii\base\ModelEvent;

use function markhuot\keystone\helpers\base\app;
Expand Down Expand Up @@ -104,8 +103,7 @@ protected function load(\yii\base\Model $model, mixed $data): void

if (enum_exists($type)) {
$value = $type::from($value);
}
elseif (class_exists($type) || interface_exists($type)) {
} elseif (class_exists($type) || interface_exists($type)) {
$value = (new static)
->handle(
className: $type,
Expand Down
4 changes: 2 additions & 2 deletions src/behaviors/BodyParamObjectBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ public function getQueryParamObjectOrFail(string $class, string $formName = '')
/**
* @template T
*
* @param array<mixed> $data
* @param class-string<T> $class
* @param array<mixed> $data
* @param class-string<T> $class
* @return T
*/
protected function handleData(array $data, string $class, string $formName = '', bool $errorOnMissing = false, bool $createOnMissing = true)
Expand Down
1 change: 1 addition & 0 deletions src/behaviors/RenderFieldHtmlBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function getFieldHtml(FieldInterface $field)
if ($fieldLayout instanceof CustomField) {
if ($fieldLayout->getField()->handle === $field->handle) {
Craft::$app->getView()->setTemplateMode($oldTemplateMode);

return $fieldHtml;
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/controllers/ComponentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace markhuot\keystone\controllers;

use Craft;
use craft\web\Controller;
use markhuot\keystone\actions\AddComponent;
use markhuot\keystone\actions\DeleteComponent;
Expand All @@ -13,8 +12,8 @@
use markhuot\keystone\behaviors\BodyParamObjectBehavior;
use markhuot\keystone\models\Component;
use markhuot\keystone\models\http\AddComponentRequest;
use markhuot\keystone\models\http\StoreComponentRequest;
use markhuot\keystone\models\http\MoveComponentRequest;
use markhuot\keystone\models\http\StoreComponentRequest;
use yii\web\Request;

/**
Expand Down
3 changes: 1 addition & 2 deletions src/models/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public function getSlot(string $name = null): SlotCollection
->where(fn (Component $component) => $component->isDirectDiscendantOf($this, $name))
->each(function (Component $component) {
$components = collect($this->slotted)
->where(fn (Component $c) => $c->isDiscendantOf($component));
->where(fn (Component $c) => $c->isDiscendantOf($component));

$component->setSlotted($components)

Expand All @@ -329,7 +329,6 @@ public function getSlot(string $name = null): SlotCollection
// call above may have removed some of the keys.
->values();


return new SlotCollection($components->all(), $this, $name);
}

Expand Down
4 changes: 2 additions & 2 deletions src/models/http/AddComponentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class AddComponentRequest extends Model
public FieldInterface $field;

#[Safe]
public ?string $path=null;
public ?string $path = null;

#[Safe]
public ?string $slot=null;
public ?string $slot = null;

#[Required]
public int $sortOrder;
Expand Down
4 changes: 2 additions & 2 deletions src/models/http/StoreComponentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class StoreComponentRequest extends Model
public FieldInterface $field;

#[Safe]
public ?string $path=null;
public ?string $path = null;

#[Safe]
public ?string $slot=null;
public ?string $slot = null;

#[Required]
public int $sortOrder;
Expand Down
1 change: 0 additions & 1 deletion src/validators/Required.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
#[Attribute(Attribute::TARGET_PROPERTY)]
class Required
{

}
1 change: 0 additions & 1 deletion src/validators/Safe.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
#[Attribute(Attribute::TARGET_PROPERTY)]
class Safe
{

}
2 changes: 1 addition & 1 deletion tests/RouteModelBindingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use markhuot\keystone\actions\MakeModelFromArray;
use markhuot\keystone\enums\MoveComponentPosition;
use markhuot\keystone\models\Component;
use markhuot\keystone\models\http\StoreComponentRequest;
use markhuot\keystone\models\http\MoveComponentRequest;
use markhuot\keystone\models\http\StoreComponentRequest;
use markhuot\keystone\tests\models\ElementToElementIdTest;
use markhuot\keystone\tests\models\OptionalFieldsTest;
use markhuot\keystone\tests\models\RequiredFieldsTest;
Expand Down

0 comments on commit bcd0578

Please sign in to comment.