mlwacosmos
mlwacosmos

Reputation: 4561

Where to check if a class is loaded or not?

In HasRoleRepository.php :

use \XXX\MyBundle\Model\Role_RT;
use \XXX\MyBundle\Model\Role;

...


public static function toModelClass($hasRoleArray, $RefGroupeRtArray) {
    $roles = array();

    foreach($hasRoleArray as $hasRole) {
        $role = $hasRole->getIdRole()->getId() === 1 ? new Role_RT() : new Role();

    ....
}

I have a fatal error : Error: Class 'XXX\MyBundle\Model\Role_RT' not found in \src\XXX\MyBundle\Repository\HasRoleRepository.php line 37

No problem with the Role class, it is just with the Role_RT class.

Same namespace in Role and Role_RT :

namespace XXX\MyBundle\Model;

I do not understand. this one is not loaded. why ? how ?

Thank you

Upvotes: 0

Views: 125

Answers (2)

Yann Eugoné
Yann Eugoné

Reputation: 1351

I agree with Splendonia. If you want to use Symfony (and most generally Composer) you will have to do with the PSR-0 naming conventions.

Please have a look to :

Upvotes: 0

Splendonia
Splendonia

Reputation: 1369

It's considered a bad practice to use _ in Class Names meaning Symfony doesn't detected it (because it's build to prevent bad practices). Change your Model name to RoleRT and try again.

Upvotes: 1

Related Questions