City-of-Bloomington / blossom

A skeleton for PHP web applications
GNU Affero General Public License v3.0
3 stars 0 forks source link

ActiveRecord does not take namespaces into account. #5

Closed inghamn closed 10 years ago

inghamn commented 10 years ago

the getDate and getForeignKey functions in ActiveRecord are not working with namespaces correctly.

inghamn commented 10 years ago

Does it make sense for ActiveRecord class to assume you must want a model from Application\Models?

I'm not so sure. I'm thinking it would be better for models to include the full namespace for the class the model would like. This is because I can see, as a developer, wanting to customize the namespace of my application. "Application" is just a stub. I would want to change it to match my project name.

So, maybe models should just include the namespace...like so....

<?php
namespace Application\Models;

use Blossom\Classes\ActiveRecord;

class Client extends ActiveRecord {
    protected $person;

    public function setPerson(Person $o) {
        parent::setForeignKeyObject(__namespace__.'\Person', 'person_id', $o);
    }
}