easybib / EasyBib_DoctrineResource

Modular Doctrine setup/bootstrapping for Zend Framework(1)
Other
5 stars 1 forks source link

hardcoded entity folder and wrong folder paths in different contexts #6

Open lenada opened 11 years ago

lenada commented 11 years ago

Do we really want to add this folder although it does not necessarily exist in a project?

https://github.com/easybib/EasyBib_DoctrineResource/blob/master/src/EasyBib/Doctrine/DoctrineResource.php#L299

another issue I ran into: when using doctrineResource from within a module, which does not live in app/modules/ (for example in a travis-ci test environment)

the path determined by getModulePath does not resolve to an existing folder, actually it generates something like: /bibsample/app/modules/infolit/app/modules/infolit/src/InfoLit/Entity

a rather dirty way to fix this issue would be the following, which leads to increased FS-reads :( cannot think of a better way right now.


    /**
     * Get Entity folders
     *
     * @return array
     */
    protected function getEntityFolders()
    {
        $folders = array();

        //only set default entity dir if it really exists
        if (is_dir($this->rootPath . '/library/Doctrine/Model')) {
            $folders[] = $this->rootPath . '/library/Doctrine/Model';
        }

        //set configured entity-dir if run in module-standalone context
        if (is_dir($this->rootPath . '/' . $this->config->modelFolder)) {
            $folders[] = $this->rootPath . '/' . $this->config->modelFolder;
        }

        //set configured entity-dir if run in module context
        if (is_dir($this->getModulePath() . $this->config->modelFolder)) {
            $folders[] = $this->modulePath . '/' . $this->config->modelFolder;
        }

        return $folders;
    }
Mischosch commented 11 years ago

yeah, when we started with Doctrine Resource it was close connected to our used setup. So, this is where hardcoded things are coming from.

perhaps the best approach would be to give the Resource an array of all needed paths? Would make the class more common usable. The question is in general, if we will test given path for existence or take them, as they come :)

@till any thoughts on this?

till commented 11 years ago

Yeah, potentially, we should allow to override this behavior — especially since we plan on moving these entities in EasyBib as well. I have to think about this though for a bit.