$names */ public function compileNames(array $names) { $this->makeCompileDir(); \file_put_contents( self::getNamesLockFile(), json_encode($names) ); } /** * @return array List of the versioned resource names * * @see compileNames() */ public static function getNames(): array { return json_decode(\file_get_contents(self::getNamesLockFile()), true); } public static function getEntityFromResource(string $resourceShortName): string { $names = self::getNames(); if (\array_key_exists($resourceShortName, $names)) { return $names[$resourceShortName]; } throw new \Exception(\sprintf( "The resource shortName '%s' does not match to a known versioned resource", $resourceShortName )); } public static function getResourceFromEntity(string $entityClass): string { foreach (self::getNames() as $shortName => $entityFqcl) { if ($entityFqcl === $entityClass) { return $shortName; } } throw new \Exception(\sprintf( "The entity class name '%s' does not match to a known versioned resource", $entityClass )); } }