سؤال

I'm required to load a component that contains a class that extends an object from a vendor.

As the vendor is loaded at runtime and the compenent is loaded at the initialisation of the controller, the script crashes.

How can I load this component at runtime and what class/filename convention should I use (CakePHP 1.3)?

هل كانت مفيدة؟

المحلول

You can use the App:import() method to load at run time.

<?php
    App::import('Component', 'Mailer');
    // We need to load the class
    $Mailer = new MailerComponent();
?>

From the manual : http://book.cakephp.org/view/936/Importing-Controllers-Models-Components-Behaviors-#Loading-Components-939

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top