23642

Cakephp: Load components in components

Question:

in app_controller.php load Session, Auth components.

And in posts_controller.php, i use CustomComponent with $components = array('Session','Auth');

Then do CustomComponent must reload Session, Auth components?

if i use and create much components and that components use other components .It will make app is very slow?

<hr />

I asked in cakephp IRC, A person answer is not:

<blockquote>

[11:05] it will not be slow, I believe it passes those around via reference

[11:05] so you have nothing to worry about

</blockquote>

Answer1:

Lets say you want to import AComponent into BComponent.

AComponent

class AComponent extends Component { public $components = array('BComponent'); public function xyz(){ $test = $this->BComponent->abc($name); echo $test; } }

BComponent

class BComponent extends Component { public function abc($name){ return "My name is: ". $name; } }

Answer2:

yes, it would need to be $components = array('Session','Auth','Custom'); Or you can use: App::import('Component', 'Custom');$Custom = new CustomComponent();

Then do CustomComponent must reload Session, Auth components? If you don't use Session or Auth inside your CustomComponent class, then no.

It will make app is very slow? No, unless you use a lot of components.

Recommend

  • concatenating strings in C
  • SSH tunnel Complex Problem
  • Why won't TIdIRC connect to channel? Is there a better component?
  • List all tables in cakePHP 3.x
  • cakephp get schema for list of tables
  • How to: CakePHP logging in without password?
  • RVM not working after installing properly?
  • Cakephp Form Helper
  • How to browse android SDK sources in Android studio 2.0
  • Reload UITableView from another tab
  • How to lookup value with multiple criteria in excel 2007 and newer
  • Find tangent points on a curve from a user-given point outside the curve
  • Reloading table causes flickering
  • Is it possible to ask GIT, don't show a file?
  • Ruby: Why does this way of using map throw an error?
  • How to generate an asynchronous reset verilog always blocks with chisel
  • Mockery and Laravel constructor injection
  • How to access recipient on sent messages page with mailboxer
  • Is looping through all style sheets and classes a good idea in JavaScript?
  • How to create two column output from a single column
  • In loopback documentation what does variable 'cb' stands for?
  • using System.Speech.Synthesis with Windows10 universal app (XAML-C#)
  • Looking for good analogy/examples for monitor verses semaphore
  • GAE: Way to get reference to an HttpSession from its ID?
  • Spring boot 2.0.0.M4 required a bean named 'entityManagerFactory' that could not be found
  • What is the purpose of TaskExecutor in spring?
  • Asynchronous UI Testing in Xcode With Swift
  • req.body is undefined - nodejs
  • Symfony2: How to get request parameter
  • Weird JavaScript statement, what does it mean?
  • Jquery - Jquery Wysiwyg return html as a string
  • Akka Routing: Reply's send to router ends up as dead letters
  • Arrays break string types in Julia
  • Is there a mandatory requirement to switch app.yaml?
  • Comma separated Values
  • WPF Applying a trigger on binding failure
  • Error creating VM instance in Google Compute Engine
  • Hits per day in Google Big Query
  • how does django model after text[] in postgresql [duplicate]
  • Java static initializers and reflection