Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Collections/FieldTypeCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Support\Collection;
use Relaticle\CustomFields\Data\FieldTypeData;

final class FieldTypeCollection extends Collection
class FieldTypeCollection extends Collection
{
public function acceptsArbitraryValues(): static
{
Expand Down
2 changes: 1 addition & 1 deletion src/CustomFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Relaticle\CustomFields\Models\CustomFieldSection;
use Relaticle\CustomFields\Models\CustomFieldValue;

final class CustomFields
class CustomFields
{
/**
* The custom field model that should be used by Custom Fields.
Expand Down
14 changes: 7 additions & 7 deletions src/CustomFieldsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

final class CustomFieldsServiceProvider extends PackageServiceProvider
class CustomFieldsServiceProvider extends PackageServiceProvider
{
public static string $name = 'custom-fields';

Expand Down Expand Up @@ -143,15 +143,15 @@ public function packageBooted(): void
}
}

private function getAssetPackageName(): string
protected function getAssetPackageName(): string
{
return 'relaticle/custom-fields';
}

/**
* @return array<Asset>
*/
private function getAssets(): array
protected function getAssets(): array
{
return [
Css::make('custom-fields', __DIR__.'/../resources/dist/custom-fields.css')->loadedOnRequest(),
Expand All @@ -161,7 +161,7 @@ private function getAssets(): array
/**
* @return array<class-string>
*/
private function getCommands(): array
protected function getCommands(): array
{
return [
MakeCustomFieldsMigrationCommand::class,
Expand All @@ -172,23 +172,23 @@ private function getCommands(): array
/**
* @return array<string>
*/
private function getIcons(): array
protected function getIcons(): array
{
return [];
}

/**
* @return array<string, mixed>
*/
private function getScriptData(): array
protected function getScriptData(): array
{
return [];
}

/**
* @return array<string>
*/
private function getMigrations(): array
protected function getMigrations(): array
{
return [
'create_custom_fields_table',
Expand Down
2 changes: 1 addition & 1 deletion src/Data/CustomFieldData.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Spatie\LaravelData\Mappers\SnakeCaseMapper;

#[MapName(SnakeCaseMapper::class)]
final class CustomFieldData extends Data
class CustomFieldData extends Data
{
/**
* Create a new instance of the CustomFieldData class.
Expand Down
2 changes: 1 addition & 1 deletion src/Data/CustomFieldSectionData.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Spatie\LaravelData\Mappers\SnakeCaseMapper;

#[MapName(SnakeCaseMapper::class)]
final class CustomFieldSectionData extends Data
class CustomFieldSectionData extends Data
{
/**
* Create a new instance of the CustomFieldData class.
Expand Down
4 changes: 2 additions & 2 deletions src/Data/EntityConfigurationData.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Relaticle\CustomFields\Models\Contracts\HasCustomFields;
use Spatie\LaravelData\Data;

final class EntityConfigurationData extends Data
class EntityConfigurationData extends Data
{
public function __construct(
public string $modelClass,
Expand All @@ -42,7 +42,7 @@ public function __construct(
/**
* Validate the configuration
*/
private function validateConfiguration(): void
protected function validateConfiguration(): void
{
if (! class_exists($this->modelClass)) {
throw new InvalidArgumentException(sprintf('Model class %s does not exist', $this->modelClass));
Expand Down
2 changes: 1 addition & 1 deletion src/Data/FieldTypeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Spatie\LaravelData\Data;
use Stringable;

final class FieldTypeData extends Data implements Stringable
class FieldTypeData extends Data implements Stringable
{
public function __construct(
public string $key,
Expand Down
2 changes: 1 addition & 1 deletion src/Data/ValidationRuleData.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Spatie\LaravelData\Data;

final class ValidationRuleData extends Data
class ValidationRuleData extends Data
{
/**
* Create a new instance of the ValidationRuleData class.
Expand Down
2 changes: 1 addition & 1 deletion src/Data/VisibilityData.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function evaluate(array $fieldValues): bool
/**
* @param array<string, mixed> $fieldValues
*/
private function evaluateCondition(VisibilityConditionData $condition, array $fieldValues): bool
protected function evaluateCondition(VisibilityConditionData $condition, array $fieldValues): bool
{
$fieldValue = $fieldValues[$condition->field_code] ?? null;

Expand Down
2 changes: 1 addition & 1 deletion src/EntitySystem/EntityCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Relaticle\CustomFields\Data\EntityConfigurationData;
use Relaticle\CustomFields\Enums\EntityFeature;

final class EntityCollection extends Collection
class EntityCollection extends Collection
{
/**
* Find entity by model class or alias
Expand Down
20 changes: 10 additions & 10 deletions src/EntitySystem/EntityConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@
* Fluent builder for configuring the entire entity management system
* Provides clean, discoverable API for global entity configuration
*/
final class EntityConfigurator implements EntityConfigurationInterface
class EntityConfigurator implements EntityConfigurationInterface
{
private bool $autoDiscover = true;
protected bool $autoDiscover = true;

private array $discoveryPaths = [];
protected array $discoveryPaths = [];

private array $discoveryNamespaces = ['App\\Models'];
protected array $discoveryNamespaces = ['App\\Models'];

private array $excludedModels = [];
protected array $excludedModels = [];

private bool $cacheEnabled = true;
protected bool $cacheEnabled = true;

private int $cacheTtl = 3600;
protected int $cacheTtl = 3600;

private array $entityModels = [];
protected array $entityModels = [];

private function __construct()
protected function __construct()
{
// Set smart defaults
$this->discoveryPaths = [app_path('Models')];
Expand Down Expand Up @@ -142,7 +142,7 @@ public function models(array $entityModels): self
/**
* Build the entities array from configured entity arrays
*/
private function buildEntitiesArray(): array
protected function buildEntitiesArray(): array
{
$entities = [];

Expand Down
30 changes: 15 additions & 15 deletions src/EntitySystem/EntityDiscovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
use Relaticle\CustomFields\Models\Contracts\HasCustomFields;
use Symfony\Component\Finder\Finder;

final class EntityDiscovery
class EntityDiscovery
{
private array $discoveredCache = [];
protected array $discoveredCache = [];

public function __construct(
private array $paths = [],
Expand Down Expand Up @@ -81,7 +81,7 @@ public function discover(): array
/**
* Discover entities from Filament Resources
*/
private function discoverFromFilamentResources(): array
protected function discoverFromFilamentResources(): array
{
$entities = [];

Expand Down Expand Up @@ -116,7 +116,7 @@ private function discoverFromFilamentResources(): array
/**
* Discover entities from configured paths
*/
private function discoverFromPaths(): array
protected function discoverFromPaths(): array
{
$entities = [];

Expand Down Expand Up @@ -148,7 +148,7 @@ private function discoverFromPaths(): array
/**
* Discover entities from namespaces
*/
private function discoverFromNamespaces(): array
protected function discoverFromNamespaces(): array
{
$entities = [];

Expand All @@ -173,7 +173,7 @@ private function discoverFromNamespaces(): array
/**
* Check if a model should be discovered
*/
private function shouldDiscoverModel(string $modelClass): bool
protected function shouldDiscoverModel(string $modelClass): bool
{
if (! class_exists($modelClass)) {
return false;
Expand Down Expand Up @@ -205,7 +205,7 @@ private function shouldDiscoverModel(string $modelClass): bool
/**
* Create entity configuration from a model class
*/
private function createEntityFromModel(string $modelClass): EntityConfigurationData
protected function createEntityFromModel(string $modelClass): EntityConfigurationData
{
/** @var Model $model */
$model = new $modelClass;
Expand All @@ -226,7 +226,7 @@ private function createEntityFromModel(string $modelClass): EntityConfigurationD
/**
* Get model label from class name
*/
private function getModelLabel(string $modelClass): string
protected function getModelLabel(string $modelClass): string
{
$baseName = class_basename($modelClass);

Expand All @@ -236,15 +236,15 @@ private function getModelLabel(string $modelClass): string
/**
* Get model plural label
*/
private function getModelPluralLabel(string $modelClass): string
protected function getModelPluralLabel(string $modelClass): string
{
return Str::plural($this->getModelLabel($modelClass));
}

/**
* Get model icon (can be customized via method or property)
*/
private function getModelIcon(string $modelClass): string
protected function getModelIcon(string $modelClass): string
{
if (method_exists($modelClass, 'getCustomFieldsIcon')) {
return $modelClass::getCustomFieldsIcon();
Expand All @@ -260,7 +260,7 @@ private function getModelIcon(string $modelClass): string
/**
* Get model primary attribute
*/
private function getModelPrimaryAttribute(string $modelClass): string
protected function getModelPrimaryAttribute(string $modelClass): string
{
if (method_exists($modelClass, 'getCustomFieldsPrimaryAttribute')) {
return $modelClass::getCustomFieldsPrimaryAttribute();
Expand All @@ -286,7 +286,7 @@ private function getModelPrimaryAttribute(string $modelClass): string
/**
* Get model search attributes
*/
private function getModelSearchAttributes(string $modelClass): array
protected function getModelSearchAttributes(string $modelClass): array
{
if (method_exists($modelClass, 'getCustomFieldsSearchAttributes')) {
return $modelClass::getCustomFieldsSearchAttributes();
Expand All @@ -305,7 +305,7 @@ private function getModelSearchAttributes(string $modelClass): array
/**
* Get class name from file path
*/
private function getClassNameFromFile(string $path): ?string
protected function getClassNameFromFile(string $path): ?string
{
$contents = File::get($path);

Expand All @@ -327,7 +327,7 @@ private function getClassNameFromFile(string $path): ?string
/**
* Get classes in a namespace (using declared classes)
*/
private function getClassesInNamespace(string $namespace): array
protected function getClassesInNamespace(string $namespace): array
{
$classes = [];
$declaredClasses = get_declared_classes();
Expand All @@ -344,7 +344,7 @@ private function getClassesInNamespace(string $namespace): array
/**
* Check if a resource class is valid
*/
private function isValidResourceClass(string $resourceClass): bool
protected function isValidResourceClass(string $resourceClass): bool
{
return class_exists($resourceClass)
&& is_subclass_of($resourceClass, Resource::class);
Expand Down
18 changes: 9 additions & 9 deletions src/EntitySystem/EntityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@
use Relaticle\CustomFields\Data\EntityConfigurationData;
use Relaticle\CustomFields\Enums\EntityFeature;

final class EntityManager implements EntityManagerInterface
class EntityManager implements EntityManagerInterface
{
use Macroable;

private const string CACHE_KEY = 'custom_fields_entities';

private const int CACHE_TTL = 3600; // 1 hour

private array $entities = [];
protected array $entities = [];

private ?array $cachedEntities = null;
protected ?array $cachedEntities = null;

private ?EntityDiscovery $discovery = null;
protected ?EntityDiscovery $discovery = null;

private bool $discoveryEnabled = false;
protected bool $discoveryEnabled = false;

private array $resolvingCallbacks = [];
protected array $resolvingCallbacks = [];

public function __construct(
private readonly bool $cacheEnabled = true
Expand Down Expand Up @@ -105,7 +105,7 @@ public function disableDiscovery(): static
/**
* Invalidate the in-memory cache (lightweight operation)
*/
private function invalidateCache(): void
protected function invalidateCache(): void
{
$this->cachedEntities = null;
}
Expand Down Expand Up @@ -145,7 +145,7 @@ public function resolving(Closure $callback): static
/**
* Build the entity cache
*/
private function buildEntityCache(): array
protected function buildEntityCache(): array
{
$entities = [];

Expand Down Expand Up @@ -179,7 +179,7 @@ private function buildEntityCache(): array
/**
* Resolve entities from various input types
*/
private function resolveEntities(array|Closure $entities): array
protected function resolveEntities(array|Closure $entities): array
{
if ($entities instanceof Closure) {
$entities = $entities();
Expand Down
Loading