Actualización

This commit is contained in:
Xes
2025-04-10 12:24:57 +02:00
parent 8969cc929d
commit 45420b6f0d
39760 changed files with 4303286 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
<?php
namespace Gedmo\SoftDeleteable\Mapping\Driver;
use Gedmo\Mapping\Driver\AbstractAnnotationDriver;
use Gedmo\Exception\InvalidMappingException;
use Gedmo\SoftDeleteable\Mapping\Validator;
/**
* This is an annotation mapping driver for SoftDeleteable
* behavioral extension. Used for extraction of extended
* metadata from Annotations specifically for SoftDeleteable
* extension.
*
* @author Gustavo Falco <comfortablynumb84@gmail.com>
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
class Annotation extends AbstractAnnotationDriver
{
/**
* Annotation to define that this object is loggable
*/
const SOFT_DELETEABLE = 'Gedmo\\Mapping\\Annotation\\SoftDeleteable';
/**
* {@inheritDoc}
*/
public function readExtendedMetadata($meta, array &$config)
{
$class = $this->getMetaReflectionClass($meta);
// class annotations
if ($class !== null && $annot = $this->reader->getClassAnnotation($class, self::SOFT_DELETEABLE)) {
$config['softDeleteable'] = true;
Validator::validateField($meta, $annot->fieldName);
$config['fieldName'] = $annot->fieldName;
$config['timeAware'] = false;
if (isset($annot->timeAware)) {
if (!is_bool($annot->timeAware)) {
throw new InvalidMappingException("timeAware must be boolean. ".gettype($annot->timeAware)." provided.");
}
$config['timeAware'] = $annot->timeAware;
}
$config['hardDelete'] = true;
if (isset($annot->hardDelete)) {
if (!is_bool($annot->hardDelete)) {
throw new InvalidMappingException("hardDelete must be boolean. ".gettype($annot->hardDelete)." provided.");
}
$config['hardDelete'] = $annot->hardDelete;
}
}
$this->validateFullMetadata($meta, $config);
}
}

View File

@@ -0,0 +1,59 @@
<?php
namespace Gedmo\SoftDeleteable\Mapping\Driver;
use Gedmo\Mapping\Driver\Xml as BaseXml;
use Gedmo\Exception\InvalidMappingException;
use Gedmo\SoftDeleteable\Mapping\Validator;
/**
* This is a xml mapping driver for SoftDeleteable
* behavioral extension. Used for extraction of extended
* metadata from xml specifically for SoftDeleteable
* extension.
*
* @author Gustavo Falco <comfortablynumb84@gmail.com>
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @author Miha Vrhovnik <miha.vrhovnik@gmail.com>
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
class Xml extends BaseXml
{
/**
* {@inheritDoc}
*/
public function readExtendedMetadata($meta, array &$config)
{
/**
* @var \SimpleXmlElement $xml
*/
$xml = $this->_getMapping($meta->name);
$xmlDoctrine = $xml;
$xml = $xml->children(self::GEDMO_NAMESPACE_URI);
if (in_array($xmlDoctrine->getName(), array('mapped-superclass', 'entity', 'document', 'embedded-document'))) {
if (isset($xml->{'soft-deleteable'})) {
$field = $this->_getAttribute($xml->{'soft-deleteable'}, 'field-name');
if (!$field) {
throw new InvalidMappingException('Field name for SoftDeleteable class is mandatory.');
}
Validator::validateField($meta, $field);
$config['softDeleteable'] = true;
$config['fieldName'] = $field;
$config['timeAware'] = false;
if ($this->_isAttributeSet($xml->{'soft-deleteable'}, 'time-aware')) {
$config['timeAware'] = $this->_getBooleanAttribute($xml->{'soft-deleteable'}, 'time-aware');
}
$config['hardDelete'] = true;
if ($this->_isAttributeSet($xml->{'soft-deleteable'}, 'hard-delete')) {
$config['hardDelete'] = $this->_getBooleanAttribute($xml->{'soft-deleteable'}, 'hard-delete');
}
}
}
}
}

View File

@@ -0,0 +1,76 @@
<?php
namespace Gedmo\SoftDeleteable\Mapping\Driver;
use Gedmo\Mapping\Driver\File;
use Gedmo\Mapping\Driver;
use Gedmo\Exception\InvalidMappingException;
use Gedmo\SoftDeleteable\Mapping\Validator;
/**
* This is a yaml mapping driver for Timestampable
* behavioral extension. Used for extraction of extended
* metadata from yaml specifically for Timestampable
* extension.
*
* @author Gustavo Falco <comfortablynumb84@gmail.com>
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
class Yaml extends File implements Driver
{
/**
* File extension
* @var string
*/
protected $_extension = '.dcm.yml';
/**
* {@inheritDoc}
*/
public function readExtendedMetadata($meta, array &$config)
{
$mapping = $this->_getMapping($meta->name);
if (isset($mapping['gedmo'])) {
$classMapping = $mapping['gedmo'];
if (isset($classMapping['soft_deleteable'])) {
$config['softDeleteable'] = true;
if (!isset($classMapping['soft_deleteable']['field_name'])) {
throw new InvalidMappingException('Field name for SoftDeleteable class is mandatory.');
}
$fieldName = $classMapping['soft_deleteable']['field_name'];
Validator::validateField($meta, $fieldName);
$config['fieldName'] = $fieldName;
$config['timeAware'] = false;
if (isset($classMapping['soft_deleteable']['time_aware'])) {
if (!is_bool($classMapping['soft_deleteable']['time_aware'])) {
throw new InvalidMappingException("timeAware must be boolean. ".gettype($classMapping['soft_deleteable']['time_aware'])." provided.");
}
$config['timeAware'] = $classMapping['soft_deleteable']['time_aware'];
}
$config['hardDelete'] = true;
if (isset($classMapping['soft_deleteable']['hard_delete'])) {
if (!is_bool($classMapping['soft_deleteable']['hard_delete'])) {
throw new InvalidMappingException("hardDelete must be boolean. ".gettype($classMapping['soft_deleteable']['hard_delete'])." provided.");
}
$config['hardDelete'] = $classMapping['soft_deleteable']['hard_delete'];
}
}
}
}
/**
* {@inheritDoc}
*/
protected function _loadMappingFile($file)
{
return \Symfony\Component\Yaml\Yaml::parse(file_get_contents($file));
}
}