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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
"Hypervel\\Translation\\": "src/translation/src/",
"Hypervel\\Validation\\": "src/validation/src/",
"Hypervel\\Permission\\": "src/permission/src/",
"Hypervel\\Sentry\\": "src/sentry/src/"
"Hypervel\\Sentry\\": "src/sentry/src/",
"Hypervel\\View\\": "src/view/src/"
},
"files": [
"src/auth/src/Functions.php",
Expand Down Expand Up @@ -181,7 +182,8 @@
"hypervel/translation": "self.version",
"hypervel/validation": "self.version",
"hypervel/permission": "self.version",
"hypervel/sentry": "self.version"
"hypervel/sentry": "self.version",
"hypervel/view": "self.version"
},
"suggest": {
"hyperf/redis": "Required to use redis driver. (^3.1).",
Expand All @@ -203,7 +205,6 @@
"hyperf/devtool": "~3.1.0",
"hyperf/redis": "~3.1.0",
"hyperf/testing": "~3.1.0",
"hyperf/view-engine": "~3.1.0",
"league/flysystem": "^3.0",
"league/flysystem-aws-s3-v3": "^3.0",
"league/flysystem-google-cloud-storage": "^3.0",
Expand Down Expand Up @@ -259,7 +260,8 @@
"providers": [
"Hypervel\\Notifications\\NotificationServiceProvider",
"Hypervel\\Telescope\\TelescopeServiceProvider",
"Hypervel\\Sentry\\SentryServiceProvider"
"Hypervel\\Sentry\\SentryServiceProvider",
"Hypervel\\View\\ViewServiceProvider"
]
},
"branch-alias": {
Expand Down
10 changes: 8 additions & 2 deletions src/devtool/src/Generator/ComponentCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Hypervel\Devtool\Generator;

use Hyperf\Devtool\Generator\GeneratorCommand;
use Hypervel\Support\Str;

class ComponentCommand extends GeneratorCommand
{
Expand All @@ -27,7 +28,7 @@ protected function getStub(): string

protected function getDefaultNamespace(): string
{
return $this->getConfig()['namespace'] ?? 'App\View\Component';
return $this->getConfig()['namespace'] ?? 'App\View\Components';
}

protected function buildClass(string $name): string
Expand All @@ -37,7 +38,12 @@ protected function buildClass(string $name): string

protected function replaceView(string $stub, string $name): string
{
$view = lcfirst(str_replace($this->getNamespace($name) . '\\', '', $name));
$view = str_replace($this->getDefaultNamespace($name) . '\\', '', $name);
$view = array_map(
fn ($part) => Str::snake($part),
explode('\\', $view)
);
$view = implode('.', $view);

return str_replace(
['%VIEW%'],
Expand Down
6 changes: 3 additions & 3 deletions src/devtool/src/Generator/stubs/view-component.stub
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ declare(strict_types=1);
namespace %NAMESPACE%;

use Closure;
use Hyperf\ViewEngine\Component\Component;
use Hyperf\ViewEngine\Contract\ViewInterface;
use Hypervel\View\Component;
use Hypervel\View\Contracts\View as ViewContract;
use Hypervel\Support\Facades\View;

class %CLASS% extends Component
Expand All @@ -22,7 +22,7 @@ class %CLASS% extends Component
/**
* Get the view / contents that represent the component.
*/
public function render(): ViewInterface|Closure|string
public function render(): ViewContract|Closure|string
{
return %VIEW%;
}
Expand Down
22 changes: 22 additions & 0 deletions src/filesystem/src/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Hypervel\Filesystem;

use Hyperf\Support\Filesystem\Filesystem as HyperfFilesystem;
use Hypervel\Http\Exceptions\FileNotFoundException;

class Filesystem extends HyperfFilesystem
{
Expand All @@ -17,4 +18,25 @@ public function ensureDirectoryExists(string $path, int $mode = 0755, bool $recu
$this->makeDirectory($path, $mode, $recursive);
}
}

/**
* Get the returned value of a file.
*
* @throws FileNotFoundException
*/
public function getRequire(string $path, array $data = [[]])
{
if ($this->isFile($path)) {
$__path = $path;
$__data = $data;

return (static function () use ($__path, $__data) {
extract($__data, EXTR_SKIP);

return require $__path;
})();
}

throw new FileNotFoundException("File does not exist at path {$path}.");
}
}
8 changes: 4 additions & 4 deletions src/foundation/src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
use Hyperf\Contract\Arrayable;
use Hyperf\HttpMessage\Cookie\Cookie;
use Hyperf\Stringable\Stringable;
use Hyperf\ViewEngine\Contract\FactoryInterface;
use Hyperf\ViewEngine\Contract\ViewInterface;
use Hypervel\Auth\Contracts\Factory as AuthFactoryContract;
use Hypervel\Auth\Contracts\Gate;
use Hypervel\Auth\Contracts\Guard;
Expand All @@ -33,6 +31,8 @@
use Hypervel\Translation\Contracts\Translator as TranslatorContract;
use Hypervel\Validation\Contracts\Factory as ValidatorFactoryContract;
use Hypervel\Validation\Contracts\Validator as ValidatorContract;
use Hypervel\View\Contracts\Factory as FactoryContract;
use Hypervel\View\Contracts\View as ViewContract;
use Psr\Http\Message\ResponseInterface;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -734,9 +734,9 @@ function __(?string $key = null, array $replace = [], ?string $locale = null): a
* @param null|string $view
* @param array $mergeData
*/
function view($view = null, array|Arrayable $data = [], $mergeData = []): FactoryInterface|ViewInterface
function view($view = null, array|Arrayable $data = [], $mergeData = []): FactoryContract|ViewContract
{
$factory = app(FactoryInterface::class);
$factory = app(FactoryContract::class);

if (func_num_args() === 0) {
return $factory;
Expand Down
7 changes: 7 additions & 0 deletions src/http/src/CoreMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Hyperf\HttpServer\Router\DispatcherFactory;
use Hyperf\Server\Exception\ServerException;
use Hyperf\View\RenderInterface;
use Hyperf\ViewEngine\Contract\Htmlable;
use Hyperf\ViewEngine\Contract\Renderable;
use Hyperf\ViewEngine\Contract\ViewInterface;
use Hypervel\Context\ResponseContext;
Expand Down Expand Up @@ -65,6 +66,12 @@ protected function transferToResponse($response, ServerRequestInterface $request
->setBody(new SwooleStream($response->render()));
}

if ($response instanceof Htmlable) {
return $this->response()
->addHeader('content-type', 'text/html')
->setBody(new SwooleStream((string) $response));
}

if (is_string($response)) {
return $this->response()->addHeader('content-type', 'text/plain')->setBody(new SwooleStream($response));
}
Expand Down
4 changes: 2 additions & 2 deletions src/session/src/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
use Hyperf\Context\Context;
use Hyperf\Macroable\Macroable;
use Hyperf\Stringable\Str;
use Hyperf\Support\MessageBag;
use Hyperf\ViewEngine\ViewErrorBag;
use Hypervel\Session\Contracts\Session;
use Hypervel\Support\MessageBag;
use Hypervel\Support\ViewErrorBag;
use SessionHandlerInterface;
use stdClass;

Expand Down
21 changes: 14 additions & 7 deletions src/support/src/Facades/Blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,36 @@

namespace Hypervel\Support\Facades;

use Hyperf\ViewEngine\Compiler\CompilerInterface;

/**
* @method static void compile(string|null $path = null)
* @method static string getPath()
* @method static void setPath(string $path)
* @method static string compileString(string $value)
* @method static string render(string $string, array $data = [], bool $deleteCachedView = false)
* @method static string renderComponent(\Hypervel\View\Component $component)
* @method static string stripParentheses(string $expression)
* @method static void extend(callable $compiler)
* @method static array getExtensions()
* @method static void if(string $name, callable $callback)
* @method static bool check(string $name, array ...$parameters)
* @method static bool check(string $name, mixed ...$parameters)
* @method static void component(string $class, string|null $alias = null, string $prefix = '')
* @method static void components(array $components, string $prefix = '')
* @method static array getClassComponentAliases()
* @method static void anonymousComponentPath(string $path, string|null $prefix = null)
* @method static void anonymousComponentNamespace(string $directory, string|null $prefix = null)
* @method static void componentNamespace(string $namespace, string $prefix)
* @method static array getAnonymousComponentPaths()
* @method static array getAnonymousComponentNamespaces()
* @method static array getClassComponentNamespaces()
* @method static array getComponentAutoload()
* @method static void setComponentAutoload(array $config)
* @method static void aliasComponent(string $path, string|null $alias = null)
* @method static void include(string $path, string|null $alias = null)
* @method static void aliasInclude(string $path, string|null $alias = null)
* @method static void directive(string $name, callable $handler)
* @method static void bindDirective(string $name, callable $handler)
* @method static void directive(string $name, callable $handler, bool $bind = false)
* @method static array getCustomDirectives()
* @method static \Hypervel\View\Compilers\BladeCompiler prepareStringsForCompilationUsing(callable $callback)
* @method static void precompiler(callable $precompiler)
* @method static string usingEchoFormat(string $format, callable $callback)
* @method static void setEchoFormat(string $format)
* @method static void withDoubleEncoding()
* @method static void withoutDoubleEncoding()
Expand All @@ -40,14 +45,16 @@
* @method static string compileEndComponentClass()
* @method static mixed sanitizeComponentAttribute(mixed $value)
* @method static string compileEndOnce()
* @method static void stringable(string|callable $class, callable|null $handler = null)
* @method static string compileEchos(string $value)
* @method static string applyEchoHandler(string $value)
*
* @see \Hypervel\View\Compilers\BladeCompiler
*/
class Blade extends Facade
{
protected static function getFacadeAccessor()
{
return CompilerInterface::class;
return 'blade.compiler';
}
}
68 changes: 38 additions & 30 deletions src/support/src/Facades/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,70 +4,78 @@

namespace Hypervel\Support\Facades;

use Hyperf\ViewEngine\Contract\FactoryInterface;
use Hypervel\View\Contracts\Factory as FactoryContract;

/**
* @method static \Hyperf\ViewEngine\Contract\ViewInterface file(string $path, array|\Hyperf\Contract\Arrayable $data = [], array $mergeData = [])
* @method static \Hyperf\ViewEngine\Contract\ViewInterface make(string $view, array|\Hyperf\Contract\Arrayable $data = [], array $mergeData = [])
* @method static \Hyperf\ViewEngine\Contract\ViewInterface first(array $views, \Hyperf\Contract\Arrayable|array $data = [], array $mergeData = [])
* @method static string renderWhen(bool $condition, string $view, \Hyperf\Contract\Arrayable|array $data = [], array $mergeData = [])
* @method static string renderUnless(bool $condition, string $view, \Hyperf\Contract\Arrayable|array $data = [], array $mergeData = [])
* @method static \Hypervel\View\Contracts\View file(string $path, \Hypervel\Support\Contracts\Arrayable|array $data = [], array $mergeData = [])
* @method static \Hypervel\View\Contracts\View make(string $view, \Hypervel\Support\Contracts\Arrayable|array $data = [], array $mergeData = [])
* @method static \Hypervel\View\Contracts\View first(array $views, \Hypervel\Support\Contracts\Arrayable|array $data = [], array $mergeData = [])
* @method static string renderWhen(bool $condition, string $view, \Hypervel\Support\Contracts\Arrayable|array $data = [], array $mergeData = [])
* @method static string renderUnless(bool $condition, string $view, \Hypervel\Support\Contracts\Arrayable|array $data = [], array $mergeData = [])
* @method static string renderEach(string $view, array $data, string $iterator, string $empty = 'raw|')
* @method static bool exists(string $view)
* @method static \Hyperf\ViewEngine\Contract\EngineInterface getEngineFromPath(string $path)
* @method static mixed share(array|string $key, null|mixed $value = null)
* @method static \Hypervel\View\Contracts\Engine getEngineFromPath(string $path)
* @method static mixed share(array|string $key, mixed|null $value = null)
* @method static void incrementRender()
* @method static void decrementRender()
* @method static bool doneRendering()
* @method static bool hasRenderedOnce(string $id)
* @method static void markAsRenderedOnce(string $id)
* @method static void addLocation(string $location)
* @method static \Hyperf\ViewEngine\Factory addNamespace(string $namespace, array|string $hints)
* @method static \Hyperf\ViewEngine\Factory prependNamespace(string $namespace, array|string $hints)
* @method static \Hyperf\ViewEngine\Factory replaceNamespace(string $namespace, array|string $hints)
* @method static void prependLocation(string $location)
* @method static \Hypervel\View\Factory addNamespace(string $namespace, string|array $hints)
* @method static \Hypervel\View\Factory prependNamespace(string $namespace, string|array $hints)
* @method static \Hypervel\View\Factory replaceNamespace(string $namespace, string|array $hints)
* @method static void addExtension(string $extension, string $engine, \Closure|null $resolver = null)
* @method static void flushState()
* @method static void flushStateIfDoneRendering()
* @method static array getExtensions()
* @method static \Hyperf\ViewEngine\Contract\EngineResolverInterface getEngineResolver()
* @method static \Hyperf\ViewEngine\Contract\FinderInterface getFinder()
* @method static void setFinder(\Hyperf\ViewEngine\Contract\FinderInterface $finder)
* @method static \Hypervel\View\Engines\EngineResolver getEngineResolver()
* @method static \Hypervel\View\ViewFinderInterface getFinder()
* @method static void setFinder(\Hypervel\View\ViewFinderInterface $finder)
* @method static void flushFinderCache()
* @method static \Psr\EventDispatcher\EventDispatcherInterface getDispatcher()
* @method static void setDispatcher(\Psr\EventDispatcher\EventDispatcherInterface $events)
* @method static \Psr\Container\ContainerInterface getContainer()
* @method static void setContainer(\Psr\Container\ContainerInterface $container)
* @method static \Hypervel\Event\Contracts\Dispatcher getDispatcher()
* @method static void setDispatcher(\Hypervel\Event\Contracts\Dispatcher $events)
* @method static \Hypervel\Container\Contracts\Container getContainer()
* @method static void setContainer(\Hypervel\Container\Contracts\Container $container)
* @method static mixed shared(string $key, mixed $default = null)
* @method static array getShared()
* @method static void macro(string $name, callable|object $macro)
* @method static void macro(string $name, object|callable $macro)
* @method static void mixin(object $mixin, bool $replace = true)
* @method static bool hasMacro(string $name)
* @method static void startComponent(\Closure|\Hyperf\ViewEngine\Contract\Htmlable|string|\Hyperf\ViewEngine\View $view, array $data = [])
* @method static void flushMacros()
* @method static void startComponent(\Hypervel\View\Contracts\View|\Hypervel\Support\Contracts\Htmlable|\Closure|string $view, array $data = [])
* @method static void startComponentFirst(array $names, array $data = [])
* @method static string renderComponent()
* @method static void slot(string $name, null|string $content = null)
* @method static mixed|null getConsumableComponentData(string $key, mixed $default = null)
* @method static void slot(string $name, string|null $content = null, array $attributes = [])
* @method static void endSlot()
* @method static array creator(array|string $views, \Closure|string $callback)
* @method static array composers(array $composers)
* @method static array composer(array|string $views, \Closure|string $callback)
* @method static void callComposer(\Hyperf\ViewEngine\Contract\ViewInterface $view)
* @method static void callCreator(\Hyperf\ViewEngine\Contract\ViewInterface $view)
* @method static void startSection(string $section, null|string|\Hyperf\ViewEngine\Contract\ViewInterface $content = null)
* @method static void callComposer(\Hypervel\View\Contracts\View $view)
* @method static void callCreator(\Hypervel\View\Contracts\View $view)
* @method static void startFragment(string $fragment)
* @method static string stopFragment()
* @method static mixed getFragment(string $name, string|null $default = null)
* @method static array getFragments()
* @method static void flushFragments()
* @method static void startSection(string $section, string|null $content = null)
* @method static void inject(string $section, string $content)
* @method static string yieldSection()
* @method static string stopSection(bool $overwrite = false)
* @method static string appendSection()
* @method static string yieldContent(string $section, \Hyperf\ViewEngine\Contract\ViewInterface|string $default = '')
* @method static string yieldContent(string $section, string $default = '')
* @method static string parentPlaceholder(string $section = '')
* @method static bool hasSection(string $name)
* @method static bool sectionMissing(string $name)
* @method static mixed getSection(string $name, null|string $default = null)
* @method static mixed getSection(string $name, string|null $default = null)
* @method static array getSections()
* @method static void flushSections()
* @method static void addLoop(null|array|\Countable $data)
* @method static void addLoop(\Countable|array $data)
* @method static void incrementLoopIndices()
* @method static void popLoop()
* @method static null|\stdClass|void getLastLoop()
* @method static \stdClass|null getLastLoop()
* @method static array getLoopStack()
* @method static void startPush(string $section, string $content = '')
* @method static string stopPush()
Expand All @@ -78,12 +86,12 @@
* @method static void startTranslation(array $replacements = [])
* @method static string renderTranslation()
*
* @see \Hyperf\ViewEngine\Factory
* @see \Hypervel\View\Factory
*/
class View extends Facade
{
protected static function getFacadeAccessor()
{
return FactoryInterface::class;
return FactoryContract::class;
}
}
3 changes: 2 additions & 1 deletion src/support/src/MessageBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
namespace Hypervel\Support;

use Hyperf\Support\MessageBag as HyperfMessageBag;
use Hypervel\Support\Contracts\MessageBag as ContractsMessageBag;

class MessageBag extends HyperfMessageBag
class MessageBag extends HyperfMessageBag implements ContractsMessageBag
{
}
Loading
Loading