Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Custom scaffold view extension
  • Hi gentlemen

    I made a custom scaffold in a subdir, i personnalize views with twig, (eg : php oil generate scaffold/custom monkey something:text) but there still is something left : i want my views to have twig extension (logical)

    I spotted the line, it's this little guy in packages/oil/class/generate/generate.php l.521

    // Create this view
    static::create($view_dir.$action.'.php', $view, 'view');

    Hard-coded, so...

    Question : What is the cleanest way to set the extension customizable, without modify this file, in case of updates or something 

    Thanks.
  • HarroHarro
    Accepted Answer
    Not very easy, Oil was never made to be extendible.

    With a bit of hack work it can be done though.

    First, copy generate.php to fuel/app/classes/oil/generate.php.

    Then open the oil front loader (the oil script in your fuel installation root), find Package::load('oil'), and after that, add

    Autoloader::add_classes(array(
        'Oil\\Generate'    => APPPATH.'classes/oil/generate.php',
    ));

    Now you have mapped to Oil\Generate class to your copy in fuel/app, instead of the one in the oil package. Now change whatever needs changing in your copy.
  • HarroHarro
    Accepted Answer
    p.s. it would probably be better if oil generate had a commandline switch to define the template type used, instead of the hardcoded php extension.

    Perhaps address that, and send a pull request?
  • I dont think i'm familiar enough with the oil package to make it properly, but maybe if i have some time later i'll do it. Thanks.

Howdy, Stranger!

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

In this Discussion