Find an email from database

@param  string $reference

@throws ReferenceNotFoundException

@return  EmailInterface|null
354679
public function getEmail($reference)
    {
        if (!isset($this->emails[$reference])) {
            $this->emails[$reference] = $this->em->getRepository($this->options['email_class'])->findOneByReference($reference);
        }

        $email = $this->emails[$reference];

        if (!$email instanceof EmailInterface) {
            throw new ReferenceNotFoundException($reference, sprintf('Reference "%s" does not exist for email.', $reference));
        }

        return $email;
    }
143771
public function resolve($reference)
    {
        $parts = explode('?:', $reference, 2);

        for ($index = 0; $index < count($parts); $index++) {
            try {
                return $this->resolver->resolve(trim($parts[$index]));
            }
            catch (UnknownDefinitionException $exception) {
                continue;
            }
        }

        return null;
    }
85682
public function offsetGet($reference)
    {
        $reference = $this->mapReference($reference);

        if (!array_key_exists($reference, $this->container)) {
            $this->createInstance($reference, [],
                false); //if the alias exists and not in container will create callable instance on fly;
        }

        $isFactory =
            is_object($this->container[$reference]) && method_exists($this->container[$reference], '__invoke');

        return $isFactory ? $this->container[$reference]($this) : $this->container[$reference];
    }
1349084
public static function getClassName($reference)
    {
        $reference = is_string($reference) ? $reference : ClassLookup::getClass($reference);
        $className = explode('\\', $reference);

        return array_pop($className);
    }
802916
private function convertObjectReference($reference)
    {
        if ($reference instanceof AbstractTable) {
            return $reference->getAliasOrName();
        } elseif ($reference instanceof BuilderInterface) {
            return $reference->buildSQL();
        } elseif ($reference instanceof RelativeClause) {
            $table = $this->convertObjectReference($reference->getRelatedTable());
            $clause = $this->convertObjectReference($reference->getClause());

            return str_replace($reference->getDirective(), $table . '.', $clause);
        }

        return $reference;
    }
455949
public static function factoryReference($reference) {
    $className = $reference[2];
    if (!class_exists($className)) {
      throw new Exceptions\EntityClassNotFoundException(
          "factoryReference called for a class that can't be found, $className."
      );
    }
    $entity = call_user_func([$className, 'factory']);
    $entity->referenceSleep($reference);
    return $entity;
  }
850127
public function findByEmail($email)
    {
        $this->addWhere('user_email', $email);
        $this->addWhere('user_is_activated', 1);

        try {
            $user = $this->selectOne();
        } catch (ExceptionNoData $exception) {
            throw new LoginException('Login and / or password is incorrect!', 1000, $exception);
        }

        return $user;
    }
170238
protected function generateExceptionMessage($reference)
    {
        $traces = debug_backtrace(false);

        $file = null;
        $line = null;

        foreach ($traces as $trace) {
            if (isset($trace['function']) && $trace['function'] == 'get' && isset($trace['class']) && $trace['class'] == __CLASS__) {
                $file = $trace['file'];
                $line = $trace['line'];
                break;
            }
        }

        $message = new ReferenceNotFoundMessage($reference, $file, $line);
        $message->setFrom($this->options['admin_email']);
        $message->setTo($this->options['admin_email']);

        return $message;
    }
1236756
protected static function getEmailByUsername($username)
    {
        if (empty($username)) {
            throw new BadRequestException("Missing required username.");
        }

        /** @var User $user */
        $user = User::whereUsername($username)->get(['email'])->first();

        if (empty($user)) {
            throw new NotFoundException('The supplied username was not found in the system.');
        }

        return $user->email;
    }
1293807
protected function unsetNullRecursively($data, $reference = null)
    {
        if (is_null($reference)) {
            $reference = $data;
        }

        $this->loop($reference, function ($key, $value) use (&$data) {
            if (is_array($data)) {
                if (is_null($value)) {
                    unset($data[$key]);
                } else {
                    $data[$key] = $this->unsetNullRecursively($value);
                }
            }

            if (is_object($data)) {
                if (is_null($value)) {
                    unset($data->$key);
                } else {
                    $data->$key = $this->unsetNullRecursively($value);
                }
            }
        });

        return $data;
    }
1186518
public function generate($reference)
    {
        $adapter = $this->getAdapter();
        if ($adapter instanceof AwsS3) {
            return $adapter->getUrl($reference);
        } elseif ($adapter instanceof Local) {
            $request = $this->getRequest();

            return $request->getSchemeAndHttpHost().'/'.$this->getLocalUploadDirectory().'/'.$reference;
        }

        return $reference;
    }
577502
public function getValueByReference($reference)
    {
        $qb = $this
            ->createQueryBuilder('e')
            ->select('SUM(e.value)')
            ->where('e.reference = :reference')
            ->setParameter('reference', $reference);

        return $qb
            ->getQuery()
            ->getSingleScalarResult();
    }
376922
protected function getCallbackFromReference($reference): callable
    {
        $this->reference = $reference;
        if(is_callable($reference)) {
            if(!is_string($reference)) {
                $callback = $reference;
            } else {
                $parts = explode("::", $reference);
                $callback = [new $parts[0](), $parts[1]];
            }
        } else {
            $callback = function () use ($reference) {
                new RegularResponse($reference);
            };
        }

        return $callback;
    }
1126780
public function get($reference, $default = null)
    {
        $reference = $this->computeKeyFQN($reference);

        // first look for exact match
        if (isset(self::$data[$reference])) {
            return self::$data[$reference];
        }

        // otherwise use a matcher to return a
        // collection of matching entries
        $matcher = $this->getMatcher();
        $matches = new Collection();

        Collection::cast(self::$data)->each(function (&$value, $key) use ($matcher, $reference, $matches) {
            if ($matcher->match($reference, $key)) {
                $matches[$key] = $value;
            }
        });

        if (!$matches->isEmpty()) return $matches;

        return $default;
    }
804472
static public function findByEMail($nb_customer, string $email)
    {
        $retval = null;

        if (is_numeric($nb_customer_id = nb_getMixedValue($nb_customer, NABU_CUSTOMER_FIELD_ID))) {
            $retval = CNabuUser::buildObjectFromSQL(
                'select u.* '
                . 'from nb_user u, nb_customer c '
               . 'where u.nb_customer_id=c.nb_customer_id '
                 . 'and c.nb_customer_id=%cust_id$d '
                 . 'and u.nb_user_email=\'%email$s\'',
                array(
                    'cust_id' => $nb_customer_id,
                    'email' => $email
                )
            );
            if ($retval instanceof CNabuUser && $nb_customer instanceof CNabuCustomer) {
                $retval->setCustomer($nb_customer);
            }
        }

        return $retval;
    }
1024056
public function getReference($key)
    {
        if (isset($this->references[$key])) {
            return $this->references[$key];
        }

        return null; // just to be explicit
    }
1077602
private function loadExternalRef($reference)
    {
        list($prefix, $path) = parse_external_ref($reference);
        return $this->loaderManager->getLoader($prefix)->load($path);
    }