/** @var UserInterface $user */
/** @var RoleHierarchyInterface $hierarchy */
$roles = $hierarchy->getReachableRoleNames($user->getRoles());
$result = array_search('ROLE_GROUP_MANAGER', $roles) !== false;
const AWS = require('aws-sdk');
require('dotenv').config(); // для получения переменных из окружения Node.js
class YandexCloud {
constructor () {
this.aws = new AWS.S3({
endpoint: 'https://storage.yandexcloud.net',
accessKeyId: process.env.YA_STORAGE_ACCESS_KEY, // берем ключ из переменной окружения
secretAccessKey: process.env.YA_STORAGE_SECRET_KEY, // берем секрет из переменной окружения
region: 'ru-central1',
httpOptions: {
timeout: 10000,
connectTimeout: 10000
},
});
}
upload = async ({file,path,fileName}) => {
try {
const params = {
Bucket: 'название', // название созданного bucket
Key: `${path}/${fileName}`, // путь и название файла в облаке (path без слэша впереди)
Body: file, // сам файл
ContentType: 'text/plain', // тип файла
}
const result = await new Promise(function(resolve, reject) {
this.aws.upload(params, function(err, data) {
if (err) return reject(err);
return resolve(data);
});
});
return result;
} catch (e) {
console.error(e);
}
}
}
const YaCloud = new YandexCloud();
YaCloud.upload({
file: '', // файл
path: 'путь/в/облаке',
fileName: 'файл.txt',
})
watchers: {
webpack: {
aggregateTimeout: 300,
poll: 1000
}
}
В случае с AMI, если я это буду делать в PHP мой скрипт захлебнётся от потока информации
Action: Login
ActionID: 1
Username: ВАШ_ЛОГИН
Secret: ВАШ_ПАРОЛЬ
Events: off
Action: Command
Command: core show hints
240@ext-local : SIP/240,CustomPresen State:Idle Watchers 0
241@ext-local : SIP/241,CustomPresen State:InUse Watchers 0
242@ext-local : SIP/242,CustomPresen State:Unavailable Watchers 0
upstream asterisk {
server 127.0.0.1:8088;
}
server {
...
location /ws {
proxy_buffers 8 32k;
proxy_buffer_size 64k;
proxy_pass http://asterisk/ws;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 999999999;
}
}
interface ExecutorInterface
{
public function exec(): string;
}
class ConcreteImplementationA implements ExecutorInterface
{
public function exec(): string
{
return 'A';
}
}
class ConcreteImplementationB implements ExecutorInterface
{
public function exec(): string
{
return 'B';
}
}
class VariantExecutor
{
public function __construct(private ServiceLocator $locator)
{
}
public function exec(string $variant): string
{
return $this->locator->get($variant)->exec();
}
}
class Controller
{
public function call(VariantExecutor $executor, string $variant): Response
{
return new Response($executor->exec($variant));
}
}
#services.yaml
app.executor.locator:
class: Symfony\Component\DependencyInjection\ServiceLocator
arguments:
-
a: App\ConcreteImplementationA
b: App\ConcreteImplementationB
tags:
- { name: container.service_locator }