pocketmine\permission\PermissibleBase::addAttachment PHP Метод

addAttachment() публичный Метод

TODO: tick scheduled attachments
public addAttachment ( pocketmine\plugin\Plugin $plugin, string $name = null, boolean $value = null ) : PermissionAttachment
$plugin pocketmine\plugin\Plugin
$name string
$value boolean
Результат PermissionAttachment
    public function addAttachment(Plugin $plugin, $name = null, $value = null)
    {
        if ($plugin === null) {
            throw new PluginException("Plugin cannot be null");
        } elseif (!$plugin->isEnabled()) {
            throw new PluginException("Plugin " . $plugin->getDescription()->getName() . " is disabled");
        }
        $result = new PermissionAttachment($plugin, $this->parent !== null ? $this->parent : $this);
        $this->attachments[spl_object_hash($result)] = $result;
        if ($name !== null and $value !== null) {
            $result->setPermission($name, $value);
        }
        $this->recalculatePermissions();
        return $result;
    }

Usage Example

Пример #1
0
 /**
  * @param Plugin $plugin
  * @param string $name
  * @param bool   $value
  *
  * @return permission\PermissionAttachment
  */
 public function addAttachment(Plugin $plugin, $name = null, $value = null)
 {
     return $this->perm->addAttachment($plugin, $name, $value);
 }