From 1fdb55ec8dc34ff7a58561b973209f340e6b7c7a Mon Sep 17 00:00:00 2001 From: SandraFerrando Date: Thu, 14 Nov 2024 15:46:32 +0100 Subject: [PATCH 01/15] feat(tree-type): add TreeType Introduce a new database table for tree types, along with a MVC to handle CRUD operations. Improve the UI for displaying tree types in the main view. --- docker/database/start-scripts/0-init.sql | 11 +- docker/database/start-scripts/1-seed.sql | 22 +- src/app/Controllers/TreeTypesController.php | 20 + src/app/Core/Logger.php | 12 +- src/app/Layouts/MainLayout.php | 2 +- src/app/Models/TreeType.php | 91 +++ src/routes/web.php | 10 +- src/vendor/autoload.php | 25 + src/vendor/composer/ClassLoader.php | 579 ++++++++++++++++++++ src/vendor/composer/InstalledVersions.php | 359 ++++++++++++ src/vendor/composer/LICENSE | 21 + src/vendor/composer/autoload_classmap.php | 15 + src/vendor/composer/autoload_files.php | 12 + src/vendor/composer/autoload_namespaces.php | 9 + src/vendor/composer/autoload_psr4.php | 16 + src/vendor/composer/autoload_real.php | 50 ++ src/vendor/composer/autoload_static.php | 89 +++ src/vendor/composer/installed.json | 484 ++++++++++++++++ src/vendor/composer/installed.php | 77 +++ src/vendor/composer/platform_check.php | 26 + src/vendor/graham-campbell/result-type | 1 + src/vendor/phpoption/phpoption | 1 + src/vendor/symfony/polyfill-ctype | 1 + src/vendor/symfony/polyfill-mbstring | 1 + src/vendor/symfony/polyfill-php80 | 1 + src/vendor/vlucas/phpdotenv | 1 + 26 files changed, 1913 insertions(+), 23 deletions(-) create mode 100644 src/app/Controllers/TreeTypesController.php create mode 100644 src/app/Models/TreeType.php create mode 100644 src/vendor/autoload.php create mode 100644 src/vendor/composer/ClassLoader.php create mode 100644 src/vendor/composer/InstalledVersions.php create mode 100644 src/vendor/composer/LICENSE create mode 100644 src/vendor/composer/autoload_classmap.php create mode 100644 src/vendor/composer/autoload_files.php create mode 100644 src/vendor/composer/autoload_namespaces.php create mode 100644 src/vendor/composer/autoload_psr4.php create mode 100644 src/vendor/composer/autoload_real.php create mode 100644 src/vendor/composer/autoload_static.php create mode 100644 src/vendor/composer/installed.json create mode 100644 src/vendor/composer/installed.php create mode 100644 src/vendor/composer/platform_check.php create mode 160000 src/vendor/graham-campbell/result-type create mode 160000 src/vendor/phpoption/phpoption create mode 160000 src/vendor/symfony/polyfill-ctype create mode 160000 src/vendor/symfony/polyfill-mbstring create mode 160000 src/vendor/symfony/polyfill-php80 create mode 160000 src/vendor/vlucas/phpdotenv diff --git a/docker/database/start-scripts/0-init.sql b/docker/database/start-scripts/0-init.sql index 8626380d..440ba32a 100644 --- a/docker/database/start-scripts/0-init.sql +++ b/docker/database/start-scripts/0-init.sql @@ -13,14 +13,23 @@ create table zones ( foreign key (point_id) references points(id) ); +create table tree_types ( + id int auto_increment primary key, + species varchar(255), + subspecies varchar(255), + family varchar(255) +); + create table elements ( id int auto_increment primary key, name varchar(255), latitude decimal, longitude decimal, + tree_types_id int, created_at timestamp, deleted_at timestamp, - updated_at timestamp + updated_at timestamp, + foreign key (tree_types_id) references tree_types(id) ); create table inventory ( diff --git a/docker/database/start-scripts/1-seed.sql b/docker/database/start-scripts/1-seed.sql index de9da5fb..9bfb6adb 100644 --- a/docker/database/start-scripts/1-seed.sql +++ b/docker/database/start-scripts/1-seed.sql @@ -1,11 +1,13 @@ --- Insert sample roles (Admin, Manager, Worker) -INSERT INTO roles (role_name) VALUES -('Administrador'), -('Gerente'), -('Trabajador'); +-- Inserts per a la taula tree_types +INSERT INTO tree_types (species, subspecies, family) +VALUES + ('Quercus', 'Quercus robur', 'Fagaceae'), + ('Pinus', 'Pinus sylvestris', 'Pinaceae'), + ('Acer', 'Acer campestre', 'Sapindaceae'); --- Insert sample workers (Spanish users) -INSERT INTO workers (company, name, dni, password, email, role_id, created_at, updated_at, deleted_at) VALUES -('TechCorp', 'Carlos García', '12345678A', 'hashedpassword1', 'carlos.garcia@example.com', 1, NOW(), NOW(), NULL), -- Admin -('InnovaTech', 'Ana Martínez', '23456789B', 'hashedpassword2', 'ana.martinez@example.com', 2, NOW(), NOW(), NULL), -- Manager -('DesignWorks', 'José Rodríguez', '34567890C', 'hashedpassword3', 'jose.rodriguez@example.com', 3, NOW(), NOW(), NULL); -- Worker \ No newline at end of file +-- Inserts per a la taula elements +INSERT INTO elements (name, latitude, longitude, tree_types_id, created_at, deleted_at, updated_at) +VALUES + ('Roureda de la Selva', 41.8793, 2.8246, 1, '2024-11-01 10:30:00', NULL, '2024-11-10 12:00:00'), + ('Pineda de les Gavarres', 41.9738, 2.7756, 2, '2024-11-02 09:45:00', NULL, '2024-11-11 11:15:00'), + ('Arbre de la Plaça Major', 41.3879, 2.1699, 3, '2024-11-03 08:00:00', NULL, '2024-11-12 10:20:00'); diff --git a/src/app/Controllers/TreeTypesController.php b/src/app/Controllers/TreeTypesController.php new file mode 100644 index 00000000..fbddda4e --- /dev/null +++ b/src/app/Controllers/TreeTypesController.php @@ -0,0 +1,20 @@ + "TreeTypes", + "title" => "Tree Types", + "layout" => "MainLayout", + "data" => ["tree_types" => $tree_types] + ]); + } +} \ No newline at end of file diff --git a/src/app/Core/Logger.php b/src/app/Core/Logger.php index 625509ba..d321ac8b 100755 --- a/src/app/Core/Logger.php +++ b/src/app/Core/Logger.php @@ -6,12 +6,12 @@ class Logger { public static function log($message, $level = 'info') { - $logFile = getenv("LOG_FILE_PATH"); - $logMessage = strtoupper($level) . ' - ' . date('Y-m-d H:i:s') . ' - ' . $message . PHP_EOL; - if (!file_exists($logFile)) { - touch($logFile); - } - file_put_contents($logFile, $logMessage, FILE_APPEND); + // $logFile = getenv("LOG_FILE_PATH"); + // $logMessage = strtoupper($level) . ' - ' . date('Y-m-d H:i:s') . ' - ' . $message . PHP_EOL; + // if (!file_exists($logFile)) { + // touch($logFile); + // } + //file_put_contents($logFile, $logMessage, FILE_APPEND); } } diff --git a/src/app/Layouts/MainLayout.php b/src/app/Layouts/MainLayout.php index 62e27406..d6de76c9 100755 --- a/src/app/Layouts/MainLayout.php +++ b/src/app/Layouts/MainLayout.php @@ -17,7 +17,7 @@ diff --git a/src/app/Models/TreeType.php b/src/app/Models/TreeType.php new file mode 100644 index 00000000..b5c1e1b9 --- /dev/null +++ b/src/app/Models/TreeType.php @@ -0,0 +1,91 @@ + $value) { + $this->$key = $value; + } + } + + // Static method to retrieve all tree_types + public static function getAll() + { + $query = "SELECT * FROM tree_types"; + $results = Database::prepareAndExecute($query); + foreach ($results as $key => $value) { + $results[$key] = new self($value); + } + return $results; + } + + // Static method to find a tree_type by ID + public static function findById($id) + { + $query = "SELECT * FROM tree_types WHERE id = :id AND deleted_at IS NULL"; + $results = Database::prepareAndExecute($query, ['id' => $id]); + + return $results ? new self($results[0]) : null; + } + + // Static method to find a tree_type by family + public static function findByfamily($family) + { + $query = "SELECT * FROM tree_types WHERE family = :family AND deleted_at IS NULL"; + $results = Database::prepareAndExecute($query, ['family' => $family]); + + return $results ? new self($results[0]) : null; + } + + // Method to save a new tree_type + public function save() + { + $query = "INSERT INTO tree_types (species, subspecies, family) + VALUES (:species, :subspecies, :family, NOW(), NOW())"; + $params = [ + 'species' => $this->species, + 'subspecies' => $this->subspecies, + 'family' => $this->family, + ]; + + return Database::prepareAndExecute($query, $params); + } + + + // Getters and setters (you can add more as needed) + public function getId() + { + return $this->id; + } + + public function getSpecies() + { + return $this->species; + } + + public function getSubspecies() + { + return $this->subspecies; + } + + public function getFamily() + { + return $this->family; + } + + +} diff --git a/src/routes/web.php b/src/routes/web.php index 18648278..889eb733 100755 --- a/src/routes/web.php +++ b/src/routes/web.php @@ -13,22 +13,22 @@ * **/ -use App\Controllers\HomeController; +use App\Controllers\TreeTypesController; use App\Controllers\AuthController; return $routes = [ "GET" => [ "/" => [ - "controller" => HomeController::class, + "controller" => TreeTypesController::class, "method" => "index" ], "/login" => [ "controller" => AuthController::class, "method" => "index" ], - "/exemple" => [ - "controller" => HomeController::class, - "method" => "exemple" + "/tree-types" => [ + "controller" => TreeTypesController::class, + "method" => "index" ], ], ]; \ No newline at end of file diff --git a/src/vendor/autoload.php b/src/vendor/autoload.php new file mode 100644 index 00000000..4403f11a --- /dev/null +++ b/src/vendor/autoload.php @@ -0,0 +1,25 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see https://www.php-fig.org/psr/psr-0/ + * @see https://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + /** @var \Closure(string):void */ + private static $includeFile; + + /** @var string|null */ + private $vendorDir; + + // PSR-4 + /** + * @var array> + */ + private $prefixLengthsPsr4 = array(); + /** + * @var array> + */ + private $prefixDirsPsr4 = array(); + /** + * @var list + */ + private $fallbackDirsPsr4 = array(); + + // PSR-0 + /** + * List of PSR-0 prefixes + * + * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) + * + * @var array>> + */ + private $prefixesPsr0 = array(); + /** + * @var list + */ + private $fallbackDirsPsr0 = array(); + + /** @var bool */ + private $useIncludePath = false; + + /** + * @var array + */ + private $classMap = array(); + + /** @var bool */ + private $classMapAuthoritative = false; + + /** + * @var array + */ + private $missingClasses = array(); + + /** @var string|null */ + private $apcuPrefix; + + /** + * @var array + */ + private static $registeredLoaders = array(); + + /** + * @param string|null $vendorDir + */ + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + self::initializeIncludeClosure(); + } + + /** + * @return array> + */ + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); + } + + return array(); + } + + /** + * @return array> + */ + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + /** + * @return list + */ + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + /** + * @return list + */ + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + /** + * @return array Array of classname => path + */ + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + * + * @return void + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + * + * @return void + */ + public function add($prefix, $paths, $prepend = false) + { + $paths = (array) $paths; + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + $paths = (array) $paths; + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 base directories + * + * @return void + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + * + * @return void + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + * + * @return void + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + * + * @return void + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + * + * @return void + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } + } + + /** + * Unregisters this instance as an autoloader. + * + * @return void + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return true|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + $includeFile = self::$includeFile; + $includeFile($file); + + return true; + } + + return null; + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + /** + * Returns the currently registered loaders keyed by their corresponding vendor directories. + * + * @return array + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + + /** + * @param string $class + * @param string $ext + * @return string|false + */ + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } + + /** + * @return void + */ + private static function initializeIncludeClosure() + { + if (self::$includeFile !== null) { + return; + } + + /** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + */ + self::$includeFile = \Closure::bind(static function($file) { + include $file; + }, null, null); + } +} diff --git a/src/vendor/composer/InstalledVersions.php b/src/vendor/composer/InstalledVersions.php new file mode 100644 index 00000000..51e734a7 --- /dev/null +++ b/src/vendor/composer/InstalledVersions.php @@ -0,0 +1,359 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer; + +use Composer\Autoload\ClassLoader; +use Composer\Semver\VersionParser; + +/** + * This class is copied in every Composer installed project and available to all + * + * See also https://getcomposer.org/doc/07-runtime.md#installed-versions + * + * To require its presence, you can require `composer-runtime-api ^2.0` + * + * @final + */ +class InstalledVersions +{ + /** + * @var mixed[]|null + * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null + */ + private static $installed; + + /** + * @var bool|null + */ + private static $canGetVendors; + + /** + * @var array[] + * @psalm-var array}> + */ + private static $installedByVendor = array(); + + /** + * Returns a list of all package names which are present, either by being installed, replaced or provided + * + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackages() + { + $packages = array(); + foreach (self::getInstalled() as $installed) { + $packages[] = array_keys($installed['versions']); + } + + if (1 === \count($packages)) { + return $packages[0]; + } + + return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); + } + + /** + * Returns a list of all package names with a specific type e.g. 'library' + * + * @param string $type + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackagesByType($type) + { + $packagesByType = array(); + + foreach (self::getInstalled() as $installed) { + foreach ($installed['versions'] as $name => $package) { + if (isset($package['type']) && $package['type'] === $type) { + $packagesByType[] = $name; + } + } + } + + return $packagesByType; + } + + /** + * Checks whether the given package is installed + * + * This also returns true if the package name is provided or replaced by another package + * + * @param string $packageName + * @param bool $includeDevRequirements + * @return bool + */ + public static function isInstalled($packageName, $includeDevRequirements = true) + { + foreach (self::getInstalled() as $installed) { + if (isset($installed['versions'][$packageName])) { + return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; + } + } + + return false; + } + + /** + * Checks whether the given package satisfies a version constraint + * + * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: + * + * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') + * + * @param VersionParser $parser Install composer/semver to have access to this class and functionality + * @param string $packageName + * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * @return bool + */ + public static function satisfies(VersionParser $parser, $packageName, $constraint) + { + $constraint = $parser->parseConstraints((string) $constraint); + $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + + return $provided->matches($constraint); + } + + /** + * Returns a version constraint representing all the range(s) which are installed for a given package + * + * It is easier to use this via isInstalled() with the $constraint argument if you need to check + * whether a given version of a package is installed, and not just whether it exists + * + * @param string $packageName + * @return string Version constraint usable with composer/semver + */ + public static function getVersionRanges($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + $ranges = array(); + if (isset($installed['versions'][$packageName]['pretty_version'])) { + $ranges[] = $installed['versions'][$packageName]['pretty_version']; + } + if (array_key_exists('aliases', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); + } + if (array_key_exists('replaced', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); + } + if (array_key_exists('provided', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); + } + + return implode(' || ', $ranges); + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['version'])) { + return null; + } + + return $installed['versions'][$packageName]['version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getPrettyVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['pretty_version'])) { + return null; + } + + return $installed['versions'][$packageName]['pretty_version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference + */ + public static function getReference($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['reference'])) { + return null; + } + + return $installed['versions'][$packageName]['reference']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. + */ + public static function getInstallPath($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @return array + * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} + */ + public static function getRootPackage() + { + $installed = self::getInstalled(); + + return $installed[0]['root']; + } + + /** + * Returns the raw installed.php data for custom implementations + * + * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. + * @return array[] + * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} + */ + public static function getRawData() + { + @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = include __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + + return self::$installed; + } + + /** + * Returns the raw data of all installed.php which are currently loaded for custom implementations + * + * @return array[] + * @psalm-return list}> + */ + public static function getAllRawData() + { + return self::getInstalled(); + } + + /** + * Lets you reload the static array from another file + * + * This is only useful for complex integrations in which a project needs to use + * this class but then also needs to execute another project's autoloader in process, + * and wants to ensure both projects have access to their version of installed.php. + * + * A typical case would be PHPUnit, where it would need to make sure it reads all + * the data it needs from this class, then call reload() with + * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure + * the project in which it runs can then also use this class safely, without + * interference between PHPUnit's dependencies and the project's dependencies. + * + * @param array[] $data A vendor/composer/installed.php data set + * @return void + * + * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data + */ + public static function reload($data) + { + self::$installed = $data; + self::$installedByVendor = array(); + } + + /** + * @return array[] + * @psalm-return list}> + */ + private static function getInstalled() + { + if (null === self::$canGetVendors) { + self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); + } + + $installed = array(); + + if (self::$canGetVendors) { + foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + if (isset(self::$installedByVendor[$vendorDir])) { + $installed[] = self::$installedByVendor[$vendorDir]; + } elseif (is_file($vendorDir.'/composer/installed.php')) { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require $vendorDir.'/composer/installed.php'; + $installed[] = self::$installedByVendor[$vendorDir] = $required; + if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { + self::$installed = $installed[count($installed) - 1]; + } + } + } + } + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require __DIR__ . '/installed.php'; + self::$installed = $required; + } else { + self::$installed = array(); + } + } + + if (self::$installed !== array()) { + $installed[] = self::$installed; + } + + return $installed; + } +} diff --git a/src/vendor/composer/LICENSE b/src/vendor/composer/LICENSE new file mode 100644 index 00000000..f27399a0 --- /dev/null +++ b/src/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/src/vendor/composer/autoload_classmap.php b/src/vendor/composer/autoload_classmap.php new file mode 100644 index 00000000..f6834955 --- /dev/null +++ b/src/vendor/composer/autoload_classmap.php @@ -0,0 +1,15 @@ + $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', + 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', + 'PhpToken' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php', + 'Stringable' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Stringable.php', + 'UnhandledMatchError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', + 'ValueError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', +); diff --git a/src/vendor/composer/autoload_files.php b/src/vendor/composer/autoload_files.php new file mode 100644 index 00000000..cd554148 --- /dev/null +++ b/src/vendor/composer/autoload_files.php @@ -0,0 +1,12 @@ + $vendorDir . '/symfony/polyfill-ctype/bootstrap.php', + '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', + 'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php', +); diff --git a/src/vendor/composer/autoload_namespaces.php b/src/vendor/composer/autoload_namespaces.php new file mode 100644 index 00000000..f1ae7a0f --- /dev/null +++ b/src/vendor/composer/autoload_namespaces.php @@ -0,0 +1,9 @@ + array($vendorDir . '/symfony/polyfill-php80'), + 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), + 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'), + 'PhpOption\\' => array($vendorDir . '/phpoption/phpoption/src/PhpOption'), + 'GrahamCampbell\\ResultType\\' => array($vendorDir . '/graham-campbell/result-type/src'), + 'Dotenv\\' => array($vendorDir . '/vlucas/phpdotenv/src'), + 'App\\' => array($baseDir . '/src/app'), +); diff --git a/src/vendor/composer/autoload_real.php b/src/vendor/composer/autoload_real.php new file mode 100644 index 00000000..a686a7e4 --- /dev/null +++ b/src/vendor/composer/autoload_real.php @@ -0,0 +1,50 @@ +register(true); + + $filesToLoad = \Composer\Autoload\ComposerStaticIniteb55ab41b565401c02d945b712f3b194::$files; + $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; + + require $file; + } + }, null, null); + foreach ($filesToLoad as $fileIdentifier => $file) { + $requireFile($fileIdentifier, $file); + } + + return $loader; + } +} diff --git a/src/vendor/composer/autoload_static.php b/src/vendor/composer/autoload_static.php new file mode 100644 index 00000000..5bbd9ff1 --- /dev/null +++ b/src/vendor/composer/autoload_static.php @@ -0,0 +1,89 @@ + __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php', + '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', + 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', + ); + + public static $prefixLengthsPsr4 = array ( + 'S' => + array ( + 'Symfony\\Polyfill\\Php80\\' => 23, + 'Symfony\\Polyfill\\Mbstring\\' => 26, + 'Symfony\\Polyfill\\Ctype\\' => 23, + ), + 'P' => + array ( + 'PhpOption\\' => 10, + ), + 'G' => + array ( + 'GrahamCampbell\\ResultType\\' => 26, + ), + 'D' => + array ( + 'Dotenv\\' => 7, + ), + 'A' => + array ( + 'App\\' => 4, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'Symfony\\Polyfill\\Php80\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/polyfill-php80', + ), + 'Symfony\\Polyfill\\Mbstring\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring', + ), + 'Symfony\\Polyfill\\Ctype\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype', + ), + 'PhpOption\\' => + array ( + 0 => __DIR__ . '/..' . '/phpoption/phpoption/src/PhpOption', + ), + 'GrahamCampbell\\ResultType\\' => + array ( + 0 => __DIR__ . '/..' . '/graham-campbell/result-type/src', + ), + 'Dotenv\\' => + array ( + 0 => __DIR__ . '/..' . '/vlucas/phpdotenv/src', + ), + 'App\\' => + array ( + 0 => __DIR__ . '/../../..' . '/src/app', + ), + ); + + public static $classMap = array ( + 'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + 'PhpToken' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php', + 'Stringable' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Stringable.php', + 'UnhandledMatchError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', + 'ValueError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticIniteb55ab41b565401c02d945b712f3b194::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticIniteb55ab41b565401c02d945b712f3b194::$prefixDirsPsr4; + $loader->classMap = ComposerStaticIniteb55ab41b565401c02d945b712f3b194::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/src/vendor/composer/installed.json b/src/vendor/composer/installed.json new file mode 100644 index 00000000..82aca11a --- /dev/null +++ b/src/vendor/composer/installed.json @@ -0,0 +1,484 @@ +{ + "packages": [ + { + "name": "graham-campbell/result-type", + "version": "v1.1.3", + "version_normalized": "1.1.3.0", + "source": { + "type": "git", + "url": "https://github.com/GrahamCampbell/Result-Type.git", + "reference": "3ba905c11371512af9d9bdd27d99b782216b6945" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/3ba905c11371512af9d9bdd27d99b782216b6945", + "reference": "3ba905c11371512af9d9bdd27d99b782216b6945", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "phpoption/phpoption": "^1.9.3" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28" + }, + "time": "2024-07-20T21:45:45+00:00", + "type": "library", + "installation-source": "source", + "autoload": { + "psr-4": { + "GrahamCampbell\\ResultType\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + } + ], + "description": "An Implementation Of The Result Type", + "keywords": [ + "Graham Campbell", + "GrahamCampbell", + "Result Type", + "Result-Type", + "result" + ], + "support": { + "issues": "https://github.com/GrahamCampbell/Result-Type/issues", + "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.3" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type", + "type": "tidelift" + } + ], + "install-path": "../graham-campbell/result-type" + }, + { + "name": "phpoption/phpoption", + "version": "1.9.3", + "version_normalized": "1.9.3.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/php-option.git", + "reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/e3fac8b24f56113f7cb96af14958c0dd16330f54", + "reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28" + }, + "time": "2024-07-20T21:41:07+00:00", + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + }, + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "installation-source": "source", + "autoload": { + "psr-4": { + "PhpOption\\": "src/PhpOption/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh" + }, + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + } + ], + "description": "Option Type for PHP", + "keywords": [ + "language", + "option", + "php", + "type" + ], + "support": { + "issues": "https://github.com/schmittjoh/php-option/issues", + "source": "https://github.com/schmittjoh/php-option/tree/1.9.3" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption", + "type": "tidelift" + } + ], + "install-path": "../phpoption/phpoption" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.31.0", + "version_normalized": "1.31.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "provide": { + "ext-ctype": "*" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "time": "2024-09-09T11:45:10+00:00", + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "installation-source": "source", + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/polyfill-ctype" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.31.0", + "version_normalized": "1.31.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "time": "2024-09-09T11:45:10+00:00", + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "installation-source": "source", + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/polyfill-mbstring" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.31.0", + "version_normalized": "1.31.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", + "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "time": "2024-09-09T11:45:10+00:00", + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "installation-source": "source", + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/polyfill-php80" + }, + { + "name": "vlucas/phpdotenv", + "version": "v5.6.1", + "version_normalized": "5.6.1.0", + "source": { + "type": "git", + "url": "https://github.com/vlucas/phpdotenv.git", + "reference": "a59a13791077fe3d44f90e7133eb68e7d22eaff2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/a59a13791077fe3d44f90e7133eb68e7d22eaff2", + "reference": "a59a13791077fe3d44f90e7133eb68e7d22eaff2", + "shasum": "" + }, + "require": { + "ext-pcre": "*", + "graham-campbell/result-type": "^1.1.3", + "php": "^7.2.5 || ^8.0", + "phpoption/phpoption": "^1.9.3", + "symfony/polyfill-ctype": "^1.24", + "symfony/polyfill-mbstring": "^1.24", + "symfony/polyfill-php80": "^1.24" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "ext-filter": "*", + "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2" + }, + "suggest": { + "ext-filter": "Required to use the boolean validator." + }, + "time": "2024-07-20T21:52:34+00:00", + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + }, + "branch-alias": { + "dev-master": "5.6-dev" + } + }, + "installation-source": "source", + "autoload": { + "psr-4": { + "Dotenv\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Vance Lucas", + "email": "vance@vancelucas.com", + "homepage": "https://github.com/vlucas" + } + ], + "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", + "keywords": [ + "dotenv", + "env", + "environment" + ], + "support": { + "issues": "https://github.com/vlucas/phpdotenv/issues", + "source": "https://github.com/vlucas/phpdotenv/tree/v5.6.1" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", + "type": "tidelift" + } + ], + "install-path": "../vlucas/phpdotenv" + } + ], + "dev": true, + "dev-package-names": [] +} diff --git a/src/vendor/composer/installed.php b/src/vendor/composer/installed.php new file mode 100644 index 00000000..6a4bfb51 --- /dev/null +++ b/src/vendor/composer/installed.php @@ -0,0 +1,77 @@ + array( + 'name' => 'daw-iesmontsia/urban-tree', + 'pretty_version' => 'dev-main', + 'version' => 'dev-main', + 'reference' => '0d63ff1e0ecb00ae5e5ca4032083bf83fd73a02c', + 'type' => 'project', + 'install_path' => __DIR__ . '/../../../', + 'aliases' => array(), + 'dev' => true, + ), + 'versions' => array( + 'daw-iesmontsia/urban-tree' => array( + 'pretty_version' => 'dev-main', + 'version' => 'dev-main', + 'reference' => '0d63ff1e0ecb00ae5e5ca4032083bf83fd73a02c', + 'type' => 'project', + 'install_path' => __DIR__ . '/../../../', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'graham-campbell/result-type' => array( + 'pretty_version' => 'v1.1.3', + 'version' => '1.1.3.0', + 'reference' => '3ba905c11371512af9d9bdd27d99b782216b6945', + 'type' => 'library', + 'install_path' => __DIR__ . '/../graham-campbell/result-type', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'phpoption/phpoption' => array( + 'pretty_version' => '1.9.3', + 'version' => '1.9.3.0', + 'reference' => 'e3fac8b24f56113f7cb96af14958c0dd16330f54', + 'type' => 'library', + 'install_path' => __DIR__ . '/../phpoption/phpoption', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/polyfill-ctype' => array( + 'pretty_version' => 'v1.31.0', + 'version' => '1.31.0.0', + 'reference' => 'a3cc8b044a6ea513310cbd48ef7333b384945638', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-ctype', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/polyfill-mbstring' => array( + 'pretty_version' => 'v1.31.0', + 'version' => '1.31.0.0', + 'reference' => '85181ba99b2345b0ef10ce42ecac37612d9fd341', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/polyfill-php80' => array( + 'pretty_version' => 'v1.31.0', + 'version' => '1.31.0.0', + 'reference' => '60328e362d4c2c802a54fcbf04f9d3fb892b4cf8', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-php80', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'vlucas/phpdotenv' => array( + 'pretty_version' => 'v5.6.1', + 'version' => '5.6.1.0', + 'reference' => 'a59a13791077fe3d44f90e7133eb68e7d22eaff2', + 'type' => 'library', + 'install_path' => __DIR__ . '/../vlucas/phpdotenv', + 'aliases' => array(), + 'dev_requirement' => false, + ), + ), +); diff --git a/src/vendor/composer/platform_check.php b/src/vendor/composer/platform_check.php new file mode 100644 index 00000000..a8b98d5c --- /dev/null +++ b/src/vendor/composer/platform_check.php @@ -0,0 +1,26 @@ += 70205)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.5". You are running ' . PHP_VERSION . '.'; +} + +if ($issues) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); + } elseif (!headers_sent()) { + echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; + } + } + trigger_error( + 'Composer detected issues in your platform: ' . implode(' ', $issues), + E_USER_ERROR + ); +} diff --git a/src/vendor/graham-campbell/result-type b/src/vendor/graham-campbell/result-type new file mode 160000 index 00000000..3ba905c1 --- /dev/null +++ b/src/vendor/graham-campbell/result-type @@ -0,0 +1 @@ +Subproject commit 3ba905c11371512af9d9bdd27d99b782216b6945 diff --git a/src/vendor/phpoption/phpoption b/src/vendor/phpoption/phpoption new file mode 160000 index 00000000..e3fac8b2 --- /dev/null +++ b/src/vendor/phpoption/phpoption @@ -0,0 +1 @@ +Subproject commit e3fac8b24f56113f7cb96af14958c0dd16330f54 diff --git a/src/vendor/symfony/polyfill-ctype b/src/vendor/symfony/polyfill-ctype new file mode 160000 index 00000000..a3cc8b04 --- /dev/null +++ b/src/vendor/symfony/polyfill-ctype @@ -0,0 +1 @@ +Subproject commit a3cc8b044a6ea513310cbd48ef7333b384945638 diff --git a/src/vendor/symfony/polyfill-mbstring b/src/vendor/symfony/polyfill-mbstring new file mode 160000 index 00000000..85181ba9 --- /dev/null +++ b/src/vendor/symfony/polyfill-mbstring @@ -0,0 +1 @@ +Subproject commit 85181ba99b2345b0ef10ce42ecac37612d9fd341 diff --git a/src/vendor/symfony/polyfill-php80 b/src/vendor/symfony/polyfill-php80 new file mode 160000 index 00000000..60328e36 --- /dev/null +++ b/src/vendor/symfony/polyfill-php80 @@ -0,0 +1 @@ +Subproject commit 60328e362d4c2c802a54fcbf04f9d3fb892b4cf8 diff --git a/src/vendor/vlucas/phpdotenv b/src/vendor/vlucas/phpdotenv new file mode 160000 index 00000000..a59a1379 --- /dev/null +++ b/src/vendor/vlucas/phpdotenv @@ -0,0 +1 @@ +Subproject commit a59a13791077fe3d44f90e7133eb68e7d22eaff2 From 901a200675b14ed95730e89c9873dd2578a4c9ba Mon Sep 17 00:00:00 2001 From: SandraFerrando Date: Thu, 14 Nov 2024 16:27:30 +0100 Subject: [PATCH 02/15] feat(tree-type): add TreeType MVC --- src/app/Controllers/TreeTypesController.php | 2 +- src/app/Models/TreeType.php | 24 +++++++++------------ src/app/Views/TreeType.php | 23 ++++++++++++++++++++ 3 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 src/app/Views/TreeType.php diff --git a/src/app/Controllers/TreeTypesController.php b/src/app/Controllers/TreeTypesController.php index fbddda4e..6ab98ebe 100644 --- a/src/app/Controllers/TreeTypesController.php +++ b/src/app/Controllers/TreeTypesController.php @@ -11,7 +11,7 @@ public function index() { $tree_types = TreeType::getAll(); View::render([ - "view" => "TreeTypes", + "view" => "TreeType", "title" => "Tree Types", "layout" => "MainLayout", "data" => ["tree_types" => $tree_types] diff --git a/src/app/Models/TreeType.php b/src/app/Models/TreeType.php index b5c1e1b9..ee7df3d4 100644 --- a/src/app/Models/TreeType.php +++ b/src/app/Models/TreeType.php @@ -13,8 +13,7 @@ class TreeType private $subspecies; private $family; - - // Constructor to initialize properties (optional) + // Constructor para inicializar propiedades public function __construct($data = []) { foreach ($data as $key => $value) { @@ -22,7 +21,7 @@ public function __construct($data = []) } } - // Static method to retrieve all tree_types + // Método estático para recuperar todos los tipos de árboles public static function getAll() { $query = "SELECT * FROM tree_types"; @@ -33,29 +32,29 @@ public static function getAll() return $results; } - // Static method to find a tree_type by ID + // Método estático para encontrar un tipo de árbol por ID public static function findById($id) { - $query = "SELECT * FROM tree_types WHERE id = :id AND deleted_at IS NULL"; + $query = "SELECT * FROM tree_types WHERE id = :id"; $results = Database::prepareAndExecute($query, ['id' => $id]); return $results ? new self($results[0]) : null; } - // Static method to find a tree_type by family - public static function findByfamily($family) + // Método estático para encontrar un tipo de árbol por familia + public static function findByFamily($family) { - $query = "SELECT * FROM tree_types WHERE family = :family AND deleted_at IS NULL"; + $query = "SELECT * FROM tree_types WHERE family = :family"; $results = Database::prepareAndExecute($query, ['family' => $family]); return $results ? new self($results[0]) : null; } - // Method to save a new tree_type + // Método para guardar un nuevo tipo de árbol public function save() { $query = "INSERT INTO tree_types (species, subspecies, family) - VALUES (:species, :subspecies, :family, NOW(), NOW())"; + VALUES (:species, :subspecies, :family)"; $params = [ 'species' => $this->species, 'subspecies' => $this->subspecies, @@ -64,9 +63,8 @@ public function save() return Database::prepareAndExecute($query, $params); } - - // Getters and setters (you can add more as needed) + // Getters y setters public function getId() { return $this->id; @@ -86,6 +84,4 @@ public function getFamily() { return $this->family; } - - } diff --git a/src/app/Views/TreeType.php b/src/app/Views/TreeType.php new file mode 100644 index 00000000..d3788418 --- /dev/null +++ b/src/app/Views/TreeType.php @@ -0,0 +1,23 @@ +
+ + + + + + + + + + + + + + + + + + + +
IDSpeciesSubspeciesFamily
getId(); ?>getSpecies(); ?>getSubspecies(); ?>getFamily(); ?>
+
+ From a0d4bcb48dc92511b05d71e432a5cb52fd84f78a Mon Sep 17 00:00:00 2001 From: SandraFerrando Date: Thu, 14 Nov 2024 16:47:56 +0100 Subject: [PATCH 03/15] Revert "feat(tree-type): add TreeType" This reverts commit 1fdb55ec8dc34ff7a58561b973209f340e6b7c7a. --- src/app/Core/Logger.php | 12 +- src/app/Layouts/MainLayout.php | 2 +- src/app/routes.php | 10 +- src/vendor/autoload.php | 25 - src/vendor/composer/ClassLoader.php | 579 -------------------- src/vendor/composer/InstalledVersions.php | 359 ------------ src/vendor/composer/LICENSE | 21 - src/vendor/composer/autoload_classmap.php | 15 - src/vendor/composer/autoload_files.php | 12 - src/vendor/composer/autoload_namespaces.php | 9 - src/vendor/composer/autoload_psr4.php | 16 - src/vendor/composer/autoload_real.php | 50 -- src/vendor/composer/autoload_static.php | 89 --- src/vendor/composer/installed.json | 484 ---------------- src/vendor/composer/installed.php | 77 --- src/vendor/composer/platform_check.php | 26 - 16 files changed, 12 insertions(+), 1774 deletions(-) delete mode 100644 src/vendor/autoload.php delete mode 100644 src/vendor/composer/ClassLoader.php delete mode 100644 src/vendor/composer/InstalledVersions.php delete mode 100644 src/vendor/composer/LICENSE delete mode 100644 src/vendor/composer/autoload_classmap.php delete mode 100644 src/vendor/composer/autoload_files.php delete mode 100644 src/vendor/composer/autoload_namespaces.php delete mode 100644 src/vendor/composer/autoload_psr4.php delete mode 100644 src/vendor/composer/autoload_real.php delete mode 100644 src/vendor/composer/autoload_static.php delete mode 100644 src/vendor/composer/installed.json delete mode 100644 src/vendor/composer/installed.php delete mode 100644 src/vendor/composer/platform_check.php diff --git a/src/app/Core/Logger.php b/src/app/Core/Logger.php index d321ac8b..625509ba 100755 --- a/src/app/Core/Logger.php +++ b/src/app/Core/Logger.php @@ -6,12 +6,12 @@ class Logger { public static function log($message, $level = 'info') { - // $logFile = getenv("LOG_FILE_PATH"); - // $logMessage = strtoupper($level) . ' - ' . date('Y-m-d H:i:s') . ' - ' . $message . PHP_EOL; - // if (!file_exists($logFile)) { - // touch($logFile); - // } - //file_put_contents($logFile, $logMessage, FILE_APPEND); + $logFile = getenv("LOG_FILE_PATH"); + $logMessage = strtoupper($level) . ' - ' . date('Y-m-d H:i:s') . ' - ' . $message . PHP_EOL; + if (!file_exists($logFile)) { + touch($logFile); + } + file_put_contents($logFile, $logMessage, FILE_APPEND); } } diff --git a/src/app/Layouts/MainLayout.php b/src/app/Layouts/MainLayout.php index d6de76c9..62e27406 100755 --- a/src/app/Layouts/MainLayout.php +++ b/src/app/Layouts/MainLayout.php @@ -17,7 +17,7 @@ diff --git a/src/app/routes.php b/src/app/routes.php index 889eb733..18648278 100644 --- a/src/app/routes.php +++ b/src/app/routes.php @@ -13,22 +13,22 @@ * **/ -use App\Controllers\TreeTypesController; +use App\Controllers\HomeController; use App\Controllers\AuthController; return $routes = [ "GET" => [ "/" => [ - "controller" => TreeTypesController::class, + "controller" => HomeController::class, "method" => "index" ], "/login" => [ "controller" => AuthController::class, "method" => "index" ], - "/tree-types" => [ - "controller" => TreeTypesController::class, - "method" => "index" + "/exemple" => [ + "controller" => HomeController::class, + "method" => "exemple" ], ], ]; \ No newline at end of file diff --git a/src/vendor/autoload.php b/src/vendor/autoload.php deleted file mode 100644 index 4403f11a..00000000 --- a/src/vendor/autoload.php +++ /dev/null @@ -1,25 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Autoload; - -/** - * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. - * - * $loader = new \Composer\Autoload\ClassLoader(); - * - * // register classes with namespaces - * $loader->add('Symfony\Component', __DIR__.'/component'); - * $loader->add('Symfony', __DIR__.'/framework'); - * - * // activate the autoloader - * $loader->register(); - * - * // to enable searching the include path (eg. for PEAR packages) - * $loader->setUseIncludePath(true); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * This class is loosely based on the Symfony UniversalClassLoader. - * - * @author Fabien Potencier - * @author Jordi Boggiano - * @see https://www.php-fig.org/psr/psr-0/ - * @see https://www.php-fig.org/psr/psr-4/ - */ -class ClassLoader -{ - /** @var \Closure(string):void */ - private static $includeFile; - - /** @var string|null */ - private $vendorDir; - - // PSR-4 - /** - * @var array> - */ - private $prefixLengthsPsr4 = array(); - /** - * @var array> - */ - private $prefixDirsPsr4 = array(); - /** - * @var list - */ - private $fallbackDirsPsr4 = array(); - - // PSR-0 - /** - * List of PSR-0 prefixes - * - * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) - * - * @var array>> - */ - private $prefixesPsr0 = array(); - /** - * @var list - */ - private $fallbackDirsPsr0 = array(); - - /** @var bool */ - private $useIncludePath = false; - - /** - * @var array - */ - private $classMap = array(); - - /** @var bool */ - private $classMapAuthoritative = false; - - /** - * @var array - */ - private $missingClasses = array(); - - /** @var string|null */ - private $apcuPrefix; - - /** - * @var array - */ - private static $registeredLoaders = array(); - - /** - * @param string|null $vendorDir - */ - public function __construct($vendorDir = null) - { - $this->vendorDir = $vendorDir; - self::initializeIncludeClosure(); - } - - /** - * @return array> - */ - public function getPrefixes() - { - if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); - } - - return array(); - } - - /** - * @return array> - */ - public function getPrefixesPsr4() - { - return $this->prefixDirsPsr4; - } - - /** - * @return list - */ - public function getFallbackDirs() - { - return $this->fallbackDirsPsr0; - } - - /** - * @return list - */ - public function getFallbackDirsPsr4() - { - return $this->fallbackDirsPsr4; - } - - /** - * @return array Array of classname => path - */ - public function getClassMap() - { - return $this->classMap; - } - - /** - * @param array $classMap Class to filename map - * - * @return void - */ - public function addClassMap(array $classMap) - { - if ($this->classMap) { - $this->classMap = array_merge($this->classMap, $classMap); - } else { - $this->classMap = $classMap; - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, either - * appending or prepending to the ones previously set for this prefix. - * - * @param string $prefix The prefix - * @param list|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories - * - * @return void - */ - public function add($prefix, $paths, $prepend = false) - { - $paths = (array) $paths; - if (!$prefix) { - if ($prepend) { - $this->fallbackDirsPsr0 = array_merge( - $paths, - $this->fallbackDirsPsr0 - ); - } else { - $this->fallbackDirsPsr0 = array_merge( - $this->fallbackDirsPsr0, - $paths - ); - } - - return; - } - - $first = $prefix[0]; - if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = $paths; - - return; - } - if ($prepend) { - $this->prefixesPsr0[$first][$prefix] = array_merge( - $paths, - $this->prefixesPsr0[$first][$prefix] - ); - } else { - $this->prefixesPsr0[$first][$prefix] = array_merge( - $this->prefixesPsr0[$first][$prefix], - $paths - ); - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, either - * appending or prepending to the ones previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param list|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories - * - * @throws \InvalidArgumentException - * - * @return void - */ - public function addPsr4($prefix, $paths, $prepend = false) - { - $paths = (array) $paths; - if (!$prefix) { - // Register directories for the root namespace. - if ($prepend) { - $this->fallbackDirsPsr4 = array_merge( - $paths, - $this->fallbackDirsPsr4 - ); - } else { - $this->fallbackDirsPsr4 = array_merge( - $this->fallbackDirsPsr4, - $paths - ); - } - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { - // Register directories for a new namespace. - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = $paths; - } elseif ($prepend) { - // Prepend directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - $paths, - $this->prefixDirsPsr4[$prefix] - ); - } else { - // Append directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - $this->prefixDirsPsr4[$prefix], - $paths - ); - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, - * replacing any others previously set for this prefix. - * - * @param string $prefix The prefix - * @param list|string $paths The PSR-0 base directories - * - * @return void - */ - public function set($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr0 = (array) $paths; - } else { - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, - * replacing any others previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param list|string $paths The PSR-4 base directories - * - * @throws \InvalidArgumentException - * - * @return void - */ - public function setPsr4($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr4 = (array) $paths; - } else { - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } - } - - /** - * Turns on searching the include path for class files. - * - * @param bool $useIncludePath - * - * @return void - */ - public function setUseIncludePath($useIncludePath) - { - $this->useIncludePath = $useIncludePath; - } - - /** - * Can be used to check if the autoloader uses the include path to check - * for classes. - * - * @return bool - */ - public function getUseIncludePath() - { - return $this->useIncludePath; - } - - /** - * Turns off searching the prefix and fallback directories for classes - * that have not been registered with the class map. - * - * @param bool $classMapAuthoritative - * - * @return void - */ - public function setClassMapAuthoritative($classMapAuthoritative) - { - $this->classMapAuthoritative = $classMapAuthoritative; - } - - /** - * Should class lookup fail if not found in the current class map? - * - * @return bool - */ - public function isClassMapAuthoritative() - { - return $this->classMapAuthoritative; - } - - /** - * APCu prefix to use to cache found/not-found classes, if the extension is enabled. - * - * @param string|null $apcuPrefix - * - * @return void - */ - public function setApcuPrefix($apcuPrefix) - { - $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; - } - - /** - * The APCu prefix in use, or null if APCu caching is not enabled. - * - * @return string|null - */ - public function getApcuPrefix() - { - return $this->apcuPrefix; - } - - /** - * Registers this instance as an autoloader. - * - * @param bool $prepend Whether to prepend the autoloader or not - * - * @return void - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - - if (null === $this->vendorDir) { - return; - } - - if ($prepend) { - self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; - } else { - unset(self::$registeredLoaders[$this->vendorDir]); - self::$registeredLoaders[$this->vendorDir] = $this; - } - } - - /** - * Unregisters this instance as an autoloader. - * - * @return void - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - - if (null !== $this->vendorDir) { - unset(self::$registeredLoaders[$this->vendorDir]); - } - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return true|null True if loaded, null otherwise - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - $includeFile = self::$includeFile; - $includeFile($file); - - return true; - } - - return null; - } - - /** - * Finds the path to the file where the class is defined. - * - * @param string $class The name of the class - * - * @return string|false The path if found, false otherwise - */ - public function findFile($class) - { - // class map lookup - if (isset($this->classMap[$class])) { - return $this->classMap[$class]; - } - if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { - return false; - } - if (null !== $this->apcuPrefix) { - $file = apcu_fetch($this->apcuPrefix.$class, $hit); - if ($hit) { - return $file; - } - } - - $file = $this->findFileWithExtension($class, '.php'); - - // Search for Hack files if we are running on HHVM - if (false === $file && defined('HHVM_VERSION')) { - $file = $this->findFileWithExtension($class, '.hh'); - } - - if (null !== $this->apcuPrefix) { - apcu_add($this->apcuPrefix.$class, $file); - } - - if (false === $file) { - // Remember that this class does not exist. - $this->missingClasses[$class] = true; - } - - return $file; - } - - /** - * Returns the currently registered loaders keyed by their corresponding vendor directories. - * - * @return array - */ - public static function getRegisteredLoaders() - { - return self::$registeredLoaders; - } - - /** - * @param string $class - * @param string $ext - * @return string|false - */ - private function findFileWithExtension($class, $ext) - { - // PSR-4 lookup - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; - - $first = $class[0]; - if (isset($this->prefixLengthsPsr4[$first])) { - $subPath = $class; - while (false !== $lastPos = strrpos($subPath, '\\')) { - $subPath = substr($subPath, 0, $lastPos); - $search = $subPath . '\\'; - if (isset($this->prefixDirsPsr4[$search])) { - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); - foreach ($this->prefixDirsPsr4[$search] as $dir) { - if (file_exists($file = $dir . $pathEnd)) { - return $file; - } - } - } - } - } - - // PSR-4 fallback dirs - foreach ($this->fallbackDirsPsr4 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { - return $file; - } - } - - // PSR-0 lookup - if (false !== $pos = strrpos($class, '\\')) { - // namespaced class name - $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); - } else { - // PEAR-like class name - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; - } - - if (isset($this->prefixesPsr0[$first])) { - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { - if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - } - } - } - - // PSR-0 fallback dirs - foreach ($this->fallbackDirsPsr0 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - - // PSR-0 include paths. - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { - return $file; - } - - return false; - } - - /** - * @return void - */ - private static function initializeIncludeClosure() - { - if (self::$includeFile !== null) { - return; - } - - /** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - * - * @param string $file - * @return void - */ - self::$includeFile = \Closure::bind(static function($file) { - include $file; - }, null, null); - } -} diff --git a/src/vendor/composer/InstalledVersions.php b/src/vendor/composer/InstalledVersions.php deleted file mode 100644 index 51e734a7..00000000 --- a/src/vendor/composer/InstalledVersions.php +++ /dev/null @@ -1,359 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer; - -use Composer\Autoload\ClassLoader; -use Composer\Semver\VersionParser; - -/** - * This class is copied in every Composer installed project and available to all - * - * See also https://getcomposer.org/doc/07-runtime.md#installed-versions - * - * To require its presence, you can require `composer-runtime-api ^2.0` - * - * @final - */ -class InstalledVersions -{ - /** - * @var mixed[]|null - * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null - */ - private static $installed; - - /** - * @var bool|null - */ - private static $canGetVendors; - - /** - * @var array[] - * @psalm-var array}> - */ - private static $installedByVendor = array(); - - /** - * Returns a list of all package names which are present, either by being installed, replaced or provided - * - * @return string[] - * @psalm-return list - */ - public static function getInstalledPackages() - { - $packages = array(); - foreach (self::getInstalled() as $installed) { - $packages[] = array_keys($installed['versions']); - } - - if (1 === \count($packages)) { - return $packages[0]; - } - - return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); - } - - /** - * Returns a list of all package names with a specific type e.g. 'library' - * - * @param string $type - * @return string[] - * @psalm-return list - */ - public static function getInstalledPackagesByType($type) - { - $packagesByType = array(); - - foreach (self::getInstalled() as $installed) { - foreach ($installed['versions'] as $name => $package) { - if (isset($package['type']) && $package['type'] === $type) { - $packagesByType[] = $name; - } - } - } - - return $packagesByType; - } - - /** - * Checks whether the given package is installed - * - * This also returns true if the package name is provided or replaced by another package - * - * @param string $packageName - * @param bool $includeDevRequirements - * @return bool - */ - public static function isInstalled($packageName, $includeDevRequirements = true) - { - foreach (self::getInstalled() as $installed) { - if (isset($installed['versions'][$packageName])) { - return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; - } - } - - return false; - } - - /** - * Checks whether the given package satisfies a version constraint - * - * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: - * - * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') - * - * @param VersionParser $parser Install composer/semver to have access to this class and functionality - * @param string $packageName - * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package - * @return bool - */ - public static function satisfies(VersionParser $parser, $packageName, $constraint) - { - $constraint = $parser->parseConstraints((string) $constraint); - $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); - - return $provided->matches($constraint); - } - - /** - * Returns a version constraint representing all the range(s) which are installed for a given package - * - * It is easier to use this via isInstalled() with the $constraint argument if you need to check - * whether a given version of a package is installed, and not just whether it exists - * - * @param string $packageName - * @return string Version constraint usable with composer/semver - */ - public static function getVersionRanges($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - $ranges = array(); - if (isset($installed['versions'][$packageName]['pretty_version'])) { - $ranges[] = $installed['versions'][$packageName]['pretty_version']; - } - if (array_key_exists('aliases', $installed['versions'][$packageName])) { - $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); - } - if (array_key_exists('replaced', $installed['versions'][$packageName])) { - $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); - } - if (array_key_exists('provided', $installed['versions'][$packageName])) { - $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); - } - - return implode(' || ', $ranges); - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present - */ - public static function getVersion($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - if (!isset($installed['versions'][$packageName]['version'])) { - return null; - } - - return $installed['versions'][$packageName]['version']; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present - */ - public static function getPrettyVersion($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - if (!isset($installed['versions'][$packageName]['pretty_version'])) { - return null; - } - - return $installed['versions'][$packageName]['pretty_version']; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference - */ - public static function getReference($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - if (!isset($installed['versions'][$packageName]['reference'])) { - return null; - } - - return $installed['versions'][$packageName]['reference']; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. - */ - public static function getInstallPath($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @return array - * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} - */ - public static function getRootPackage() - { - $installed = self::getInstalled(); - - return $installed[0]['root']; - } - - /** - * Returns the raw installed.php data for custom implementations - * - * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. - * @return array[] - * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} - */ - public static function getRawData() - { - @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); - - if (null === self::$installed) { - // only require the installed.php file if this file is loaded from its dumped location, - // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 - if (substr(__DIR__, -8, 1) !== 'C') { - self::$installed = include __DIR__ . '/installed.php'; - } else { - self::$installed = array(); - } - } - - return self::$installed; - } - - /** - * Returns the raw data of all installed.php which are currently loaded for custom implementations - * - * @return array[] - * @psalm-return list}> - */ - public static function getAllRawData() - { - return self::getInstalled(); - } - - /** - * Lets you reload the static array from another file - * - * This is only useful for complex integrations in which a project needs to use - * this class but then also needs to execute another project's autoloader in process, - * and wants to ensure both projects have access to their version of installed.php. - * - * A typical case would be PHPUnit, where it would need to make sure it reads all - * the data it needs from this class, then call reload() with - * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure - * the project in which it runs can then also use this class safely, without - * interference between PHPUnit's dependencies and the project's dependencies. - * - * @param array[] $data A vendor/composer/installed.php data set - * @return void - * - * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data - */ - public static function reload($data) - { - self::$installed = $data; - self::$installedByVendor = array(); - } - - /** - * @return array[] - * @psalm-return list}> - */ - private static function getInstalled() - { - if (null === self::$canGetVendors) { - self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); - } - - $installed = array(); - - if (self::$canGetVendors) { - foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { - if (isset(self::$installedByVendor[$vendorDir])) { - $installed[] = self::$installedByVendor[$vendorDir]; - } elseif (is_file($vendorDir.'/composer/installed.php')) { - /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ - $required = require $vendorDir.'/composer/installed.php'; - $installed[] = self::$installedByVendor[$vendorDir] = $required; - if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { - self::$installed = $installed[count($installed) - 1]; - } - } - } - } - - if (null === self::$installed) { - // only require the installed.php file if this file is loaded from its dumped location, - // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 - if (substr(__DIR__, -8, 1) !== 'C') { - /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ - $required = require __DIR__ . '/installed.php'; - self::$installed = $required; - } else { - self::$installed = array(); - } - } - - if (self::$installed !== array()) { - $installed[] = self::$installed; - } - - return $installed; - } -} diff --git a/src/vendor/composer/LICENSE b/src/vendor/composer/LICENSE deleted file mode 100644 index f27399a0..00000000 --- a/src/vendor/composer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - -Copyright (c) Nils Adermann, Jordi Boggiano - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - diff --git a/src/vendor/composer/autoload_classmap.php b/src/vendor/composer/autoload_classmap.php deleted file mode 100644 index f6834955..00000000 --- a/src/vendor/composer/autoload_classmap.php +++ /dev/null @@ -1,15 +0,0 @@ - $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', - 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', - 'PhpToken' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php', - 'Stringable' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Stringable.php', - 'UnhandledMatchError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', - 'ValueError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', -); diff --git a/src/vendor/composer/autoload_files.php b/src/vendor/composer/autoload_files.php deleted file mode 100644 index cd554148..00000000 --- a/src/vendor/composer/autoload_files.php +++ /dev/null @@ -1,12 +0,0 @@ - $vendorDir . '/symfony/polyfill-ctype/bootstrap.php', - '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', - 'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php', -); diff --git a/src/vendor/composer/autoload_namespaces.php b/src/vendor/composer/autoload_namespaces.php deleted file mode 100644 index f1ae7a0f..00000000 --- a/src/vendor/composer/autoload_namespaces.php +++ /dev/null @@ -1,9 +0,0 @@ - array($vendorDir . '/symfony/polyfill-php80'), - 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), - 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'), - 'PhpOption\\' => array($vendorDir . '/phpoption/phpoption/src/PhpOption'), - 'GrahamCampbell\\ResultType\\' => array($vendorDir . '/graham-campbell/result-type/src'), - 'Dotenv\\' => array($vendorDir . '/vlucas/phpdotenv/src'), - 'App\\' => array($baseDir . '/src/app'), -); diff --git a/src/vendor/composer/autoload_real.php b/src/vendor/composer/autoload_real.php deleted file mode 100644 index a686a7e4..00000000 --- a/src/vendor/composer/autoload_real.php +++ /dev/null @@ -1,50 +0,0 @@ -register(true); - - $filesToLoad = \Composer\Autoload\ComposerStaticIniteb55ab41b565401c02d945b712f3b194::$files; - $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { - if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { - $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; - - require $file; - } - }, null, null); - foreach ($filesToLoad as $fileIdentifier => $file) { - $requireFile($fileIdentifier, $file); - } - - return $loader; - } -} diff --git a/src/vendor/composer/autoload_static.php b/src/vendor/composer/autoload_static.php deleted file mode 100644 index 5bbd9ff1..00000000 --- a/src/vendor/composer/autoload_static.php +++ /dev/null @@ -1,89 +0,0 @@ - __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php', - '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', - 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', - ); - - public static $prefixLengthsPsr4 = array ( - 'S' => - array ( - 'Symfony\\Polyfill\\Php80\\' => 23, - 'Symfony\\Polyfill\\Mbstring\\' => 26, - 'Symfony\\Polyfill\\Ctype\\' => 23, - ), - 'P' => - array ( - 'PhpOption\\' => 10, - ), - 'G' => - array ( - 'GrahamCampbell\\ResultType\\' => 26, - ), - 'D' => - array ( - 'Dotenv\\' => 7, - ), - 'A' => - array ( - 'App\\' => 4, - ), - ); - - public static $prefixDirsPsr4 = array ( - 'Symfony\\Polyfill\\Php80\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/polyfill-php80', - ), - 'Symfony\\Polyfill\\Mbstring\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring', - ), - 'Symfony\\Polyfill\\Ctype\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype', - ), - 'PhpOption\\' => - array ( - 0 => __DIR__ . '/..' . '/phpoption/phpoption/src/PhpOption', - ), - 'GrahamCampbell\\ResultType\\' => - array ( - 0 => __DIR__ . '/..' . '/graham-campbell/result-type/src', - ), - 'Dotenv\\' => - array ( - 0 => __DIR__ . '/..' . '/vlucas/phpdotenv/src', - ), - 'App\\' => - array ( - 0 => __DIR__ . '/../../..' . '/src/app', - ), - ); - - public static $classMap = array ( - 'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', - 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', - 'PhpToken' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php', - 'Stringable' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Stringable.php', - 'UnhandledMatchError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', - 'ValueError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', - ); - - public static function getInitializer(ClassLoader $loader) - { - return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticIniteb55ab41b565401c02d945b712f3b194::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticIniteb55ab41b565401c02d945b712f3b194::$prefixDirsPsr4; - $loader->classMap = ComposerStaticIniteb55ab41b565401c02d945b712f3b194::$classMap; - - }, null, ClassLoader::class); - } -} diff --git a/src/vendor/composer/installed.json b/src/vendor/composer/installed.json deleted file mode 100644 index 82aca11a..00000000 --- a/src/vendor/composer/installed.json +++ /dev/null @@ -1,484 +0,0 @@ -{ - "packages": [ - { - "name": "graham-campbell/result-type", - "version": "v1.1.3", - "version_normalized": "1.1.3.0", - "source": { - "type": "git", - "url": "https://github.com/GrahamCampbell/Result-Type.git", - "reference": "3ba905c11371512af9d9bdd27d99b782216b6945" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/3ba905c11371512af9d9bdd27d99b782216b6945", - "reference": "3ba905c11371512af9d9bdd27d99b782216b6945", - "shasum": "" - }, - "require": { - "php": "^7.2.5 || ^8.0", - "phpoption/phpoption": "^1.9.3" - }, - "require-dev": { - "phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28" - }, - "time": "2024-07-20T21:45:45+00:00", - "type": "library", - "installation-source": "source", - "autoload": { - "psr-4": { - "GrahamCampbell\\ResultType\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - } - ], - "description": "An Implementation Of The Result Type", - "keywords": [ - "Graham Campbell", - "GrahamCampbell", - "Result Type", - "Result-Type", - "result" - ], - "support": { - "issues": "https://github.com/GrahamCampbell/Result-Type/issues", - "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.3" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type", - "type": "tidelift" - } - ], - "install-path": "../graham-campbell/result-type" - }, - { - "name": "phpoption/phpoption", - "version": "1.9.3", - "version_normalized": "1.9.3.0", - "source": { - "type": "git", - "url": "https://github.com/schmittjoh/php-option.git", - "reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/e3fac8b24f56113f7cb96af14958c0dd16330f54", - "reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54", - "shasum": "" - }, - "require": { - "php": "^7.2.5 || ^8.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28" - }, - "time": "2024-07-20T21:41:07+00:00", - "type": "library", - "extra": { - "bamarni-bin": { - "bin-links": true, - "forward-command": false - }, - "branch-alias": { - "dev-master": "1.9-dev" - } - }, - "installation-source": "source", - "autoload": { - "psr-4": { - "PhpOption\\": "src/PhpOption/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Johannes M. Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh" - }, - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - } - ], - "description": "Option Type for PHP", - "keywords": [ - "language", - "option", - "php", - "type" - ], - "support": { - "issues": "https://github.com/schmittjoh/php-option/issues", - "source": "https://github.com/schmittjoh/php-option/tree/1.9.3" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption", - "type": "tidelift" - } - ], - "install-path": "../phpoption/phpoption" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.31.0", - "version_normalized": "1.31.0.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", - "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "provide": { - "ext-ctype": "*" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "time": "2024-09-09T11:45:10+00:00", - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "installation-source": "source", - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "install-path": "../symfony/polyfill-ctype" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.31.0", - "version_normalized": "1.31.0.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", - "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "provide": { - "ext-mbstring": "*" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "time": "2024-09-09T11:45:10+00:00", - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "installation-source": "source", - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "install-path": "../symfony/polyfill-mbstring" - }, - { - "name": "symfony/polyfill-php80", - "version": "v1.31.0", - "version_normalized": "1.31.0.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "time": "2024-09-09T11:45:10+00:00", - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "installation-source": "source", - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "install-path": "../symfony/polyfill-php80" - }, - { - "name": "vlucas/phpdotenv", - "version": "v5.6.1", - "version_normalized": "5.6.1.0", - "source": { - "type": "git", - "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "a59a13791077fe3d44f90e7133eb68e7d22eaff2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/a59a13791077fe3d44f90e7133eb68e7d22eaff2", - "reference": "a59a13791077fe3d44f90e7133eb68e7d22eaff2", - "shasum": "" - }, - "require": { - "ext-pcre": "*", - "graham-campbell/result-type": "^1.1.3", - "php": "^7.2.5 || ^8.0", - "phpoption/phpoption": "^1.9.3", - "symfony/polyfill-ctype": "^1.24", - "symfony/polyfill-mbstring": "^1.24", - "symfony/polyfill-php80": "^1.24" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.2", - "ext-filter": "*", - "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2" - }, - "suggest": { - "ext-filter": "Required to use the boolean validator." - }, - "time": "2024-07-20T21:52:34+00:00", - "type": "library", - "extra": { - "bamarni-bin": { - "bin-links": true, - "forward-command": false - }, - "branch-alias": { - "dev-master": "5.6-dev" - } - }, - "installation-source": "source", - "autoload": { - "psr-4": { - "Dotenv\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Vance Lucas", - "email": "vance@vancelucas.com", - "homepage": "https://github.com/vlucas" - } - ], - "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", - "keywords": [ - "dotenv", - "env", - "environment" - ], - "support": { - "issues": "https://github.com/vlucas/phpdotenv/issues", - "source": "https://github.com/vlucas/phpdotenv/tree/v5.6.1" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", - "type": "tidelift" - } - ], - "install-path": "../vlucas/phpdotenv" - } - ], - "dev": true, - "dev-package-names": [] -} diff --git a/src/vendor/composer/installed.php b/src/vendor/composer/installed.php deleted file mode 100644 index 6a4bfb51..00000000 --- a/src/vendor/composer/installed.php +++ /dev/null @@ -1,77 +0,0 @@ - array( - 'name' => 'daw-iesmontsia/urban-tree', - 'pretty_version' => 'dev-main', - 'version' => 'dev-main', - 'reference' => '0d63ff1e0ecb00ae5e5ca4032083bf83fd73a02c', - 'type' => 'project', - 'install_path' => __DIR__ . '/../../../', - 'aliases' => array(), - 'dev' => true, - ), - 'versions' => array( - 'daw-iesmontsia/urban-tree' => array( - 'pretty_version' => 'dev-main', - 'version' => 'dev-main', - 'reference' => '0d63ff1e0ecb00ae5e5ca4032083bf83fd73a02c', - 'type' => 'project', - 'install_path' => __DIR__ . '/../../../', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'graham-campbell/result-type' => array( - 'pretty_version' => 'v1.1.3', - 'version' => '1.1.3.0', - 'reference' => '3ba905c11371512af9d9bdd27d99b782216b6945', - 'type' => 'library', - 'install_path' => __DIR__ . '/../graham-campbell/result-type', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'phpoption/phpoption' => array( - 'pretty_version' => '1.9.3', - 'version' => '1.9.3.0', - 'reference' => 'e3fac8b24f56113f7cb96af14958c0dd16330f54', - 'type' => 'library', - 'install_path' => __DIR__ . '/../phpoption/phpoption', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'symfony/polyfill-ctype' => array( - 'pretty_version' => 'v1.31.0', - 'version' => '1.31.0.0', - 'reference' => 'a3cc8b044a6ea513310cbd48ef7333b384945638', - 'type' => 'library', - 'install_path' => __DIR__ . '/../symfony/polyfill-ctype', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'symfony/polyfill-mbstring' => array( - 'pretty_version' => 'v1.31.0', - 'version' => '1.31.0.0', - 'reference' => '85181ba99b2345b0ef10ce42ecac37612d9fd341', - 'type' => 'library', - 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'symfony/polyfill-php80' => array( - 'pretty_version' => 'v1.31.0', - 'version' => '1.31.0.0', - 'reference' => '60328e362d4c2c802a54fcbf04f9d3fb892b4cf8', - 'type' => 'library', - 'install_path' => __DIR__ . '/../symfony/polyfill-php80', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'vlucas/phpdotenv' => array( - 'pretty_version' => 'v5.6.1', - 'version' => '5.6.1.0', - 'reference' => 'a59a13791077fe3d44f90e7133eb68e7d22eaff2', - 'type' => 'library', - 'install_path' => __DIR__ . '/../vlucas/phpdotenv', - 'aliases' => array(), - 'dev_requirement' => false, - ), - ), -); diff --git a/src/vendor/composer/platform_check.php b/src/vendor/composer/platform_check.php deleted file mode 100644 index a8b98d5c..00000000 --- a/src/vendor/composer/platform_check.php +++ /dev/null @@ -1,26 +0,0 @@ -= 70205)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.5". You are running ' . PHP_VERSION . '.'; -} - -if ($issues) { - if (!headers_sent()) { - header('HTTP/1.1 500 Internal Server Error'); - } - if (!ini_get('display_errors')) { - if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { - fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); - } elseif (!headers_sent()) { - echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; - } - } - trigger_error( - 'Composer detected issues in your platform: ' . implode(' ', $issues), - E_USER_ERROR - ); -} From 9f6a18b44c2360bc3c91cfd00178892649214088 Mon Sep 17 00:00:00 2001 From: 0x1026 <69076992+0x1026@users.noreply.github.com> Date: Thu, 14 Nov 2024 17:02:51 +0100 Subject: [PATCH 04/15] Revert "feat(tree-type): add TreeType" This reverts commit 1fdb55ec8dc34ff7a58561b973209f340e6b7c7a. --- src/vendor/graham-campbell/result-type | 1 - src/vendor/phpoption/phpoption | 1 - src/vendor/symfony/polyfill-ctype | 1 - src/vendor/symfony/polyfill-mbstring | 1 - src/vendor/symfony/polyfill-php80 | 1 - src/vendor/vlucas/phpdotenv | 1 - 6 files changed, 6 deletions(-) delete mode 160000 src/vendor/graham-campbell/result-type delete mode 160000 src/vendor/phpoption/phpoption delete mode 160000 src/vendor/symfony/polyfill-ctype delete mode 160000 src/vendor/symfony/polyfill-mbstring delete mode 160000 src/vendor/symfony/polyfill-php80 delete mode 160000 src/vendor/vlucas/phpdotenv diff --git a/src/vendor/graham-campbell/result-type b/src/vendor/graham-campbell/result-type deleted file mode 160000 index 3ba905c1..00000000 --- a/src/vendor/graham-campbell/result-type +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3ba905c11371512af9d9bdd27d99b782216b6945 diff --git a/src/vendor/phpoption/phpoption b/src/vendor/phpoption/phpoption deleted file mode 160000 index e3fac8b2..00000000 --- a/src/vendor/phpoption/phpoption +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e3fac8b24f56113f7cb96af14958c0dd16330f54 diff --git a/src/vendor/symfony/polyfill-ctype b/src/vendor/symfony/polyfill-ctype deleted file mode 160000 index a3cc8b04..00000000 --- a/src/vendor/symfony/polyfill-ctype +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a3cc8b044a6ea513310cbd48ef7333b384945638 diff --git a/src/vendor/symfony/polyfill-mbstring b/src/vendor/symfony/polyfill-mbstring deleted file mode 160000 index 85181ba9..00000000 --- a/src/vendor/symfony/polyfill-mbstring +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 85181ba99b2345b0ef10ce42ecac37612d9fd341 diff --git a/src/vendor/symfony/polyfill-php80 b/src/vendor/symfony/polyfill-php80 deleted file mode 160000 index 60328e36..00000000 --- a/src/vendor/symfony/polyfill-php80 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 60328e362d4c2c802a54fcbf04f9d3fb892b4cf8 diff --git a/src/vendor/vlucas/phpdotenv b/src/vendor/vlucas/phpdotenv deleted file mode 160000 index a59a1379..00000000 --- a/src/vendor/vlucas/phpdotenv +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a59a13791077fe3d44f90e7133eb68e7d22eaff2 From d42a61ee59cae2fdcc28561ea37cd054d33e90d2 Mon Sep 17 00:00:00 2001 From: 0x1026 <69076992+0x1026@users.noreply.github.com> Date: Thu, 14 Nov 2024 23:50:48 +0100 Subject: [PATCH 05/15] feat(database): enhance tree_types table with unique constraints --- docker/database/start-scripts/0-init.sql | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docker/database/start-scripts/0-init.sql b/docker/database/start-scripts/0-init.sql index 440ba32a..038efa90 100644 --- a/docker/database/start-scripts/0-init.sql +++ b/docker/database/start-scripts/0-init.sql @@ -15,9 +15,10 @@ create table zones ( create table tree_types ( id int auto_increment primary key, - species varchar(255), - subspecies varchar(255), - family varchar(255) + family varchar(255) not null, + genus varchar(255) not null, + species varchar(255) not null unique, + constraint UC_TreeType unique (family, genus, species) ); create table elements ( From d26a58a6d3f1ae81569f576268d7c81452b42301 Mon Sep 17 00:00:00 2001 From: 0x1026 <69076992+0x1026@users.noreply.github.com> Date: Thu, 14 Nov 2024 23:53:34 +0100 Subject: [PATCH 06/15] revert(database): remove changes --- docker/database/start-scripts/1-seed.sql | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/docker/database/start-scripts/1-seed.sql b/docker/database/start-scripts/1-seed.sql index 9bfb6adb..de9da5fb 100644 --- a/docker/database/start-scripts/1-seed.sql +++ b/docker/database/start-scripts/1-seed.sql @@ -1,13 +1,11 @@ --- Inserts per a la taula tree_types -INSERT INTO tree_types (species, subspecies, family) -VALUES - ('Quercus', 'Quercus robur', 'Fagaceae'), - ('Pinus', 'Pinus sylvestris', 'Pinaceae'), - ('Acer', 'Acer campestre', 'Sapindaceae'); +-- Insert sample roles (Admin, Manager, Worker) +INSERT INTO roles (role_name) VALUES +('Administrador'), +('Gerente'), +('Trabajador'); --- Inserts per a la taula elements -INSERT INTO elements (name, latitude, longitude, tree_types_id, created_at, deleted_at, updated_at) -VALUES - ('Roureda de la Selva', 41.8793, 2.8246, 1, '2024-11-01 10:30:00', NULL, '2024-11-10 12:00:00'), - ('Pineda de les Gavarres', 41.9738, 2.7756, 2, '2024-11-02 09:45:00', NULL, '2024-11-11 11:15:00'), - ('Arbre de la Plaça Major', 41.3879, 2.1699, 3, '2024-11-03 08:00:00', NULL, '2024-11-12 10:20:00'); +-- Insert sample workers (Spanish users) +INSERT INTO workers (company, name, dni, password, email, role_id, created_at, updated_at, deleted_at) VALUES +('TechCorp', 'Carlos García', '12345678A', 'hashedpassword1', 'carlos.garcia@example.com', 1, NOW(), NOW(), NULL), -- Admin +('InnovaTech', 'Ana Martínez', '23456789B', 'hashedpassword2', 'ana.martinez@example.com', 2, NOW(), NOW(), NULL), -- Manager +('DesignWorks', 'José Rodríguez', '34567890C', 'hashedpassword3', 'jose.rodriguez@example.com', 3, NOW(), NOW(), NULL); -- Worker \ No newline at end of file From cbd5e7dc40bae1808421ed284708e53cce967ecb Mon Sep 17 00:00:00 2001 From: 0x1026 <69076992+0x1026@users.noreply.github.com> Date: Thu, 14 Nov 2024 23:55:08 +0100 Subject: [PATCH 07/15] feat(database): add sample tree types to seeding script --- docker/database/start-scripts/1-seed.sql | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docker/database/start-scripts/1-seed.sql b/docker/database/start-scripts/1-seed.sql index de9da5fb..711227c3 100644 --- a/docker/database/start-scripts/1-seed.sql +++ b/docker/database/start-scripts/1-seed.sql @@ -8,4 +8,10 @@ INSERT INTO roles (role_name) VALUES INSERT INTO workers (company, name, dni, password, email, role_id, created_at, updated_at, deleted_at) VALUES ('TechCorp', 'Carlos García', '12345678A', 'hashedpassword1', 'carlos.garcia@example.com', 1, NOW(), NOW(), NULL), -- Admin ('InnovaTech', 'Ana Martínez', '23456789B', 'hashedpassword2', 'ana.martinez@example.com', 2, NOW(), NOW(), NULL), -- Manager -('DesignWorks', 'José Rodríguez', '34567890C', 'hashedpassword3', 'jose.rodriguez@example.com', 3, NOW(), NOW(), NULL); -- Worker \ No newline at end of file +('DesignWorks', 'José Rodríguez', '34567890C', 'hashedpassword3', 'jose.rodriguez@example.com', 3, NOW(), NOW(), NULL); -- Worker + +-- Insert sample tree types +INSERT INTO tree_types (family, genus, species) VALUES +('Fagaceae', 'Quercus', 'Quercus robur'), +('Pinaceae', 'Pinus', 'Pinus sylvestris'), +('Sapindaceae', 'Acer', 'Acer campestre'); From bf47d1f89a3a253177d41a3ce3dcef92be71980e Mon Sep 17 00:00:00 2001 From: 0x1026 <69076992+0x1026@users.noreply.github.com> Date: Thu, 14 Nov 2024 23:56:00 +0100 Subject: [PATCH 08/15] refactor(tree-type): rename controller for consistency --- .../{TreeTypesController.php => TreeTypeController.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/app/Controllers/{TreeTypesController.php => TreeTypeController.php} (93%) diff --git a/src/app/Controllers/TreeTypesController.php b/src/app/Controllers/TreeTypeController.php similarity index 93% rename from src/app/Controllers/TreeTypesController.php rename to src/app/Controllers/TreeTypeController.php index 6ab98ebe..94b81ebf 100644 --- a/src/app/Controllers/TreeTypesController.php +++ b/src/app/Controllers/TreeTypeController.php @@ -5,7 +5,7 @@ use App\Core\View; use App\Models\TreeType; -class TreeTypesController +class TreeTypeController { public function index() { From 16fb22dfccebb37a78251216c913e6dc9851580b Mon Sep 17 00:00:00 2001 From: SandraFerrando Date: Fri, 15 Nov 2024 15:35:29 +0100 Subject: [PATCH 09/15] fix(tree-type): add suggestions --- src/app/Models/TreeType.php | 48 +++++++++++++++++++++++++------------ src/app/Views/TreeType.php | 8 +++---- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/app/Models/TreeType.php b/src/app/Models/TreeType.php index ee7df3d4..9b469014 100644 --- a/src/app/Models/TreeType.php +++ b/src/app/Models/TreeType.php @@ -8,10 +8,10 @@ class TreeType { - private $id; - private $species; - private $subspecies; - private $family; + private int $id; + private string $family; + private string $genus; + private string $species; // Constructor para inicializar propiedades public function __construct($data = []) @@ -50,15 +50,33 @@ public static function findByFamily($family) return $results ? new self($results[0]) : null; } + + public static function findByGenus($genus) + { + $query = "SELECT * FROM tree_types WHERE genus = :genus"; + $results = Database::prepareAndExecute($query, ['genus' => $genus]); + + return $results ? new self($results[0]) : null; + } + + + public static function findBySpecies($species) + { + $query = "SELECT * FROM tree_types WHERE species = :species"; + $results = Database::prepareAndExecute($query, ['species' => $species]); + return $results ? new self($results[0]) : null; + } + + // Método para guardar un nuevo tipo de árbol public function save() { - $query = "INSERT INTO tree_types (species, subspecies, family) - VALUES (:species, :subspecies, :family)"; + $query = "INSERT INTO tree_types (family, genus, species) + VALUES (:family, :genus, :species)"; $params = [ - 'species' => $this->species, - 'subspecies' => $this->subspecies, 'family' => $this->family, + 'genus' => $this->genus, + 'species' => $this->species ]; return Database::prepareAndExecute($query, $params); @@ -70,18 +88,18 @@ public function getId() return $this->id; } - public function getSpecies() + public function getFamily() { - return $this->species; + return $this->family; } - public function getSubspecies() + public function getGenus() { - return $this->subspecies; + return $this->genus; } - public function getFamily() - { - return $this->family; + public function getSpecies() + { + return $this->species; } } diff --git a/src/app/Views/TreeType.php b/src/app/Views/TreeType.php index d3788418..9a83e504 100644 --- a/src/app/Views/TreeType.php +++ b/src/app/Views/TreeType.php @@ -3,18 +3,18 @@ ID - Species - Subspecies Family + Genus + Species getId(); ?> - getSpecies(); ?> - getSubspecies(); ?> getFamily(); ?> + getGenus(); ?> + getSpecies(); ?> From 14ae820d030026d787b1df5428e4005097ea52a7 Mon Sep 17 00:00:00 2001 From: SandraFerrando Date: Fri, 15 Nov 2024 15:41:19 +0100 Subject: [PATCH 10/15] feat(tree-type): add setters --- src/app/Models/TreeType.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/app/Models/TreeType.php b/src/app/Models/TreeType.php index 9b469014..dbc66501 100644 --- a/src/app/Models/TreeType.php +++ b/src/app/Models/TreeType.php @@ -50,7 +50,7 @@ public static function findByFamily($family) return $results ? new self($results[0]) : null; } - + public static function findByGenus($genus) { $query = "SELECT * FROM tree_types WHERE genus = :genus"; @@ -59,7 +59,7 @@ public static function findByGenus($genus) return $results ? new self($results[0]) : null; } - + public static function findBySpecies($species) { $query = "SELECT * FROM tree_types WHERE species = :species"; @@ -71,7 +71,7 @@ public static function findBySpecies($species) // Método para guardar un nuevo tipo de árbol public function save() { - $query = "INSERT INTO tree_types (family, genus, species) + $query = "INSERT INTO tree_types (family, genus, species) VALUES (:family, :genus, :species)"; $params = [ 'family' => $this->family, @@ -99,7 +99,22 @@ public function getGenus() } public function getSpecies() - { + { return $this->species; } + + public function setFamily($family) + { + $this->family = $family; + } + + public function setGenus($genus) + { + $this->genus = $genus; + } + + public function setSpecies($species) + { + $this->species = $species; + } } From b40edbd583f891b982c6bdc270658732ec5b90a5 Mon Sep 17 00:00:00 2001 From: SandraFerrando Date: Fri, 15 Nov 2024 15:44:11 +0100 Subject: [PATCH 11/15] fix(tree-types): change variable name to follow the style --- src/app/Views/TreeType.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/Views/TreeType.php b/src/app/Views/TreeType.php index 9a83e504..b577dd1a 100644 --- a/src/app/Views/TreeType.php +++ b/src/app/Views/TreeType.php @@ -9,12 +9,12 @@ - + - getId(); ?> - getFamily(); ?> - getGenus(); ?> - getSpecies(); ?> + getId(); ?> + getFamily(); ?> + getGenus(); ?> + getSpecies(); ?> From ef861d747b228ea6021f3ea40c1ca5b758a58234 Mon Sep 17 00:00:00 2001 From: SandraFerrando Date: Fri, 15 Nov 2024 16:57:23 +0100 Subject: [PATCH 12/15] feat(tree-type): add update and delete functions --- src/app/Models/TreeType.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/app/Models/TreeType.php b/src/app/Models/TreeType.php index dbc66501..cf3e7ae2 100644 --- a/src/app/Models/TreeType.php +++ b/src/app/Models/TreeType.php @@ -82,6 +82,28 @@ public function save() return Database::prepareAndExecute($query, $params); } + public function update() + { + $query = "UPDATE tree_types SET family = :family, genus = :genus, species = :species + WHERE id = :id"; + $params = [ + 'id' => $this->id, + 'family' => $this->family, + 'genus' => $this->genus, + 'species' => $this->species, + ]; + + return Database::prepareAndExecute($query, $params); + } + + // Method to delete a tree type (hard delete) + public function delete() + { + $query = "DELETE FROM tree_types WHERE id = :id"; + return Database::prepareAndExecute($query, ['id' => $this->id]); + } + + // Getters y setters public function getId() { From 02d50bfc844708fea271c757e9494b0eda793212 Mon Sep 17 00:00:00 2001 From: 0x1026 <69076992+0x1026@users.noreply.github.com> Date: Sat, 16 Nov 2024 13:24:59 +0100 Subject: [PATCH 13/15] refactor(router): improve routing logic --- src/app/Controllers/AuthController.php | 11 +++++++--- src/app/Controllers/Controller.php | 9 -------- src/app/Controllers/HomeController.php | 11 +++++++--- src/app/Core/BaseController.php | 11 ++++++++++ src/app/Core/Router.php | 18 +++++++--------- src/app/bootstrap.php | 2 -- src/app/routes.php | 29 +++++++------------------- src/public/index.php | 6 ++++-- 8 files changed, 46 insertions(+), 51 deletions(-) delete mode 100755 src/app/Controllers/Controller.php create mode 100644 src/app/Core/BaseController.php diff --git a/src/app/Controllers/AuthController.php b/src/app/Controllers/AuthController.php index 88438bd6..d1d29384 100755 --- a/src/app/Controllers/AuthController.php +++ b/src/app/Controllers/AuthController.php @@ -2,11 +2,12 @@ namespace App\Controllers; +use App\Core\BaseController; use App\Core\View; -class AuthController +class AuthController implements BaseController { - public function index() + public function get() { View::render([ "view" => "Auth/Login", @@ -15,4 +16,8 @@ public function index() "data" => [] ]); } -} \ No newline at end of file + + public function post() {} + public function put() {} + public function delete() {} +} diff --git a/src/app/Controllers/Controller.php b/src/app/Controllers/Controller.php deleted file mode 100755 index 938c0983..00000000 --- a/src/app/Controllers/Controller.php +++ /dev/null @@ -1,9 +0,0 @@ - ["workers" => $workers] ]); } -} \ No newline at end of file + + public function post() {} + public function put() {} + public function delete() {} +} diff --git a/src/app/Core/BaseController.php b/src/app/Core/BaseController.php new file mode 100644 index 00000000..74b3704f --- /dev/null +++ b/src/app/Core/BaseController.php @@ -0,0 +1,11 @@ +routes[$requestMethod][$requestUri])) { - return $this->callRoute($this->routes[$requestMethod][$requestUri], $requestMethod === 'POST' ? $_POST : []); - } + if (isset($this->routes[$requestUri])) + return $this->callRoute(strtolower($requestMethod), $this->routes[$requestUri], $requestMethod === 'POST' ? $_POST : []); // If no direct match, check for dynamic routes with parameters - foreach ($this->routes[$requestMethod] as $route => $routeInfo) { + foreach ($this->routes as $route => $routeController) { $routePattern = preg_replace('/:\w+/', '(\w+)', $route); $pattern = '#^' . $routePattern . '$#'; if (preg_match($pattern, $requestUri, $matches)) { array_shift($matches); // Remove the full match $params = $this->extractParams($route, $matches); - return $this->callRoute($routeInfo, $params, $requestMethod === 'POST' ? $_POST : []); + return $this->callRoute(strtolower($requestMethod), $routeController, $params, $requestMethod === 'POST' ? $_POST : []); } } @@ -40,14 +39,13 @@ protected function extractParams($route, $matches) return array_combine($paramNames[1], $matches); } - protected function callRoute($routeInfo, $params = [], $postData = []) + protected function callRoute($method, $routeController, $params = [], $postData = []) { - $controller = new $routeInfo['controller'](); - $method = $routeInfo['method']; - + $controller = new $routeController(); + // Combine route parameters and POST data $arguments = array_merge(array_values($params), [$postData]); - + // Unpack the combined array into the method call $controller->$method(...$arguments); } diff --git a/src/app/bootstrap.php b/src/app/bootstrap.php index b186cc68..3b7f102f 100644 --- a/src/app/bootstrap.php +++ b/src/app/bootstrap.php @@ -1,7 +1,5 @@ [ - * "URI" => [ - * "controller" => "ControllerName", - * "method" => "methodName" - * ] + * + * [ + * "URI" => "ControllerName", * ] - * + * **/ use App\Controllers\HomeController; use App\Controllers\AuthController; return $routes = [ - "GET" => [ - "/" => [ - "controller" => HomeController::class, - "method" => "index" - ], - "/login" => [ - "controller" => AuthController::class, - "method" => "index" - ], - "/exemple" => [ - "controller" => HomeController::class, - "method" => "exemple" - ], - ], -]; \ No newline at end of file + "/" => HomeController::class, + "/login" => AuthController::class, +]; diff --git a/src/public/index.php b/src/public/index.php index 08b8efad..5e3f03d6 100755 --- a/src/public/index.php +++ b/src/public/index.php @@ -1,9 +1,11 @@ load('../app/routes.php'); -$router->dispatch($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']); \ No newline at end of file +$router->dispatch($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']); From a74c80c94032ebe7f72d7dc32bbdac3f9eca7411 Mon Sep 17 00:00:00 2001 From: 0x1026 <69076992+0x1026@users.noreply.github.com> Date: Sat, 16 Nov 2024 13:28:24 +0100 Subject: [PATCH 14/15] refactor(models): improve database interactions --- docker/database/start-scripts/0-init.sql | 40 ++--- docker/database/start-scripts/1-seed.sql | 4 +- src/app/Controllers/HomeController.php | 2 +- src/app/Core/BaseModel.php | 151 ++++++++++++++++++ src/app/Models/Role.php | 23 +++ src/app/Models/Worker.php | 195 +++-------------------- src/app/Views/Home.php | 14 +- 7 files changed, 227 insertions(+), 202 deletions(-) create mode 100644 src/app/Core/BaseModel.php create mode 100644 src/app/Models/Role.php diff --git a/docker/database/start-scripts/0-init.sql b/docker/database/start-scripts/0-init.sql index 8626380d..e277d42a 100644 --- a/docker/database/start-scripts/0-init.sql +++ b/docker/database/start-scripts/0-init.sql @@ -8,8 +8,8 @@ create table zones ( id int auto_increment primary key, name varchar(255), quantity int, - postal_code int, - point_id int, + postal_code int, + point_id int, foreign key (point_id) references points(id) ); @@ -25,8 +25,8 @@ create table elements ( create table inventory ( id int auto_increment primary key, - element_id int, - zone_id int, + element_id int, + zone_id int, foreign key (element_id) references elements(id), foreign key (zone_id) references zones(id) ); @@ -35,25 +35,25 @@ create table incidences ( id int auto_increment primary key, name varchar(255), photo varchar(255), - element_id int, + element_id int, description varchar(255), - incident_date timestamp, + incident_date timestamp, foreign key (element_id) references elements(id) ); create table roles ( id int auto_increment primary key, - role_name varchar(255) + name varchar(255) unique ); create table workers ( id int auto_increment primary key, company varchar(255), name varchar(255), - dni varchar(255) unique, + dni varchar(255) unique, password varchar(255), - email varchar(255), - role_id int, + email varchar(255), + role_id int, created_at timestamp, deleted_at timestamp, updated_at timestamp, @@ -84,23 +84,23 @@ create table parts ( create table routes ( id int auto_increment primary key, - distance float, - point_id int, - travel_time int, + distance float, + point_id int, + travel_time int, foreign key (point_id) references points(id) ); create table tasks ( id int auto_increment primary key, - task_name varchar(255), - work_order_id int, + task_name varchar(255), + work_order_id int, description varchar(255), - inventory_id int, - machine_id int, - route_id int, + inventory_id int, + machine_id int, + route_id int, status BIT, - part_id int, - history_id int, + part_id int, + history_id int, created_at timestamp, deleted_at timestamp, foreign key (work_order_id) references work_orders(id), diff --git a/docker/database/start-scripts/1-seed.sql b/docker/database/start-scripts/1-seed.sql index de9da5fb..380bf275 100644 --- a/docker/database/start-scripts/1-seed.sql +++ b/docker/database/start-scripts/1-seed.sql @@ -1,5 +1,5 @@ -- Insert sample roles (Admin, Manager, Worker) -INSERT INTO roles (role_name) VALUES +INSERT INTO roles (name) VALUES ('Administrador'), ('Gerente'), ('Trabajador'); @@ -8,4 +8,4 @@ INSERT INTO roles (role_name) VALUES INSERT INTO workers (company, name, dni, password, email, role_id, created_at, updated_at, deleted_at) VALUES ('TechCorp', 'Carlos García', '12345678A', 'hashedpassword1', 'carlos.garcia@example.com', 1, NOW(), NOW(), NULL), -- Admin ('InnovaTech', 'Ana Martínez', '23456789B', 'hashedpassword2', 'ana.martinez@example.com', 2, NOW(), NOW(), NULL), -- Manager -('DesignWorks', 'José Rodríguez', '34567890C', 'hashedpassword3', 'jose.rodriguez@example.com', 3, NOW(), NOW(), NULL); -- Worker \ No newline at end of file +('DesignWorks', 'José Rodríguez', '34567890C', 'hashedpassword3', 'jose.rodriguez@example.com', 3, NOW(), NOW(), NULL); -- Worker diff --git a/src/app/Controllers/HomeController.php b/src/app/Controllers/HomeController.php index 7537c181..3d966e7d 100755 --- a/src/app/Controllers/HomeController.php +++ b/src/app/Controllers/HomeController.php @@ -10,7 +10,7 @@ class HomeController implements BaseController { public function get() { - $workers = Worker::getAll(); + $workers = Worker::findAll(); View::render([ "view" => "Home", "title" => "Home Page", diff --git a/src/app/Core/BaseModel.php b/src/app/Core/BaseModel.php new file mode 100644 index 00000000..697037f7 --- /dev/null +++ b/src/app/Core/BaseModel.php @@ -0,0 +1,151 @@ +{$foreignKey}; + + $query = "SELECT * FROM $relatedTable WHERE $ownerKey = :foreignKeyValue LIMIT 1"; + $results = Database::prepareAndExecute($query, ['foreignKeyValue' => $foreignKeyValue]); + + return !empty($results) ? $relatedModel::mapDataToModel($results[0]) : null; + } + + public function delete() + { + $table = static::getTableName(); + + if (static::hasSoftDelete()) { + $query = "UPDATE $table SET deleted_at = NOW() WHERE id = :id"; + Database::prepareAndExecute($query, ['id' => $this->id]); + } else { + $query = "DELETE FROM $table WHERE id = :id"; + Database::prepareAndExecute($query, ['id' => $this->id]); + } + } + + public static function find($id) + { + $table = static::getTableName(); + $query = "SELECT * FROM $table WHERE id = :id LIMIT 1"; + $results = Database::prepareAndExecute($query, ['id' => $id]); + + if (!empty($results)) + return static::mapDataToModel($results[0]); + + return null; + } + + public static function findAll($conditions = []) + { + $table = static::getTableName(); + $query = "SELECT * FROM $table"; + $params = []; + + if (!empty($conditions)) { + $clauses = []; + foreach ($conditions as $key => $value) { + $clauses[] = "$key = :$key"; + $params[$key] = $value; + } + $query .= " WHERE " . implode(" AND ", $clauses); + } + + $results = Database::prepareAndExecute($query, $params); + + return array_map(fn($row) => static::mapDataToModel($row), $results); + } + + // Fetch all soft deleted records + public static function findSoftDeleted() + { + if (!static::hasSoftDelete()) + return []; + + $table = static::getTableName(); + $query = "SELECT * FROM $table WHERE deleted_at IS NOT NULL"; + $results = Database::prepareAndExecute($query); + + return array_map(fn($row) => static::mapDataToModel($row), $results); + } + + // Dynamically relationship fetching + public function hasMany($relatedModel, $foreignKey, $localKey = 'id') + { + $relatedTable = $relatedModel::getTableName(); + $localKeyValue = $this->{$localKey}; + + $query = "SELECT * FROM $relatedTable WHERE $foreignKey = :localKeyValue"; + $results = Database::prepareAndExecute($query, ['localKeyValue' => $localKeyValue]); + + return array_map(fn($row) => $relatedModel::mapDataToModel($row), $results); + } + + // Dynamically check if a table has the deleted_at column + protected static function hasSoftDelete() + { + static $softDeleteCache = []; + $table = static::getTableName(); + + if (!isset($softDeleteCache[$table])) { + $query = "SHOW COLUMNS FROM $table LIKE 'deleted_at'"; + $result = Database::prepareAndExecute($query); + $softDeleteCache[$table] = !empty($result); // Cache the result + } + + return $softDeleteCache[$table]; + } + + public function restore() + { + if (static::hasSoftDelete()) { + $table = static::getTableName(); + $query = "UPDATE $table SET deleted_at = NULL WHERE id = :id"; + Database::prepareAndExecute($query, ['id' => $this->id]); + } + } + + public function save() + { + $table = static::getTableName(); + $properties = get_object_vars($this); + unset($properties['id']); // Avoid saving the id in the data fields + + if ($this->id) { + // Update logic + $fields = []; + foreach ($properties as $key => $value) { + $fields[] = "$key = :$key"; + } + $query = "UPDATE $table SET " . implode(", ", $fields) . " WHERE id = :id"; + $properties['id'] = $this->id; + } else { + // Insert logic + $fields = array_keys($properties); + $placeholders = array_map(fn($field) => ":$field", $fields); + $query = "INSERT INTO $table (" . implode(", ", $fields) . ") VALUES (" . implode(", ", $placeholders) . ")"; + } + + Database::prepareAndExecute($query, $properties); + + if (!$this->id) + $this->id = Database::connect()->lastInsertId(); + } + + //* Abstract methods to enforce subclass implementation + abstract protected static function getTableName(); + abstract protected static function mapDataToModel($data); + + //* Getters and Setters + public function getId() + { + return $this->id; + } +} diff --git a/src/app/Models/Role.php b/src/app/Models/Role.php new file mode 100644 index 00000000..b7ce3423 --- /dev/null +++ b/src/app/Models/Role.php @@ -0,0 +1,23 @@ +id = $data['id']; + $role->name = $data['name']; + return $role; + } +} diff --git a/src/app/Models/Worker.php b/src/app/Models/Worker.php index 3a1095f0..2f8846ec 100644 --- a/src/app/Models/Worker.php +++ b/src/app/Models/Worker.php @@ -2,189 +2,40 @@ namespace App\Models; +use App\Core\BaseModel; use App\Core\Database; -use PDO; -use PDOException; -class Worker +class Worker extends BaseModel { - private $id; - private $company; - private $name; - private $dni; - private $password; - private $email; - private $role_id; - private $created_at; - private $deleted_at; - private $updated_at; - // Constructor to initialize properties (optional) - public function __construct($data = []) - { - foreach ($data as $key => $value) { - $this->$key = $value; - } - } - - // Static method to retrieve all workers - public static function getAll() - { - $query = "SELECT * FROM workers"; - $results = Database::prepareAndExecute($query); - foreach ($results as $key => $value) { - $results[$key] = new self($value); - } - return $results; - } - - // Static method to find a worker by ID - public static function findById($id) - { - $query = "SELECT * FROM workers WHERE id = :id AND deleted_at IS NULL"; - $results = Database::prepareAndExecute($query, ['id' => $id]); - - return $results ? new self($results[0]) : null; - } - - // Static method to find a worker by DNI - public static function findByDni($dni) - { - $query = "SELECT * FROM workers WHERE dni = :dni AND deleted_at IS NULL"; - $results = Database::prepareAndExecute($query, ['dni' => $dni]); - - return $results ? new self($results[0]) : null; - } - - // Method to save a new worker - public function save() - { - $query = "INSERT INTO workers (company, name, dni, password, email, role_id, created_at, updated_at) - VALUES (:company, :name, :dni, :password, :email, :role_id, NOW(), NOW())"; - $params = [ - 'company' => $this->company, - 'name' => $this->name, - 'dni' => $this->dni, - 'password' => password_hash($this->password, PASSWORD_BCRYPT), // Hashing password - 'email' => $this->email, - 'role_id' => $this->role_id - ]; - - return Database::prepareAndExecute($query, $params); - } - - // Method to update an existing worker - public function update() - { - $query = "UPDATE workers SET company = :company, name = :name, dni = :dni, email = :email, - role_id = :role_id, updated_at = NOW() WHERE id = :id AND deleted_at IS NULL"; - $params = [ - 'id' => $this->id, - 'company' => $this->company, - 'name' => $this->name, - 'dni' => $this->dni, - 'email' => $this->email, - 'role_id' => $this->role_id - ]; - - return Database::prepareAndExecute($query, $params); - } - - // Method to delete a worker (soft delete by updating `deleted_at` timestamp) - public function delete() - { - $query = "UPDATE workers SET deleted_at = NOW() WHERE id = :id"; - return Database::prepareAndExecute($query, ['id' => $this->id]); - } - - // Getters and setters (you can add more as needed) - public function getId() - { - return $this->id; - } - - public function getCompany() - { - return $this->company; - } - - public function getName() - { - return $this->name; - } - - public function getDni() - { - return $this->dni; - } - - public function getPassword() - { - return $this->password; - } - - public function getEmail() - { - return $this->email; - } - - public function getRoleId() - { - return $this->role_id; - } - - public function setId($id) - { - $this->id = $id; - } - - public function setCompany($company) - { - $this->company = $company; - } - - public function setName($name) - { - $this->name = $name; - } - - public function setDni($dni) - { - $this->dni = $dni; - } - - public function setPassword($password) - { - $this->password = $password; - } - - public function setEmail($email) - { - $this->email = $email; - } - - public function setRoleId($role_id) - { - $this->role_id = $role_id; - } - - public function setUpdatedAt($updated_at) - { - $this->updated_at = $updated_at; - } + public string $company; + public string $name; + public string $dni; + public string $password; + public string $email; + public int $role_id; - public function getCreatedAt() + protected static function getTableName() { - return $this->created_at; + return 'workers'; } - public function getDeletedAt() + protected static function mapDataToModel($data) { - return $this->deleted_at; + $user = new Worker(); + $user->id = $data['id']; + $user->company = $data['company']; + $user->name = $data['name']; + $user->dni = $data['dni']; + $user->password = $data['password']; + $user->email = $data['email']; + $user->role_id = $data['role_id']; + return $user; } - public function getUpdatedAt() + // Fetch the user's role + public function role() { - return $this->updated_at; + return $this->belongsTo(Role::class, 'role_id', 'id'); } } diff --git a/src/app/Views/Home.php b/src/app/Views/Home.php index 67d4d2ab..1c5db326 100755 --- a/src/app/Views/Home.php +++ b/src/app/Views/Home.php @@ -7,20 +7,20 @@ Name DNI Email - Role ID + Role Name getId(); ?> - getCompany(); ?> - getName(); ?> - getDni(); ?> - getEmail(); ?> - getRoleId(); ?> + company; ?> + name; ?> + dni; ?> + email; ?> + role()->name; ?> - \ No newline at end of file + From 551c85a5435a84b5a1c3ca9173aa95c6b584945b Mon Sep 17 00:00:00 2001 From: 0x1026 <69076992+0x1026@users.noreply.github.com> Date: Sat, 16 Nov 2024 16:58:12 +0100 Subject: [PATCH 15/15] fix(tree-type): update changes --- src/app/Controllers/TreeTypeController.php | 11 +- src/app/Models/TreeType.php | 143 ++------------------- src/app/Views/TreeType.php | 6 +- 3 files changed, 25 insertions(+), 135 deletions(-) diff --git a/src/app/Controllers/TreeTypeController.php b/src/app/Controllers/TreeTypeController.php index 94b81ebf..d61bd359 100644 --- a/src/app/Controllers/TreeTypeController.php +++ b/src/app/Controllers/TreeTypeController.php @@ -2,14 +2,15 @@ namespace App\Controllers; +use App\Core\BaseController; use App\Core\View; use App\Models\TreeType; -class TreeTypeController +class TreeTypeController implements BaseController { - public function index() + public function get() { - $tree_types = TreeType::getAll(); + $tree_types = TreeType::findAll(); View::render([ "view" => "TreeType", "title" => "Tree Types", @@ -17,4 +18,8 @@ public function index() "data" => ["tree_types" => $tree_types] ]); } + + public function post() {} + public function put() {} + public function delete() {} } \ No newline at end of file diff --git a/src/app/Models/TreeType.php b/src/app/Models/TreeType.php index cf3e7ae2..e59f8f1f 100644 --- a/src/app/Models/TreeType.php +++ b/src/app/Models/TreeType.php @@ -2,141 +2,26 @@ Namespace App\Models; -use App\Core\Database; -use PDO; -use PDOException; +use App\Core\BaseModel; -class TreeType +class TreeType extends BaseModel { - private int $id; - private string $family; - private string $genus; - private string $species; + public string $family; + public string $genus; + public string $species; - // Constructor para inicializar propiedades - public function __construct($data = []) + protected static function getTableName(): string { - foreach ($data as $key => $value) { - $this->$key = $value; - } + return 'tree_types'; } - // Método estático para recuperar todos los tipos de árboles - public static function getAll() - { - $query = "SELECT * FROM tree_types"; - $results = Database::prepareAndExecute($query); - foreach ($results as $key => $value) { - $results[$key] = new self($value); - } - return $results; - } - - // Método estático para encontrar un tipo de árbol por ID - public static function findById($id) - { - $query = "SELECT * FROM tree_types WHERE id = :id"; - $results = Database::prepareAndExecute($query, ['id' => $id]); - - return $results ? new self($results[0]) : null; - } - - // Método estático para encontrar un tipo de árbol por familia - public static function findByFamily($family) - { - $query = "SELECT * FROM tree_types WHERE family = :family"; - $results = Database::prepareAndExecute($query, ['family' => $family]); - - return $results ? new self($results[0]) : null; - } - - - public static function findByGenus($genus) - { - $query = "SELECT * FROM tree_types WHERE genus = :genus"; - $results = Database::prepareAndExecute($query, ['genus' => $genus]); - - return $results ? new self($results[0]) : null; + protected static function mapDataToModel($data) { + $tree_type = new TreeType(); + $tree_type->id = $data['id']; + $tree_type->family = $data['family']; + $tree_type->genus = $data['genus']; + $tree_type->species = $data['species']; + return $tree_type; } - - public static function findBySpecies($species) - { - $query = "SELECT * FROM tree_types WHERE species = :species"; - $results = Database::prepareAndExecute($query, ['species' => $species]); - return $results ? new self($results[0]) : null; - } - - - // Método para guardar un nuevo tipo de árbol - public function save() - { - $query = "INSERT INTO tree_types (family, genus, species) - VALUES (:family, :genus, :species)"; - $params = [ - 'family' => $this->family, - 'genus' => $this->genus, - 'species' => $this->species - ]; - - return Database::prepareAndExecute($query, $params); - } - - public function update() - { - $query = "UPDATE tree_types SET family = :family, genus = :genus, species = :species - WHERE id = :id"; - $params = [ - 'id' => $this->id, - 'family' => $this->family, - 'genus' => $this->genus, - 'species' => $this->species, - ]; - - return Database::prepareAndExecute($query, $params); - } - - // Method to delete a tree type (hard delete) - public function delete() - { - $query = "DELETE FROM tree_types WHERE id = :id"; - return Database::prepareAndExecute($query, ['id' => $this->id]); - } - - - // Getters y setters - public function getId() - { - return $this->id; - } - - public function getFamily() - { - return $this->family; - } - - public function getGenus() - { - return $this->genus; - } - - public function getSpecies() - { - return $this->species; - } - - public function setFamily($family) - { - $this->family = $family; - } - - public function setGenus($genus) - { - $this->genus = $genus; - } - - public function setSpecies($species) - { - $this->species = $species; - } } diff --git a/src/app/Views/TreeType.php b/src/app/Views/TreeType.php index b577dd1a..a36bd3b3 100644 --- a/src/app/Views/TreeType.php +++ b/src/app/Views/TreeType.php @@ -12,9 +12,9 @@ getId(); ?> - getFamily(); ?> - getGenus(); ?> - getSpecies(); ?> + family; ?> + genus; ?> + species; ?>