Primer commit del sistema separado falta mejorar mucho

This commit is contained in:
nickpons666
2025-12-30 01:18:46 -06:00
commit 1679c73e52
2384 changed files with 472342 additions and 0 deletions

7
vendor/evenement/evenement/.gitattributes vendored Executable file
View File

@@ -0,0 +1,7 @@
/.github export-ignore
/doc export-ignore
/examples export-ignore
/tests export-ignore
/.gitignore export-ignore
/CHANGELOG.md export-ignore
/phpunit.xml.dist export-ignore

19
vendor/evenement/evenement/LICENSE vendored Executable file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2011 Igor Wiedler
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

64
vendor/evenement/evenement/README.md vendored Executable file
View File

@@ -0,0 +1,64 @@
# Événement
Événement is a very simple event dispatching library for PHP.
It has the same design goals as [Silex](https://silex.symfony.com/) and
[Pimple](https://github.com/silexphp/Pimple), to empower the user while staying concise
and simple.
It is very strongly inspired by the [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter) API found in
[node.js](http://nodejs.org).
![Continuous Integration](https://github.com/igorw/evenement/workflows/CI/badge.svg)
[![Latest Stable Version](https://poser.pugx.org/evenement/evenement/v/stable.png)](https://packagist.org/packages/evenement/evenement)
[![Total Downloads](https://poser.pugx.org/evenement/evenement/downloads.png)](https://packagist.org/packages/evenement/evenement/stats)
[![License](https://poser.pugx.org/evenement/evenement/license.png)](https://packagist.org/packages/evenement/evenement)
## Fetch
The recommended way to install Événement is [through composer](http://getcomposer.org). By running the following command:
$ composer require evenement/evenement
## Usage
### Creating an Emitter
```php
<?php
$emitter = new Evenement\EventEmitter();
```
### Adding Listeners
```php
<?php
$emitter->on('user.created', function (User $user) use ($logger) {
$logger->log(sprintf("User '%s' was created.", $user->getLogin()));
});
```
### Removing Listeners
```php
<?php
$emitter->removeListener('user.created', function (User $user) use ($logger) {
$logger->log(sprintf("User '%s' was created.", $user->getLogin()));
});
```
### Emitting Events
```php
<?php
$emitter->emit('user.created', [$user]);
```
Tests
-----
$ ./vendor/bin/phpunit
License
-------
MIT, see LICENSE.

29
vendor/evenement/evenement/composer.json vendored Executable file
View File

@@ -0,0 +1,29 @@
{
"name": "evenement/evenement",
"description": "Événement is a very simple event dispatching library for PHP",
"keywords": ["event-dispatcher", "event-emitter"],
"license": "MIT",
"authors": [
{
"name": "Igor Wiedler",
"email": "igor@wiedler.ch"
}
],
"require": {
"php": ">=7.0"
},
"require-dev": {
"phpunit/phpunit": "^9 || ^6"
},
"autoload": {
"psr-4": {
"Evenement\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Evenement\\Tests\\": "tests/"
},
"files": ["tests/functions.php"]
}
}

View File

@@ -0,0 +1,17 @@
<?php declare(strict_types=1);
/*
* This file is part of Evenement.
*
* (c) Igor Wiedler <igor@wiedler.ch>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Evenement;
class EventEmitter implements EventEmitterInterface
{
use EventEmitterTrait;
}

View File

@@ -0,0 +1,22 @@
<?php declare(strict_types=1);
/*
* This file is part of Evenement.
*
* (c) Igor Wiedler <igor@wiedler.ch>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Evenement;
interface EventEmitterInterface
{
public function on($event, callable $listener);
public function once($event, callable $listener);
public function removeListener($event, callable $listener);
public function removeAllListeners($event = null);
public function listeners($event = null);
public function emit($event, array $arguments = []);
}

View File

@@ -0,0 +1,154 @@
<?php declare(strict_types=1);
/*
* This file is part of Evenement.
*
* (c) Igor Wiedler <igor@wiedler.ch>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Evenement;
use InvalidArgumentException;
use function count;
use function array_keys;
use function array_merge;
use function array_search;
use function array_unique;
use function array_values;
trait EventEmitterTrait
{
protected $listeners = [];
protected $onceListeners = [];
public function on($event, callable $listener)
{
if ($event === null) {
throw new InvalidArgumentException('event name must not be null');
}
if (!isset($this->listeners[$event])) {
$this->listeners[$event] = [];
}
$this->listeners[$event][] = $listener;
return $this;
}
public function once($event, callable $listener)
{
if ($event === null) {
throw new InvalidArgumentException('event name must not be null');
}
if (!isset($this->onceListeners[$event])) {
$this->onceListeners[$event] = [];
}
$this->onceListeners[$event][] = $listener;
return $this;
}
public function removeListener($event, callable $listener)
{
if ($event === null) {
throw new InvalidArgumentException('event name must not be null');
}
if (isset($this->listeners[$event])) {
$index = array_search($listener, $this->listeners[$event], true);
if (false !== $index) {
unset($this->listeners[$event][$index]);
if (count($this->listeners[$event]) === 0) {
unset($this->listeners[$event]);
}
}
}
if (isset($this->onceListeners[$event])) {
$index = array_search($listener, $this->onceListeners[$event], true);
if (false !== $index) {
unset($this->onceListeners[$event][$index]);
if (count($this->onceListeners[$event]) === 0) {
unset($this->onceListeners[$event]);
}
}
}
}
public function removeAllListeners($event = null)
{
if ($event !== null) {
unset($this->listeners[$event]);
} else {
$this->listeners = [];
}
if ($event !== null) {
unset($this->onceListeners[$event]);
} else {
$this->onceListeners = [];
}
}
public function listeners($event = null): array
{
if ($event === null) {
$events = [];
$eventNames = array_unique(
array_merge(
array_keys($this->listeners),
array_keys($this->onceListeners)
)
);
foreach ($eventNames as $eventName) {
$events[$eventName] = array_merge(
isset($this->listeners[$eventName]) ? $this->listeners[$eventName] : [],
isset($this->onceListeners[$eventName]) ? $this->onceListeners[$eventName] : []
);
}
return $events;
}
return array_merge(
isset($this->listeners[$event]) ? $this->listeners[$event] : [],
isset($this->onceListeners[$event]) ? $this->onceListeners[$event] : []
);
}
public function emit($event, array $arguments = [])
{
if ($event === null) {
throw new InvalidArgumentException('event name must not be null');
}
$listeners = [];
if (isset($this->listeners[$event])) {
$listeners = array_values($this->listeners[$event]);
}
$onceListeners = [];
if (isset($this->onceListeners[$event])) {
$onceListeners = array_values($this->onceListeners[$event]);
}
if(empty($listeners) === false) {
foreach ($listeners as $listener) {
$listener(...$arguments);
}
}
if(empty($onceListeners) === false) {
unset($this->onceListeners[$event]);
foreach ($onceListeners as $listener) {
$listener(...$arguments);
}
}
}
}