/** * Esta funcion permite conocer las variables que se encuentran en el contenido * de los correos electronicos, para luego validar si el usuario proporciona * o no cada una de las variables a la hora de enviar el correo * @author Cesar Giraldo - Kijho Technologies <*****@*****.**> 30/11/2015 * @param Email $email * @param array[mixed] $dataToTemplate * @return array[string] arreglo con las variables que faltan por enviar al twig */ private function filterTwigVars(Email $email, $dataToTemplate) { $content = $email->getContent(); $lastPos = strpos($content, '}}'); $nullVars = array(); if ($lastPos > 0) { $var = trim(Util::getBetween($content, '{{', '}}')); if (!$this->isParameterInData($var, $dataToTemplate)) { array_push($nullVars, $var); } $noMoreParameters = false; while (!$noMoreParameters) { $content = substr($content, $lastPos + 2); $lastPos = strpos($content, '}}'); if ($lastPos > 0) { $var = trim(Util::getBetween($content, '{{', '}}')); if (!$this->isParameterInData($var, $dataToTemplate)) { array_push($nullVars, $var); } } else { $noMoreParameters = true; } } } return $nullVars; }
/** * Permite hallar las relaciones que tiene una entidad con otras entidades * a partir de la informacion en las anotaciones de sus atributos * Cesar Giraldo - Kijho Technologies <*****@*****.**> 17/11/2015 * @param array[\ReflectionClass] $instances arreglo de instancias a analizar * @return \ReflectionClass */ function getEntityRelationships($instances) { $relationships = array(); foreach ($instances as $instance) { foreach ($instance->getProperties() as $property) { //$property = new \ReflectionProperty; $docComment = $property->getDocComment(); $position = strpos($docComment, "targetEntity="); if ($position) { $docComment = substr($docComment, $position); $entityName = Util::getBetween($docComment, 'targetEntity="', '"'); if (empty($entityName)) { $entityName = Util::getBetween($docComment, "targetEntity='", "'"); } try { $entityNamespace = $this->getEntityNamespace(); //verificamos que la entidad este escrita con el namespace completo $positionNamespace = strpos($entityName, $entityNamespace); if ($positionNamespace === false) { $entityName = $entityNamespace . $entityName; } $object = new \ReflectionClass(new $entityName()); $relationships[$instance->getName()][$property->getName()] = $object; } catch (\Exception $exc) { // El namespace no esta escrito con ruta absoluta //echo $exc->getTraceAsString(); } } } } return $relationships; }