{"action":"created","issue":{"url":"https://api.github.com/repos/cargomedia/CM/issues/1588","labels_url":"https://api.github.com/repos/cargomedia/CM/issues/1588/labels{/name}","comments_url":"https://api.github.com/repos/cargomedia/CM/issues/1588/comments","events_url":"https://api.github.com/repos/cargomedia/CM/issues/1588/events","html_url":"https://github.com/cargomedia/CM/issues/1588","id":54088747,"number":1588,"title":"Allow to find by abbreviation (or name) in CM_Model_Location","user":{"login":"dlondero","id":209782,"avatar_url":"https://avatars.githubusercontent.com/u/209782?v=3","gravatar_id":"","url":"https://api.github.com/users/dlondero","html_url":"https://github.com/dlondero","followers_url":"https://api.github.com/users/dlondero/followers","following_url":"https://api.github.com/users/dlondero/following{/other_user}","gists_url":"https://api.github.com/users/dlondero/gists{/gist_id}","starred_url":"https://api.github.com/users/dlondero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlondero/subscriptions","organizations_url":"https://api.github.com/users/dlondero/orgs","repos_url":"https://api.github.com/users/dlondero/repos","events_url":"https://api.github.com/users/dlondero/events{/privacy}","received_events_url":"https://api.github.com/users/dlondero/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cargomedia/CM/labels/ready","name":"ready","color":"ededed"}],"state":"open","locked":false,"assignee":{"login":"dlondero","id":209782,"avatar_url":"https://avatars.githubusercontent.com/u/209782?v=3","gravatar_id":"","url":"https://api.github.com/users/dlondero","html_url":"https://github.com/dlondero","followers_url":"https://api.github.com/users/dlondero/followers","following_url":"https://api.github.com/users/dlondero/following{/other_user}","gists_url":"https://api.github.com/users/dlondero/gists{/gist_id}","starred_url":"https://api.github.com/users/dlondero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlondero/subscriptions","organizations_url":"https://api.github.com/users/dlondero/orgs","repos_url":"https://api.github.com/users/dlondero/repos","events_url":"https://api.github.com/users/dlondero/events{/privacy}","received_events_url":"https://api.github.com/users/dlondero/received_events","type":"User","site_admin":false},"milestone":null,"comments":5,"created_at":"2015-01-12T18:27:24Z","updated_at":"2015-01-14T13:53:07Z","closed_at":null,"body":"It would be great to be able to `findByAbbreviation()` countries and states as right now that could be done only by `id` and most of the times that differs from development to production.\r\n\r\nOne idea could be to add `CM_Model_Location_Abstract::findByAttribute($key, $value)` and use it directly or call it from `CM_Model_Location_Country::findByAbbreviation()`.\r\n\r\nAs countries and states are in different tables it would be good to pull `CM_Model_Abstract:: getTableName()` changes from #1580.\r\n\r\n@njam FYI"},"comment":{"url":"https://api.github.com/repos/cargomedia/CM/issues/comments/69918363","html_url":"https://github.com/cargomedia/CM/issues/1588#issuecomment-69918363","issue_url":"https://api.github.com/repos/cargomedia/CM/issues/1588","id":69918363,"user":{"login":"tomaszdurka","id":113303,"avatar_url":"https://avatars.githubusercontent.com/u/113303?v=3","gravatar_id":"","url":"https://api.github.com/users/tomaszdurka","html_url":"https://github.com/tomaszdurka","followers_url":"https://api.github.com/users/tomaszdurka/followers","following_url":"https://api.github.com/users/tomaszdurka/following{/other_user}","gists_url":"https://api.github.com/users/tomaszdurka/gists{/gist_id}","starred_url":"https://api.github.com/users/tomaszdurka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomaszdurka/subscriptions","organizations_url":"https://api.github.com/users/tomaszdurka/orgs","repos_url":"https://api.github.com/users/tomaszdurka/repos","events_url":"https://api.github.com/users/tomaszdurka/events{/privacy}","received_events_url":"https://api.github.com/users/tomaszdurka/received_events","type":"User","site_admin":false},"created_at":"2015-01-14T13:53:07Z","updated_at":"2015-01-14T13:53:07Z","body":"Even though the only usage is country abbreviation let's go for more generic solutions. We can introduce either:\r\n- `CM_Model_Location::findByAttirbute($level, $key, $value)`\r\n- `CM_Model_Location_Abstract::findByAttirbute($key, $value)`\r\n- `CM_Model_Abstract::findByAttirbute($key)` combined with `CM_Model_StorageAdapter_Database::findByAttirbute($key, $value)` \r\n\r\nI would vote for option 2. Caching would be done as you've noted down.\r\n\r\n@dlondero do you agree?"}}