Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading the Component on the Fly #4

Closed
cpierce opened this issue Oct 31, 2013 · 5 comments
Closed

Loading the Component on the Fly #4

cpierce opened this issue Oct 31, 2013 · 5 comments

Comments

@cpierce
Copy link

cpierce commented Oct 31, 2013

I'm trying to load the Component on the fly but it is requesting that the controller be passed in startup(). Why? It isn't being used anywhere.

@chronon
Copy link
Owner

chronon commented Nov 1, 2013

You're right in that it's not presently being used anywhere, but removing it breaks E_STRICT compatibility for PHP 5.4. Running tests without it (on PHP 5.4.x) result in an exception with message:

Declaration of StripeComponent::startup() should be compatible with Component::startup(Controller $controller)

@cpierce
Copy link
Author

cpierce commented Nov 1, 2013

so if I were going to load it on the fly I'd do

$this->Stripe = $this->Components->load('Stripe.Stripe');
$this->Stripe->startup();

but what would I sent from within the Controller to pass correctly?

Thanks in advance.

I'm using the component for a multi-account environment so loading it in the $components isn't viable for my application.

@chronon
Copy link
Owner

chronon commented Nov 1, 2013

Have you tried $this->Stripe->startup(null);?

@cpierce
Copy link
Author

cpierce commented Nov 1, 2013

i passed 'Account' which is the name of my controller and it said it
shouldn't be a string ... i will try null

On Fri, Nov 1, 2013 at 8:31 AM, Gregory Gaskill notifications@github.comwrote:

Have you tried $this->Stripe->startup(null);?


Reply to this email directly or view it on GitHubhttps://github.com//issues/4#issuecomment-27565437
.

Chris Pierce
Computer Services of Durant, Inc.
cpierce@csdurant.com / www.csdurant.com
t. 580-920-1216 / f. 580-745-5317

http://www.facebook.com/cpierce http://www.twitter.com/chrislpierce
http://www.linkedin.com/in/cpierce

@josegonzalez
Copy link

You can also try doing:

$this->Stripe->startup($this);

If you are in a controller context. Otherwise, a simple Controller object will do:

if (!$request = Router::getRequest(true)) {
    $request = new CakeRequest();
}
$response = new CakeResponse();
$controller = new Controller($request, $response);
$this->Stripe->startup($this);

ExceptionRenderer::_getController($request) is an example of this.

I'd +1 closing this ticket.

@chronon chronon closed this as completed Dec 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants