Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Auth package migrations with changed models
  • I use some changed Ormauth for my own needs. In fact I changed only schema with my additional migration and make my own models in /fuel/apps/classes/model/auth/*

    I use this in  bootstrap.php:

    \Autoloader::add_classes(array(
        // Add classes you want to override here
        // Example: 'View' => APPPATH.'classes/view.php',
        'Model\Auth_User'            => APPPATH.'classes/model/auth/user.php',
        'Model\Auth_Metadata'        => APPPATH.'classes/model/auth/metadata.php',
        'Model\Auth_Group'           => APPPATH.'classes/model/auth/group.php',
        'Model\Auth_Role'            => APPPATH.'classes/model/auth/role.php',
        'Model\Auth_Permission'      => APPPATH.'classes/model/auth/permission.php',
        'Model\Auth_Userpermission'  => APPPATH.'classes/model/auth/userpermission.php',
        'Model\Auth_Grouppermission' => APPPATH.'classes/model/auth/grouppermission.php',
        'Model\Auth_Rolepermission'  => APPPATH.'classes/model/auth/rolepermission.php'
    ));

    It is all ok till I tried revert migrations to 0 and reapply it again. I encountered with problem: Auth package migrations use models for making some work, but they doesn't load its own models, and they loads mine. At this early moment schema is not changed yet and my models do not correspond it - this causes an error.

    May be I need oil reqests use without registering my model with Autoloader. How can I distinguish oil and web requests?
  • If you extend, you should make sure to remain compatible. You obviously havent, so that is what you need to fix.

    Since you have extended, migrations will use your extended version, that is the entire idea behind framework class extensions in Fuel...

    You can create dependencies in migrations by returning false in your up() or down() method. For example, if your migrations tests in up() for the existence of the "users" table, it will always run after the Auth migrations have run. It allows you to alter the sequence in which migrations will run.
  • May be as great solution you are right, but for simpliest way it enough to make oil working with Auth models. So I need to distinguish oil and web requests in bootstrap.php and add condition for registering my models with Autoloader.

    Since I don't use my models in my migrations it will be ok to allow oil works always with original Auth models.

    Is there an easy way to distinguish this requests?

    May be I need to re-read documentation...
  • Hmm... I found the dumb, but simple solution :]

    if (isset($routerequest))
      \Autoloader::add_classes(array(
        // Add classes you want to override here
        // Example: 'View' => APPPATH.'classes/view.php',
        'Model\Auth_User'            => APPPATH.'classes/model/auth/user.php',
        'Model\Auth_Metadata'        => APPPATH.'classes/model/auth/metadata.php',
        'Model\Auth_Group'           => APPPATH.'classes/model/auth/group.php',
        'Model\Auth_Role'            => APPPATH.'classes/model/auth/role.php',
        'Model\Auth_Permission'      => APPPATH.'classes/model/auth/permission.php',
        'Model\Auth_Userpermission'  => APPPATH.'classes/model/auth/userpermission.php',
        'Model\Auth_Grouppermission' => APPPATH.'classes/model/auth/grouppermission.php',
        'Model\Auth_Rolepermission'  => APPPATH.'classes/model/auth/rolepermission.php'
    ));

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

  • bvn September 2015
  • Harro September 2015