-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBase.php
41 lines (33 loc) · 1.04 KB
/
Base.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
* Copyright (c) 2017. Alexandr Kosarev, @kosarev.by
*/
/**
* Created by PhpStorm.
* User: Alexandr
* Date: 26.12.2017
* Time: 16:06
*/
namespace Joomplace\X\Helper\ACL;
trait Base
{
protected $context = null;
public function getParentAssetName(){
if(!$this->context){
list($vendor, $ext, $name) = explode('\\',self::class);
$this->context = implode('.',[strtolower(substr($ext,0,3).'_'.$name)]);
}
return $this->context;
}
public static function getAssetName($context = null, $pattern = false){
if(!is_subclass_of($context, Model::class,false)){
$context = new static();
if(!$pattern){
return $context->getParentAssetName();
}
}
return implode('.',[$context->getParentAssetName(),$context->getTable(),$pattern?'%':$context->getKey()]);
}
public abstract static function can($action, $context = null, \Joomla\CMS\User\User $user = null);
public abstract function scopeAccessible($query);
}