Yii Framework Forum: Component management design as a pattern - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Component management design as a pattern

#1 User is offline   kernel 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 91
  • Joined: 22-November 10

Posted 07 October 2011 - 03:37 AM

Instead of component managment only available to Yii::app()

$config = array(
  'comp1' => array(
    'class' => '...',
     ... other option ..
  ),
  'comp2' => array(
    'class' => '...',
     ... other option ..
  ),
);


$a = new ComponentManager($config);

$b = new ComponentManager($config);

$a->comp1-> ...

$b->comp2-> ...

1

#2 User is offline   gbasto 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 70
  • Joined: 28-September 10
  • Location:Portugal

Posted 07 October 2011 - 04:07 AM

Sounds nice.
0

#3 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,778
  • Joined: 17-January 09
  • Location:Russia

Posted 07 October 2011 - 09:50 AM

What's your use case for it?
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#4 User is offline   kernel 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 91
  • Joined: 22-November 10

Posted 08 October 2011 - 02:59 AM

The case is in general meaning, Coders can create their own ComponentManager at any point of time to make use of the ComponentManager's powerful lazyloading and object registry functionity, that will be a great helper to app design.

Event a temporary componentSet:

$a = new ComponentManager($TempConfig); //create a new temporary componentSet

... do sth. ... such as:

$a->comp1->blah();

$a->comp2->foo();

unset($a); // when I don't need it.
0

#5 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,778
  • Joined: 17-January 09
  • Location:Russia

Posted 08 October 2011 - 05:52 AM

So no real case for now? :)
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#6 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 10 October 2011 - 02:20 AM

One potential advantage of this could be, when you have many application components with lot of configuration. In that case you could move all that config to another file and only load it inside your custom component manager. On the other hand you can also achieve that by dynamically adding a component to the webapplication. So i also can't really see why a custom component manager is more useful than using an application component in the first place :).
0

#7 User is offline   Davidhhuan 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 270
  • Joined: 08-September 09

Posted 19 October 2011 - 09:38 AM

you can set it in main.php

'components'=>array_merge(include_once('path_to_your_components_settings_1'), include_once('path_to_your_components_settings_2'));

no pain, no gain...

My Blog : http://cnblogs.com/davidhhuan
My website: http://sharefamily.net/
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users