Symfony\Component\Validator\Validator::validate PHP Method

validate() public method

{@inheritDoc}
public validate ( $object, $groups = null )
    public function validate($object, $groups = null)
    {
        $metadata = $this->metadataFactory->getClassMetadata(get_class($object));

        $walk = function(GraphWalker $walker, $group) use ($metadata, $object) {
            return $walker->walkObject($metadata, $object, $group, '');
        };

        return $this->validateGraph($object, $walk, $groups);
    }

Usage Example

 /**
  * Factory an implementation adding it to container builder
  * after being validated in structure (not connection) of
  * each server data
  *
  * @param  string                    $implementation
  * @param  array                     $configuration
  * @param  ContainerBuilder          $containerBuilder
  * @throws BadConfigurationException
  */
 public function factoryImplementationConfiguration($implementation, array $configuration, ContainerBuilder $containerBuilder)
 {
     $serversToStore = array();
     if (!in_array($implementation, UrodozCacheExtension::$availableImplementations)) {
         throw new BadConfigurationException("The implementation {" . $implementation . "} is not supported by the bundle UrodozCacheManager");
     }
     $implementationConfigs = static::$implementationsConfigs[$implementation];
     $validationStoreClass = $implementationConfigs["validationStoreClass"];
     $servers = $configuration[$implementation]["servers"];
     foreach ($servers as $serverString) {
         $explodedServerString = explode(":", $serverString);
         if (count($explodedServerString) != 2) {
             throw new BadConfigurationException("Expected {host}:{port} on server definition, got : " . $serverString);
         }
         //Create the store and validates it
         $storeValidator = new $validationStoreClass($explodedServerString[0], (int) $explodedServerString[1]);
         $violationCollection = $this->validator->validate($storeValidator);
         if (count($violationCollection) != 0) {
             throw new BadConfigurationException("Error on server definition : " . $serverString . ". " . $violationCollection[0]->getMessage() . " at property {" . $violationCollection[0]->getPropertyPath() . "}");
         }
         //Store the server definition on the array to inject on the container
         $serversToStore[] = array("host" => $explodedServerString[0], "port" => (int) $explodedServerString[1]);
     }
     //Store the response on the container
     $containerBuilder->setParameter($implementationConfigs["parameterKey"], $serversToStore);
 }
All Usage Examples Of Symfony\Component\Validator\Validator::validate