Skip to content

Added a doctrine orm query function for phone number#139

Open
modiamir wants to merge 2 commits into
misd-service-development:masterfrom
modiamir:master
Open

Added a doctrine orm query function for phone number#139
modiamir wants to merge 2 commits into
misd-service-development:masterfrom
modiamir:master

Conversation

@modiamir

Copy link
Copy Markdown

Added a function to use in doctrine query builder and DQL for making query based on PhoneNumber object like this:

$util = $this->get('libphonenumber.phone_number_util');
$phone = $util->parse('09125995014', 'IR');
        
$qb = $this->getDoctrine()->getRepository('AppBundle:User')
    ->createQueryBuilder('u');

$user = $qb->where($qb->expr()->eq('u.phone', "PHONE($phone)"))
    ->getQuery()
    ->getResult();

To use this DQL function we need to add this to symfony configuration:

doctrine:
    orm:
        dql:
            string_functions:
                PHONE: Misd\PhoneNumberBundle\Doctrine\ORM\DQL\Functions\Phone

@shakaran

shakaran commented Sep 1, 2017

Copy link
Copy Markdown
Contributor

@modiamir Could you update your PR since the test only fails for HHVM

HHVM is no longer supported on Ubuntu Precise. Please consider using Trusty with dist: trusty.

So @rh389 could check later and merge if all it is ok, thanks!

@modiamir modiamir force-pushed the master branch 2 times, most recently from 71c13c6 to 40fec7a Compare September 2, 2017 04:52
@modiamir

modiamir commented Sep 2, 2017

Copy link
Copy Markdown
Author

@shakaran i added dist: trusty to .travic-ci.yml, now tests pass for all versions of php

@shakaran

Copy link
Copy Markdown
Contributor

@modiamir Thanks very much! Now the maintainer could easy merge after his review ;)

@modiamir

Copy link
Copy Markdown
Author

@rh389 would you please review this pr?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants