Re: CakePHP 2.0 Component Calling Helper

2012-04-10 Thread euromark
with 2.1 the issue should be easy to resolve.
there are now great ways to keep the code dry and still use all classes 
accordingly:
http://www.dereuromark.de/2012/04/10/cakephp-now-fully-mvc/ 

You would make a Cleaner lib in /Utility and then you can still use some 
CleanerHelper with internally calls the Lib class.
Try to keep the method static for the controller/component level. Then 
there is no need to initialize it.
The helper can still work as it used to.


Am Samstag, 22. Oktober 2011 01:35:13 UTC+2 schrieb majna:
>
> there is 2.0 branch
>
> https://github.com/CakeDC/comments/blob/2.0/Controller/Component/CommentsComponent.php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: CakePHP 2.0 Component Calling Helper

2011-10-21 Thread majna
there is 2.0 branch
https://github.com/CakeDC/comments/blob/2.0/Controller/Component/CommentsComponent.php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: CakePHP 2.0 Component Calling Helper

2011-10-21 Thread euromark
looks kind of ugly
one more reason to get those functions out of the helpers into libs
there is no reason for almost 70% of all helper functions to be in
helpers
some might have to be used in controllers etc.
therefore they should be libs and the helpers should internally use
those libs.

it starts with text but doesnt end with time helper.

your "cleaner" helper seems to be a unjustified helper as well and
should also move its functionality to a lib.


On 21 Okt., 23:18, zuha  wrote:
> Solved (might be a better solution though, if anyone cares to critique my
> solution) :
>
> *Changed the function cleanHtml() from the above version to this version : *
> *
> *
> // in Comments/Controller/Component/CommentsComponent.php
> function cleanHtml($text, $settings = 'full') {
> App::import('Helper', 'Comments.Cleaner');
> App::uses('View', 'View');
> $this->View = new View($this->Controller);
> $cleaner = & new CleanerHelper($this->View);
> return $cleaner->clean($text, $settings);
>
>
>
>
>
>
>
> }

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: CakePHP 2.0 Component Calling Helper

2011-10-21 Thread zuha
Solved (might be a better solution though, if anyone cares to critique my 
solution) : 

*Changed the function cleanHtml() from the above version to this version : *
*
*
// in Comments/Controller/Component/CommentsComponent.php 
function cleanHtml($text, $settings = 'full') {
App::import('Helper', 'Comments.Cleaner');
App::uses('View', 'View');
$this->View = new View($this->Controller);
$cleaner = & new CleanerHelper($this->View);
return $cleaner->clean($text, $settings);
}

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


CakePHP 2.0 Component Calling Helper

2011-10-21 Thread zuha
So I'm working on upgrading the CakeDC Comments Plugin to 2.0, and I've hit 
a roadblock.  

// in Comments/Controller/Component/CommentsComponent.php
function cleanHtml($text, $settings = 'full') {
App::import('Helper', 'Comments.Cleaner');
$cleaner = & new CleanerHelper();
return $cleaner->clean($text, $settings);
}

and I get the follow error print out  (any help for how I get the view to 
from the component to the helper)? 

*Warning* (4096) 
:
 Argument 1 passed to CleanerHelper::__construct() must be an instance of View, 
none given, called in 
C:\wamp\www\zuha\app\Plugin\Comments\Controller\Component\CommentsComponent.php 
on line 678 and defined [*APP\Plugin\Comments\View\Helper\CleanerHelper.php*, 
line *78*]

*Notice* (8) 
:
 Undefined variable: View [*APP\Plugin\Comments\View\Helper\CleanerHelper.php*, 
line *82*]

*Warning* (4096) 
:
 Argument 1 passed to Helper::__construct() must be an instance of View, null 
given, called in 
C:\wamp\www\zuha\app\Plugin\Comments\View\Helper\CleanerHelper.php on line 82 
and defined [*CORE\Cake\View\Helper.php*, line *144*]

*Notice* (8) 
:
 Trying to get property of non-object [*CORE\Cake\View\Helper.php*, line *146*]

*Warning* (4096) 
:
 Argument 1 passed to CleanerHelper::__construct() must be an instance of View, 
none given, called in 
C:\wamp\www\zuha\app\Plugin\Comments\Controller\Component\CommentsComponent.php 
on line 678 and defined [*APP\Plugin\Comments\View\Helper\CleanerHelper.php*, 
line *78*]

*Notice* (8) 
:
 Undefined variable: View [*APP\Plugin\Comments\View\Helper\CleanerHelper.php*, 
line *82*]

*Warning* (4096) 
:
 Argument 1 passed to Helper::__construct() must be an instance of View, null 
given, called in 
C:\wamp\www\zuha\app\Plugin\Comments\View\Helper\CleanerHelper.php on line 82 
and defined [*CORE\Cake\View\Helper.php*, line *144*]

*Notice* (8) 
:
 Trying to get property of non-object [*CORE\Cake\View\Helper.php*, line *146*]



*// NOTE : I've already added this to the CleanerHelper... (View $View, 
$settings = array())*

public function __construct(View $View, $settings = array()) {
foreach ($this->config['full'] as $key => $value) {
$this->{$key} = $value;
}
parent::__construct($View, $settings);
}

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php