Enhance refactor commands with controller-aware Route() updates and fix code quality violations
Add semantic token highlighting for 'that' variable and comment file references in VS Code extension Add Phone_Text_Input and Currency_Input components with formatting utilities Implement client widgets, form standardization, and soft delete functionality Add modal scroll lock and update documentation Implement comprehensive modal system with form integration and validation Fix modal component instantiation using jQuery plugin API Implement modal system with responsive sizing, queuing, and validation support Implement form submission with validation, error handling, and loading states Implement country/state selectors with dynamic data loading and Bootstrap styling Revert Rsx::Route() highlighting in Blade/PHP files Target specific PHP scopes for Rsx::Route() highlighting in Blade Expand injection selector for Rsx::Route() highlighting Add custom syntax highlighting for Rsx::Route() and Rsx.Route() calls Update jqhtml packages to v2.2.165 Add bundle path validation for common mistakes (development mode only) Create Ajax_Select_Input widget and Rsx_Reference_Data controller Create Country_Select_Input widget with default country support Initialize Tom Select on Select_Input widgets Add Tom Select bundle for enhanced select dropdowns Implement ISO 3166 geographic data system for country/region selection Implement widget-based form system with disabled state support 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
215
vendor/sokil/php-isocodes/src/AbstractDatabase.php
vendored
Normal file
215
vendor/sokil/php-isocodes/src/AbstractDatabase.php
vendored
Normal file
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sokil\IsoCodes;
|
||||
|
||||
use Sokil\IsoCodes\TranslationDriver\GettextExtensionDriver;
|
||||
use Sokil\IsoCodes\TranslationDriver\TranslationDriverInterface;
|
||||
|
||||
/**
|
||||
* Abstract collection of ISO entries
|
||||
*/
|
||||
abstract class AbstractDatabase implements \Iterator, \Countable
|
||||
{
|
||||
/**
|
||||
* Default ath ISO databases
|
||||
*/
|
||||
public const DATABASE_PATH = 'databases';
|
||||
|
||||
/**
|
||||
* Default path to gettext localised messages
|
||||
*/
|
||||
public const MESSAGES_PATH = 'messages';
|
||||
|
||||
/**
|
||||
* Path to directory with databases
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $baseDirectory;
|
||||
|
||||
/**
|
||||
* @var string[][]
|
||||
* @psalm-var Array<int, Array<string, string>>
|
||||
*
|
||||
* Cluster index used for iteration by entries
|
||||
*
|
||||
*/
|
||||
private $clusterIndex = [];
|
||||
|
||||
/**
|
||||
* @var TranslationDriverInterface
|
||||
*/
|
||||
protected $translationDriver;
|
||||
|
||||
/**
|
||||
* @param string|null $baseDirectory
|
||||
* @param TranslationDriverInterface|null $translationDriver
|
||||
*
|
||||
* @throws \RuntimeException when base directory not specified and directory can not be located automatically
|
||||
*/
|
||||
public function __construct(
|
||||
?string $baseDirectory = null,
|
||||
?TranslationDriverInterface $translationDriver = null
|
||||
) {
|
||||
if (empty($baseDirectory)) {
|
||||
// Require external database in "sokil/php-isocodes-db-*" packages
|
||||
$suggestedBaseDirectories = [
|
||||
// production mode, find in sibling directory "php-isocodes-db-i18n" or "php-isocodes-db-only"
|
||||
__DIR__ . '/../../php-isocodes-db-i18n/',
|
||||
__DIR__ . '/../../php-isocodes-db-only/',
|
||||
// development mode, find in current vendor packages
|
||||
__DIR__ . '/../vendor/sokil/php-isocodes-db-i18n/',
|
||||
__DIR__ . '/../vendor/sokil/php-isocodes-db-only/',
|
||||
];
|
||||
|
||||
foreach ($suggestedBaseDirectories as $suggestedBaseDirectory) {
|
||||
if (is_dir($suggestedBaseDirectory)) {
|
||||
$this->baseDirectory = $suggestedBaseDirectory;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->baseDirectory)) {
|
||||
throw new \RuntimeException(
|
||||
sprintf(
|
||||
'Base directory not specified and directory can not be located automatically. Finding at %s',
|
||||
implode(', ', $suggestedBaseDirectories)
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$this->baseDirectory = rtrim($baseDirectory, '/') . '/';
|
||||
}
|
||||
|
||||
$this->translationDriver = $translationDriver ?? new GettextExtensionDriver();
|
||||
|
||||
$this->translationDriver->configureDirectory(
|
||||
$this->getISONumber(),
|
||||
$this->getLocalMessagesDirPath()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* ISO Standard Number
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
abstract public static function getISONumber(): string;
|
||||
|
||||
/**
|
||||
* @psalm-param Array<string, string> $entry
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
abstract protected function arrayToEntry(array $entry);
|
||||
|
||||
/**
|
||||
* Get path to directory with database files
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getDatabasesPath(): string
|
||||
{
|
||||
return $this->baseDirectory . self::DATABASE_PATH;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get path to directory with gettext messages
|
||||
*/
|
||||
private function getLocalMessagesDirPath(): string
|
||||
{
|
||||
return $this->baseDirectory . self::MESSAGES_PATH;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of all database rows.
|
||||
* For large databases like ISO-3166-2 this may require a lot of memory.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getClusterIndex(): array
|
||||
{
|
||||
// initialise cluster index
|
||||
$this->loadClusterIndex();
|
||||
|
||||
return $this->clusterIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build cluster index for iteration
|
||||
*/
|
||||
private function loadClusterIndex(): void
|
||||
{
|
||||
// check if cluster index already loaded
|
||||
if (!empty($this->clusterIndex)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$isoNumber = $this->getISONumber();
|
||||
|
||||
// load database from json file
|
||||
$databaseFilePath = $this->getDatabasesPath() . '/iso_' . $isoNumber . '.json';
|
||||
|
||||
$json = \json_decode(
|
||||
file_get_contents($databaseFilePath),
|
||||
true
|
||||
);
|
||||
|
||||
// build cluster index from database
|
||||
$this->clusterIndex = $json[$isoNumber];
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds array of entries.
|
||||
* Creates many entry objects in loop, use iterator instead.
|
||||
*
|
||||
* @psalm-return Array<string, object>
|
||||
* @return object[]
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
/** @psalm-var Array<string, object> $array */
|
||||
$array = iterator_to_array($this);
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return object
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current()
|
||||
{
|
||||
return $this->arrayToEntry(current($this->clusterIndex));
|
||||
}
|
||||
|
||||
public function key(): ?int
|
||||
{
|
||||
return key($this->clusterIndex);
|
||||
}
|
||||
|
||||
public function next(): void
|
||||
{
|
||||
next($this->clusterIndex);
|
||||
}
|
||||
|
||||
public function rewind(): void
|
||||
{
|
||||
// initialise cluster index
|
||||
$this->loadClusterIndex();
|
||||
|
||||
reset($this->clusterIndex);
|
||||
}
|
||||
|
||||
public function valid(): bool
|
||||
{
|
||||
return $this->key() !== null;
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return count($this->getClusterIndex());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user