!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache. PHP/7.3.33 

uname -a: Linux acloudg.aryanict.com 4.18.0-513.9.1.lve.el8.x86_64 #1 SMP Mon Dec 4 15:01:22 UTC
2023 x86_64
 

uid=1095(katebhospital) gid=1098(katebhospital) groups=1098(katebhospital) 

Safe-mode: OFF (not secure)

/opt/alt/php54/usr/share/pear/Symfony/Bridge/Doctrine/Validator/Constraints/   drwxr-xr-x
Free 293.64 GB of 429.69 GB (68.34%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     UniqueEntityValidator.php (5.02 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Bridge\Doctrine\Validator\Constraints;

use 
Doctrine\Common\Persistence\ManagerRegistry;
use 
Symfony\Component\Validator\Constraint;
use 
Symfony\Component\Validator\Exception\UnexpectedTypeException;
use 
Symfony\Component\Validator\Exception\ConstraintDefinitionException;
use 
Symfony\Component\Validator\ConstraintValidator;

/**
 * Unique Entity Validator checks if one or a set of fields contain unique values.
 *
 * @author Benjamin Eberlei <kontakt@beberlei.de>
 */
class UniqueEntityValidator extends ConstraintValidator
{
    
/**
     * @var ManagerRegistry
     */
    
private $registry;

    
/**
     * @param ManagerRegistry $registry
     */
    
public function __construct(ManagerRegistry $registry)
    {
        
$this->registry $registry;
    }

    
/**
     * @param object     $entity
     * @param Constraint $constraint
     *
     * @throws UnexpectedTypeException
     * @throws ConstraintDefinitionException
     */
    
public function validate($entityConstraint $constraint)
    {
        if (!
is_array($constraint->fields) && !is_string($constraint->fields)) {
            throw new 
UnexpectedTypeException($constraint->fields'array');
        }

        if (
null !== $constraint->errorPath && !is_string($constraint->errorPath)) {
            throw new 
UnexpectedTypeException($constraint->errorPath'string or null');
        }

        
$fields = (array) $constraint->fields;

        if (
=== count($fields)) {
            throw new 
ConstraintDefinitionException('At least one field has to be specified.');
        }

        if (
$constraint->em) {
            
$em $this->registry->getManager($constraint->em);

            if (!
$em) {
               throw new 
ConstraintDefinitionException(sprintf('Object manager "%s" does not exist.'$constraint->em));
            }
        } else {
            
$em $this->registry->getManagerForClass(get_class($entity));

            if (!
$em) {
                throw new 
ConstraintDefinitionException(sprintf('Unable to find the object manager associated with an entity of class "%s".'get_class($entity)));
            }
        }

        
$class $em->getClassMetadata(get_class($entity));
        
/* @var $class \Doctrine\Common\Persistence\Mapping\ClassMetadata */

        
$criteria = array();
        foreach (
$fields as $fieldName) {
            if (!
$class->hasField($fieldName) && !$class->hasAssociation($fieldName)) {
                throw new 
ConstraintDefinitionException(sprintf("The field '%s' is not mapped by Doctrine, so it cannot be validated for uniqueness."$fieldName));
            }

            
$criteria[$fieldName] = $class->reflFields[$fieldName]->getValue($entity);

            if (
$constraint->ignoreNull && null === $criteria[$fieldName]) {
                return;
            }

            if (
null !== $criteria[$fieldName] && $class->hasAssociation($fieldName)) {
                
/* Ensure the Proxy is initialized before using reflection to
                 * read its identifiers. This is necessary because the wrapped
                 * getter methods in the Proxy are being bypassed.
                 */
                
$em->initializeObject($criteria[$fieldName]);

                
$relatedClass $em->getClassMetadata($class->getAssociationTargetClass($fieldName));
                
$relatedId $relatedClass->getIdentifierValues($criteria[$fieldName]);

                if (
count($relatedId) > 1) {
                    throw new 
ConstraintDefinitionException(
                        
"Associated entities are not allowed to have more than one identifier field to be " .
                        
"part of a unique constraint in: ".$class->getName()."#".$fieldName
                    
);
                }
                
$criteria[$fieldName] = array_pop($relatedId);
            }
        }

        
$repository $em->getRepository(get_class($entity));
        
$result $repository->{$constraint->repositoryMethod}($criteria);

        
/* If the result is a MongoCursor, it must be advanced to the first
         * element. Rewinding should have no ill effect if $result is another
         * iterator implementation.
         */
        
if ($result instanceof \Iterator) {
            
$result->rewind();
        } elseif (
is_array($result)) {
            
reset($result);
        }

        
/* If no entity matched the query criteria or a single entity matched,
         * which is the same as the entity being validated, the criteria is
         * unique.
         */
        
if (=== count($result) || (=== count($result) && $entity === ($result instanceof \Iterator $result->current() : current($result)))) {
            return;
        }

        
$errorPath null !== $constraint->errorPath $constraint->errorPath $fields[0];

        
$this->context->addViolationAt($errorPath$constraint->message, array(), $criteria[$fields[0]]);
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0039 ]--