mirror of
https://github.com/archtechx/livewire-access.git
synced 2025-12-12 12:24:03 +00:00
implicit access
This commit is contained in:
parent
a5e58a14d8
commit
8df06ae2c3
9 changed files with 184 additions and 22 deletions
12
src/BlockFrontendAccess.php
Normal file
12
src/BlockFrontendAccess.php
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Lean\LivewireAccess;
|
||||
|
||||
use Attribute;
|
||||
|
||||
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_METHOD)]
|
||||
class BlockFrontendAccess
|
||||
{
|
||||
}
|
||||
23
src/WithImplicitAccess.php
Normal file
23
src/WithImplicitAccess.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Lean\LivewireAccess;
|
||||
|
||||
use ReflectionMethod;
|
||||
use ReflectionProperty;
|
||||
|
||||
trait WithImplicitAccess
|
||||
{
|
||||
protected function methodIsPublicAndNotDefinedOnBaseClass($methodName)
|
||||
{
|
||||
return parent::methodIsPublicAndNotDefinedOnBaseClass($methodName)
|
||||
&& count((new ReflectionMethod($this, $methodName))->getAttributes(BlockFrontendAccess::class)) === 0;
|
||||
}
|
||||
|
||||
public function propertyIsPublicAndNotDefinedOnBaseClass($propertyName)
|
||||
{
|
||||
return parent::propertyIsPublicAndNotDefinedOnBaseClass($propertyName)
|
||||
&& count((new ReflectionProperty($this, $propertyName))->getAttributes(BlockFrontendAccess::class)) === 0;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue